1 package se
.umu
.cs
.dit06ajnajs
;
3 import java
.awt
.Dimension
;
6 import java
.util
.ArrayList
;
8 import se
.umu
.cs
.dit06ajnajs
.agent
.Agent
;
9 import se
.umu
.cs
.dit06ajnajs
.agent
.Tower
;
10 import se
.umu
.cs
.dit06ajnajs
.map
.Map
;
11 import se
.umu
.cs
.dit06ajnajs
.map
.MapBuilder
;
12 import se
.umu
.cs
.dit06ajnajs
.map
.MapSquare
;
13 import se
.umu
.cs
.dit06ajnajs
.map
.PathSquare
;
14 import se
.umu
.cs
.dit06ajnajs
.map
.TowerSquare
;
16 public class ATDModel
{
22 public ATDModel(List
<Map
> maps
) {
23 this.agents
= new ArrayList
<Agent
>();
25 this.currentMap
= maps
.get(0); //MapBuilder.createMap();
28 public void addTower(Tower t
) {
29 TowerSquare square
= currentMap
.getRandomFreeTowerSquare();
31 // If there is a free square, place tower
32 Point p
= square
.getPosition();
36 //Register as observer for the neighbours in range
37 int shootRange
= t
.getRange();
39 (int) Math
.ceil((shootRange
- AntiTD
.SQUARE_SIZE
*0.5)
40 / (AntiTD
.SQUARE_SIZE
));
42 List
<MapSquare
> neighbours
43 = this.currentMap
.getNeighbours(square
, squareRange
);
44 for (MapSquare neighbour
: neighbours
) {
45 if(neighbour
instanceof PathSquare
) {
46 neighbour
.addObserver(square
);
51 System
.out
.println("No available towersquares");
57 public void addAgent(Agent agent
) {
58 // TODO Auto-generated method stub
62 public List
<Agent
> getAgents() {
63 // TODO Auto-generated method stub
68 return this.currentMap
;
71 public Image
getMapImage() {
72 return currentMap
.getMapImage();
75 public Dimension
getMapDimension() {
76 return currentMap
.getDimension();