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.
78 lines
1.6 KiB
78 lines
1.6 KiB
package model;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class MapCreature {
|
|
private final int sizeTile;
|
|
private final int sizeMap;
|
|
private final ArrayList<Case> map = new ArrayList<>();
|
|
private int coordStartX;
|
|
private int coordStartY;
|
|
|
|
public MapCreature(int sizeTile, int sizeMap) {
|
|
this.coordStartX = getCoordStartX();
|
|
this.coordStartY = getCoordStartY();
|
|
this.sizeTile = sizeTile;
|
|
this.sizeMap = sizeMap;
|
|
}
|
|
|
|
public void addCase(Case c) {
|
|
this.map.add(c);
|
|
if(c.isStart){
|
|
setCoordStartX(c.coordX);
|
|
setCoordStartY(c.coordY);
|
|
}
|
|
}
|
|
public void removeCase(Case c) {
|
|
this.map.remove(c);
|
|
}
|
|
public ArrayList<Case> getMap() {
|
|
return this.map;
|
|
}
|
|
public int getSizeTile() {
|
|
return this.sizeTile;
|
|
}
|
|
public int getSizeMap() {
|
|
return this.sizeMap;
|
|
}
|
|
public int getCoordStartX(){
|
|
return coordStartX;
|
|
}
|
|
public void setCoordStartX(int x){
|
|
this.coordStartX = x;
|
|
}
|
|
public int getCoordStartY(){
|
|
return coordStartY;
|
|
}
|
|
public void setCoordStartY(int y){
|
|
this.coordStartY = y;
|
|
}
|
|
|
|
public Case getNextCase(Case c){
|
|
int i;
|
|
int j;
|
|
for(i = 0; i < this.map.size(); i++){
|
|
if(c == this.map.get(i)){
|
|
j=i+1;
|
|
return this.map.get(j);
|
|
}
|
|
}
|
|
return c;
|
|
}
|
|
|
|
public Case getStartCase(){
|
|
for(Case c : this.map){
|
|
if(c.isStart){
|
|
System.out.println(c);
|
|
return c;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|