source: 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/RoomTemplates.cs @ 3660

Revision 3660, 8.2 KB checked in by dezhidki, 11 years ago (diff)

Talletus.

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