-
Notifications
You must be signed in to change notification settings - Fork 11
/
Scene.java
117 lines (95 loc) · 2.61 KB
/
Scene.java
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
import java.util.*;
/**
* Write a description of class Scene here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Scene
{
private Scene[] neighbourScenes = new Scene[4];
private List<Entity> entities = new ArrayList<Entity>();
private String background = "bg.png";
private int width;
private int height;
private String name;
private String soundToPlay;
/**
* Constructor for objects of class Scene
*/
public Scene()
{
this.name = Game.generateRandomString();
}
public Scene(String name)
{
this.name = name;
}
public Scene getNeighbourScene(Direction direction) {
return neighbourScenes[direction.getValue()];
}
public void setNeighbourScene(Direction direction, Scene scene) {
neighbourScenes[direction.getValue()] = scene;
switch(direction) {
case NORTH:
scene.neighbourScenes[Direction.SOUTH.getValue()] = this;
break;
case SOUTH:
scene.neighbourScenes[Direction.NORTH.getValue()] = this;
break;
case WEST:
scene.neighbourScenes[Direction.EAST.getValue()] = this;
break;
case EAST:
scene.neighbourScenes[Direction.WEST.getValue()] = this;
break;
}
}
public List<Entity> getEntities() {
return entities;
}
public void setEntities(List<Entity> entities) {
this.entities = entities;
}
public void clearEntities() {
entities.clear();
}
/**
* Add a entity to the scene
*
* @param entity to be added to the scene
*/
public void addEntity(Entity entity) {
entities.add(entity);
}
public String getBackground() {
return this.background;
}
public void setBackground(String background) {
this.background = background;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getSoundToPlay() {
return soundToPlay;
}
public void setSoundToPlay(String soundToPlay) {
this.soundToPlay = soundToPlay;
}
}