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

Revision 3596, 6.3 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;
9
10namespace Rooms
11{
12    class EmptyRoom : Room
13    {
14        public EmptyRoom(TheDungeonGame game, Vector pos, Vector size, double thickness)
15            : base(game, pos, size, thickness)
16        {
17        }
18
19        public override void initRoom()
20        {
21            createLevelDecorations();
22        }
23    }
24
25    class RoomType1 : Room
26    {
27        public RoomType1(TheDungeonGame game, Vector pos, Vector size, double thickness)
28            : base(game, pos, size, thickness)
29        {
30        }
31
32        public override void initRoom()
33        {
34            createLevelDecorations();
35
36            addBlock(new ObjectRock(blockWidth, blockHeight), 0, 0);
37            addBlock(new ObjectRock(blockWidth, blockHeight), bWidth - 1, 0);
38            addBlock(new ObjectRock(blockWidth, blockHeight), 0, bHeight - 1, new Vector(0, -50));
39            addBlock(new ObjectRock(blockWidth, blockHeight), bWidth - 1, bHeight - 1, new Vector(0, -50));
40
41            spawnRandomEntities(5);
42        }
43    }
44
45    class RoomType2 : Room
46    {
47        public RoomType2(TheDungeonGame game, Vector pos, Vector size, double thickness)
48            : base(game, pos, size, thickness)
49        {
50        }
51
52        public override void initRoom()
53        {
54            createLevelDecorations();
55
56            for (int i = 0; i < 4; i++)
57            {
58                addBlock(new ObjectRock(blockWidth, blockHeight), 1, 1 + i, new Vector(0, -50));
59            }
60
61            for (int i = 0; i < 4; i++)
62            {
63                addBlock(new ObjectRock(blockWidth, blockHeight), 8, 1 + i, new Vector(0, -50));
64            }
65
66            spawnRandomEntities(5);
67        }
68    }
69
70    class RoomType3 : Room
71    {
72        public RoomType3(TheDungeonGame game, Vector pos, Vector size, double thickness)
73            : base(game, pos, size, thickness)
74        {
75        }
76
77        public override void initRoom()
78        {
79            createLevelDecorations();
80
81            for (int i = 0; i < 4; i++)
82            {
83                addBlock(new ObjectRock(blockWidth, blockHeight), i, 1);
84            }
85
86            for (int i = 0; i < 4; i++)
87            {
88                addBlock(new ObjectRock(blockWidth, blockHeight), i, 4);
89            }
90
91            for (int i = 0; i < 4; i++)
92            {
93                addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 1);
94            }
95
96            for (int i = 0; i < 4; i++)
97            {
98                addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 4);
99            }
100
101            spawnRandomEntities(5);
102        }
103    }
104
105    class RoomType4 : Room
106    {
107        public RoomType4(TheDungeonGame game, Vector pos, Vector size, double thickness)
108            : base(game, pos, size, thickness)
109        {
110        }
111
112        public override void initRoom()
113        {
114            createLevelDecorations();
115
116            for (int y = 1; y < bHeight; y++)
117            {
118                for (int x = 1; x < bWidth - 1; x++)
119                {
120                    if (x % 2 != 0 && y % 2 != 0)
121                        addBlock(new ObjectRock(blockWidth, blockHeight), x, y, new Vector(40, 0));
122                }
123            }
124
125            spawnRandomEntities(5);
126        }
127    }
128
129    class RoomType5 : Room
130    {
131        public RoomType5(TheDungeonGame game, Vector pos, Vector size, double thickness)
132            : base(game, pos, size, thickness)
133        {
134        }
135
136        public override void initRoom()
137        {
138            createLevelDecorations();
139
140            for (int y = 0; y < 3; y++)
141            {
142                for (int x = 0; x < 3; x++)
143                {
144                    addBlock(new ObjectRock(blockWidth, blockHeight), x + 3, y + 1, new Vector(30, -20));
145                }
146            }
147
148            deleteBlock(bWidth / 2 - 1, bHeight / 2);
149            spawnRandomEntities(5);
150        }
151    }
152
153    class RoomType6 : Room
154    {
155        public RoomType6(TheDungeonGame game, Vector pos, Vector size, double thickness)
156            : base(game, pos, size, thickness)
157        {
158        }
159
160        public override void initRoom()
161        {
162            createLevelDecorations();
163
164            for (int i = 0; i < 5; i++)
165            {
166                int bx = RandomGen.NextInt(bWidth);
167                int by = RandomGen.NextInt(bHeight);
168                addBlock(new ObjectRock(blockWidth, blockHeight), bx, by);
169            }
170
171            spawnRandomEntities(5);
172        }
173    }
174
175    class BossRoom : Room
176    {
177        public BossRoom(TheDungeonGame game, Vector pos, Vector size, double thickness)
178            : base(game, pos, size, thickness)
179        {
180        }
181
182        public override void initRoom()
183        {
184            createLevelDecorations();
185        }
186    }
187
188    class RoomCreator
189    {
190        public static Room createRoom(TheDungeonGame game, Vector pos, Vector size, double thickness, int room)
191        {
192            Room result = null;
193            if (room == 0)
194                result = new EmptyRoom(game, pos, size, thickness);
195            else if (room == 1)
196                result = new RoomType1(game, pos, size, thickness);
197            else if (room == 2)
198                result = new RoomType2(game, pos, size, thickness);
199            else if (room == 3)
200                result = new RoomType3(game, pos, size, thickness);
201            else if (room == 4)
202                result = new RoomType4(game, pos, size, thickness);
203            else if (room == 5)
204                result = new RoomType5(game, pos, size, thickness);
205            else if (room == 6)
206                result = new RoomType6(game, pos, size, thickness);
207            else if (room == 7)
208                result = new BossRoom(game, pos, size, thickness);
209
210            return result;
211        }
212
213        public static EntityBase getEntity(int id)
214        {
215            EntityBase ent = null;
216            if (id == 0)
217                ent = new EntityFly((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle);
218            return ent;
219        }
220    }
221}
Note: See TracBrowser for help on using the repository browser.