|
|
package com.sheep.model;
|
|
|
|
|
|
/*
|
|
|
图层类
|
|
|
二维表格
|
|
|
记录当前地图的坐标偏移量、行、列、最大存储量、当前牌数量
|
|
|
存储map向Brand赋值,上一层Layer,方便置灰函数操作
|
|
|
*/
|
|
|
|
|
|
public class Layer {
|
|
|
private Integer offsetx;//偏移位置x
|
|
|
private Integer offsety;//偏移位置y
|
|
|
|
|
|
private Integer rowNum;//行
|
|
|
private Integer colNum;//列
|
|
|
|
|
|
private Integer capacity;//当前图层最大牌容量
|
|
|
private Integer size;//当前牌数量
|
|
|
|
|
|
private Layer parent;//上一层图层对象
|
|
|
|
|
|
private Cell[][] cells = null;//存储的二维表格
|
|
|
|
|
|
private Map map;//当前所在的map
|
|
|
|
|
|
//有参构造,根据传入的行列实现表格初始化
|
|
|
public Layer(Integer rowNum,Integer colNum) {
|
|
|
this.rowNum = rowNum;
|
|
|
this.colNum = colNum;
|
|
|
|
|
|
this.capacity = this.rowNum * this.rowNum;
|
|
|
|
|
|
this.cells = new Cell[this.rowNum][this.colNum];
|
|
|
this.size = 0;
|
|
|
|
|
|
offsetx = 0;
|
|
|
offsety = 0;
|
|
|
}
|
|
|
|
|
|
//打印表格,用于开发阶段测试使用
|
|
|
public void showCells(){
|
|
|
for(int row = 0;row < cells.length;row++){
|
|
|
for(int col = 0;col<cells[row].length;col++){
|
|
|
System.out.print(cells[row][col].getBrand().getName()+" ");
|
|
|
}
|
|
|
System.out.println();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//alt+ins打开生成可选择Getter和Setter可以快速得到以下函数
|
|
|
|
|
|
|
|
|
public Map getMap() {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
public void setMap(Map map) {
|
|
|
this.map = map;
|
|
|
}
|
|
|
|
|
|
public Layer getParent() {
|
|
|
return parent;
|
|
|
}
|
|
|
|
|
|
public void setParent(Layer parent) {
|
|
|
this.parent = parent;
|
|
|
}
|
|
|
|
|
|
public Integer getOffsetx() {
|
|
|
return offsetx;
|
|
|
}
|
|
|
|
|
|
public void setOffsetx(Integer offsetx) {
|
|
|
this.offsetx = offsetx;
|
|
|
}
|
|
|
|
|
|
public Integer getOffsety() {
|
|
|
return offsety;
|
|
|
}
|
|
|
|
|
|
public void setOffsety(Integer offsety) {
|
|
|
this.offsety = offsety;
|
|
|
}
|
|
|
|
|
|
public Integer getRowNum() {
|
|
|
return rowNum;
|
|
|
}
|
|
|
|
|
|
public void setRowNum(Integer rowNum) {
|
|
|
this.rowNum = rowNum;
|
|
|
}
|
|
|
|
|
|
public Integer getColNum() {
|
|
|
return colNum;
|
|
|
}
|
|
|
|
|
|
public void setColNum(Integer colNum) {
|
|
|
this.colNum = colNum;
|
|
|
}
|
|
|
|
|
|
public Integer getCapacity() {
|
|
|
return capacity;
|
|
|
}
|
|
|
|
|
|
public void setCapacity(Integer capacity) {
|
|
|
this.capacity = capacity;
|
|
|
}
|
|
|
|
|
|
public Integer getSize() {
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
public void setSize(Integer size) {
|
|
|
this.size = size;
|
|
|
}
|
|
|
|
|
|
public Cell[][] getCells() {
|
|
|
return cells;
|
|
|
}
|
|
|
|
|
|
public void setCells(Cell[][] cells) {
|
|
|
this.cells = cells;
|
|
|
}
|
|
|
}
|