You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}