MovingObject.java 2.41 KB
Newer Older
Juon Kawakami's avatar
init  
Juon Kawakami committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package firesimulator.world;

/**
 * @author tn
 *
 */
public abstract class MovingObject extends RealObject {

    private int stamina=0;
    private int hp=0;
    private int damage=0;
    private int buriedness=0;
    private int positionId=0;
    private int positionExtra=0;
    private RescueObject position;
    protected World world = null; 
    private String currentAction;
    private int currentActionLastChange;
    private int x;
    private int y;
	
    public MovingObject(int id) {
        super(id);
        currentAction = "AK_REST";
        currentActionLastChange = 0;
    }
	
    public void setWorld(World w) {
        world = w; 
    }


    public void setPositionId(int id){
        positionId=id;
        if (world != null) {
            position = world.getObject(positionId);
        }
    }
	
    public int getPositionId(){
        return positionId;
    }
	
    public void setPositionExtra(int pos){
        positionExtra=pos;
    }
	
    public int getPositionExtra(){
        return positionExtra;
    }
	
    public void setPosition(){
		
    }

    public StationaryObject getLocation(){
        if (position instanceof MovingObject)
            return ((MovingObject) position).getLocation();
        else if (position instanceof StationaryObject)
            return (StationaryObject) position;
        else 
            return null;
    }
	
    public int getLocationID(){
        if (position instanceof MovingObject)
            return ((MovingObject) position).getLocationID();
        else if (position instanceof StationaryObject)
            return position.id;
        else 
            return -1;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setX(int x) {
        this.x = x;
    }
	
    public void setY(int y) {
        this.y = y;
    }
	
    public void setStamina(int stamina){
        this.stamina=stamina;
    }
	
    public void setHp(int hp){
        this.hp=hp;
    }
	
    public void setDamage(int damage){
        this.damage=damage;
    }
	
    public void setBuriedness(int buriedness){
        this.buriedness=buriedness;
    }
	
    public String getCurrentAction() {
        if(world.getTime()>currentActionLastChange)
            return "AK_REST";
        return currentAction;
    }

    public void setCurrentAction(String action) {
        currentActionLastChange = world.getTime();
        currentAction = action;
    }

}