1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | using Jypeli.Assets; |
---|
7 | using MathHelper; |
---|
8 | using Entity; |
---|
9 | using Items; |
---|
10 | |
---|
11 | namespace Rooms |
---|
12 | { |
---|
13 | class EmptyRoom : Room |
---|
14 | { |
---|
15 | public EmptyRoom(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
16 | : base(game, pos, size, thickness) |
---|
17 | { |
---|
18 | } |
---|
19 | |
---|
20 | public override void initRoom() |
---|
21 | { |
---|
22 | createLevelDecorations(); |
---|
23 | |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | class RoomType1 : Room |
---|
28 | { |
---|
29 | public RoomType1(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
30 | : base(game, pos, size, thickness) |
---|
31 | { |
---|
32 | } |
---|
33 | |
---|
34 | public override void initRoom() |
---|
35 | { |
---|
36 | createLevelDecorations(); |
---|
37 | |
---|
38 | addBlock(new ObjectRock(blockWidth, blockHeight), 0, 0); |
---|
39 | addBlock(new ObjectRock(blockWidth, blockHeight), bWidth - 1, 0); |
---|
40 | addBlock(new ObjectRock(blockWidth, blockHeight), 0, bHeight - 1, new Vector(0, -50)); |
---|
41 | addBlock(new ObjectRock(blockWidth, blockHeight), bWidth - 1, bHeight - 1, new Vector(0, -50)); |
---|
42 | |
---|
43 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
44 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | class RoomType2 : Room |
---|
49 | { |
---|
50 | public RoomType2(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
51 | : base(game, pos, size, thickness) |
---|
52 | { |
---|
53 | } |
---|
54 | |
---|
55 | public override void initRoom() |
---|
56 | { |
---|
57 | createLevelDecorations(); |
---|
58 | |
---|
59 | for (int i = 0; i < 3; i++) |
---|
60 | { |
---|
61 | addBlock(new ObjectRock(blockWidth, blockHeight), 1, 1 + i, new Vector(0, -50)); |
---|
62 | } |
---|
63 | |
---|
64 | for (int i = 0; i < 3; i++) |
---|
65 | { |
---|
66 | addBlock(new ObjectRock(blockWidth, blockHeight), 8, 1 + i, new Vector(0, -50)); |
---|
67 | } |
---|
68 | |
---|
69 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
70 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | class RoomType3 : Room |
---|
75 | { |
---|
76 | public RoomType3(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
77 | : base(game, pos, size, thickness) |
---|
78 | { |
---|
79 | } |
---|
80 | |
---|
81 | public override void initRoom() |
---|
82 | { |
---|
83 | createLevelDecorations(); |
---|
84 | |
---|
85 | for (int i = 0; i < 4; i++) |
---|
86 | { |
---|
87 | addBlock(new ObjectRock(blockWidth, blockHeight), i, 1); |
---|
88 | } |
---|
89 | |
---|
90 | for (int i = 0; i < 4; i++) |
---|
91 | { |
---|
92 | addBlock(new ObjectRock(blockWidth, blockHeight), i, 4); |
---|
93 | } |
---|
94 | |
---|
95 | for (int i = 0; i < 4; i++) |
---|
96 | { |
---|
97 | addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 1); |
---|
98 | } |
---|
99 | |
---|
100 | for (int i = 0; i < 4; i++) |
---|
101 | { |
---|
102 | addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 4); |
---|
103 | } |
---|
104 | |
---|
105 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
106 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | class RoomType4 : Room |
---|
111 | { |
---|
112 | public RoomType4(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
113 | : base(game, pos, size, thickness) |
---|
114 | { |
---|
115 | } |
---|
116 | |
---|
117 | public override void initRoom() |
---|
118 | { |
---|
119 | createLevelDecorations(); |
---|
120 | |
---|
121 | for (int y = 1; y < bHeight; y++) |
---|
122 | { |
---|
123 | for (int x = 1; x < bWidth - 1; x++) |
---|
124 | { |
---|
125 | if (x % 2 != 0 && y % 2 != 0) |
---|
126 | addBlock(new ObjectRock(blockWidth, blockHeight), x, y, new Vector(40, 0)); |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
131 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | class RoomType5 : Room |
---|
136 | { |
---|
137 | public RoomType5(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
138 | : base(game, pos, size, thickness) |
---|
139 | { |
---|
140 | } |
---|
141 | |
---|
142 | public override void initRoom() |
---|
143 | { |
---|
144 | createLevelDecorations(); |
---|
145 | |
---|
146 | for (int y = 0; y < 3; y++) |
---|
147 | { |
---|
148 | for (int x = 0; x < 3; x++) |
---|
149 | { |
---|
150 | addBlock(new ObjectRock(blockWidth, blockHeight), x + 3, y + 1, new Vector(30, -20)); |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | deleteBlock(bWidth / 2 - 1, bHeight / 2); |
---|
155 | deleteBlock(bWidth / 2, bHeight / 2); |
---|
156 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
157 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | class RoomType6 : Room |
---|
162 | { |
---|
163 | public RoomType6(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
164 | : base(game, pos, size, thickness) |
---|
165 | { |
---|
166 | } |
---|
167 | |
---|
168 | public override void initRoom() |
---|
169 | { |
---|
170 | createLevelDecorations(); |
---|
171 | |
---|
172 | for (int i = 0; i < 5; i++) |
---|
173 | { |
---|
174 | int bx = RandomGen.NextInt(bWidth); |
---|
175 | int by = RandomGen.NextInt(bHeight); |
---|
176 | addBlock(new ObjectRock(blockWidth, blockHeight), bx, by); |
---|
177 | } |
---|
178 | |
---|
179 | spawnRandomEntities(RandomGen.NextInt(6) + 1); |
---|
180 | spawnRandomItems(RandomGen.NextInt(2)); |
---|
181 | } |
---|
182 | } |
---|
183 | |
---|
184 | class BossRoom : Room |
---|
185 | { |
---|
186 | public BossRoom(TheDungeonGame game, Vector pos, Vector size, double thickness) |
---|
187 | : base(game, pos, size, thickness) |
---|
188 | { |
---|
189 | roomName = "Boss Room"; |
---|
190 | } |
---|
191 | |
---|
192 | public override void initRoom() |
---|
193 | { |
---|
194 | createLevelDecorations(); |
---|
195 | |
---|
196 | addEntityAt(new EntityBossMario(Game, Vector.Zero, new Vector(30, 60), Shape.Rectangle), 3, 3); |
---|
197 | } |
---|
198 | } |
---|
199 | |
---|
200 | class RoomCreator |
---|
201 | { |
---|
202 | public static Room createRoom(TheDungeonGame game, Vector pos, Vector size, double thickness, int room) |
---|
203 | { |
---|
204 | Room result = null; |
---|
205 | if (room == 0) |
---|
206 | result = new EmptyRoom(game, pos, size, thickness); |
---|
207 | else if (room == 1) |
---|
208 | result = new RoomType1(game, pos, size, thickness); |
---|
209 | else if (room == 2) |
---|
210 | result = new RoomType2(game, pos, size, thickness); |
---|
211 | else if (room == 3) |
---|
212 | result = new RoomType3(game, pos, size, thickness); |
---|
213 | else if (room == 4) |
---|
214 | result = new RoomType4(game, pos, size, thickness); |
---|
215 | else if (room == 5) |
---|
216 | result = new RoomType5(game, pos, size, thickness); |
---|
217 | else if (room == 6) |
---|
218 | result = new RoomType6(game, pos, size, thickness); |
---|
219 | else if (room == 7) |
---|
220 | result = new BossRoom(game, pos, size, thickness); |
---|
221 | |
---|
222 | return result; |
---|
223 | } |
---|
224 | |
---|
225 | public static EntityBase getEntity(int id) |
---|
226 | { |
---|
227 | EntityBase ent = null; |
---|
228 | if (id == 0) |
---|
229 | ent = new EntityFly((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle); |
---|
230 | else if (id == 1) |
---|
231 | ent = new EntityZombie((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(60, 60), Shape.Rectangle); |
---|
232 | else if (id == 2) |
---|
233 | ent = new EntityDerpFace((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(60, 60), Shape.Circle); |
---|
234 | else if (id == 3) |
---|
235 | ent = new EntityDerpFly((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle); |
---|
236 | //else if(id == 4) |
---|
237 | // ent = new EntityDerpPistolZombie((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle); |
---|
238 | return ent; |
---|
239 | } |
---|
240 | |
---|
241 | public static Item getItem(int id) |
---|
242 | { |
---|
243 | Item item = null; |
---|
244 | if (id == 0) |
---|
245 | item = new ItemHealth(); |
---|
246 | else if (id == 1) |
---|
247 | item = new ItemAmmoDamage(); |
---|
248 | else if (id == 2) |
---|
249 | item = new ItemWeaponSpeed(); |
---|
250 | else if (id == 3) |
---|
251 | item = new ItemBulletLifeTime(); |
---|
252 | |
---|
253 | return item; |
---|
254 | } |
---|
255 | } |
---|
256 | } |
---|