1 package se
.umu
.cs
.dit06ajnajs
.map
;
4 import se
.umu
.cs
.dit06ajnajs
.agent
.Unit
;
5 import java
.util
.logging
.Logger
;
6 import se
.umu
.cs
.dit06ajnajs
.agent
.Direction
;
7 import java
.awt
.Graphics
;
9 import se
.umu
.cs
.dit06ajnajs
.AntiTD
;
10 import java
.util
.Observer
;
11 import java
.util
.Observable
;
13 public class StartSquare
extends MapSquare
implements Traversable
, Observer
{
14 private static Logger logger
= Logger
.getLogger("AntiTD");
15 private boolean active
= false;
17 // TODO, set startDirection dynamicly
18 private Direction startDirection
= Direction
.UP
;
20 public StartSquare(int x
, int y
, Image image
) {
24 public boolean isActive() {
28 public void setActive(boolean active
) {
32 public void setStartDirection(Direction directioin
) {
33 this.startDirection
= directioin
;
36 public Direction
getStartDirection() {
37 return this.startDirection
;
40 public void landOn(Unit unit
) {
41 // TODO copied from GoalSquare, how do we implement a starting Unit?
43 unit
.setDirection(startDirection
);
47 * Sets this StartSquare as active.
60 public void paint(Graphics g
) {
63 g
.setColor(Color
.GREEN
);
64 g
.drawRect(getX(), getY(),
65 AntiTD
.SQUARE_SIZE
- 1, AntiTD
.SQUARE_SIZE
- 1);
66 g
.drawRect(getX() - 1, getY() - 1,
67 AntiTD
.SQUARE_SIZE
- 2, AntiTD
.SQUARE_SIZE
- 2);
72 * Called when another StartSquare is activated, which means that this
73 * StartSquare should not be active.
75 * @param observer an <code>Observable</code> value
76 * @param obj an <code>Object</code> value
78 public void update(Observable observer
, Object obj
) {
79 logger
.info("Update in StartSquare: active is set to false");