- Timestamp:
- 2012-07-05 10:46:03 (11 years ago)
- Location:
- 2012/27/DenisZ/TheDungeonGame/TheDungeonGame
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/EntityTemplates.cs
r3549 r3568 4 4 using System.Text; 5 5 using Jypeli; 6 using Jypeli.Assets; 6 7 7 8 namespace Entity … … 19 20 } 20 21 } 22 23 public class EntityFly : EntityBase 24 { 25 public EntityFly(TheDungeonGame game, Vector pos, Vector size, Shape shape) 26 : base(game, pos, size, shape) 27 { 28 } 29 30 public override void init() 31 { 32 Brain = new FollowerBrain(game.Player,200); 33 Brain.Active = true; 34 } 35 } 21 36 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/LevelGenerator.cs
r3563 r3568 47 47 } 48 48 49 public void initDungeon() 50 { 51 foreach (Room room in roomList) 52 { 53 room.initRoom(); 54 } 55 } 56 49 57 public void buildDungeon() 50 58 { 51 59 foreach (Room room in roomList) 52 60 { 53 room.initRoom();54 61 room.buildLevel(); 55 62 } … … 73 80 if (room == 0) 74 81 { 75 lastRoom = new TestRoom(game, VecMath.mul(CenterRoom, new Vector(TheDungeonGame.ROOMWIDTH + TheDungeonGame.ROOMTHICKNESS, -TheDungeonGame.ROOMHEIGHT - TheDungeonGame.ROOMTHICKNESS)), TheDungeonGame.roomSize, TheDungeonGame.ROOMTHICKNESS);82 lastRoom = new EmptyRoom(game, VecMath.mul(CenterRoom, new Vector(TheDungeonGame.ROOMWIDTH + TheDungeonGame.ROOMTHICKNESS, -TheDungeonGame.ROOMHEIGHT - TheDungeonGame.ROOMTHICKNESS)), TheDungeonGame.roomSize, TheDungeonGame.ROOMTHICKNESS); 76 83 placeRoomAt(lastRoom, (int)CenterRoom.X, (int)CenterRoom.Y); 77 84 continue; … … 113 120 { 114 121 if (getRoomFromDirection(lastRoom, dir) != null) return false; 115 currentRoom = new TestRoom(game, VecMath.mul(pos, new Vector(TheDungeonGame.ROOMWIDTH + TheDungeonGame.ROOMTHICKNESS, -TheDungeonGame.ROOMHEIGHT - TheDungeonGame.ROOMTHICKNESS)), TheDungeonGame.roomSize, TheDungeonGame.ROOMTHICKNESS); 122 currentRoom = RoomCreator.createRoom(game, VecMath.mul(pos, new Vector(TheDungeonGame.ROOMWIDTH + TheDungeonGame.ROOMTHICKNESS, -TheDungeonGame.ROOMHEIGHT - TheDungeonGame.ROOMTHICKNESS)), TheDungeonGame.roomSize, TheDungeonGame.ROOMTHICKNESS, RandomGen.NextInt(6)+1); 123 //currentRoom = new EmptyRoom(game, VecMath.mul(pos, new Vector(TheDungeonGame.ROOMWIDTH + TheDungeonGame.ROOMTHICKNESS, -TheDungeonGame.ROOMHEIGHT - TheDungeonGame.ROOMTHICKNESS)), TheDungeonGame.roomSize, TheDungeonGame.ROOMTHICKNESS); 116 124 return placeRoomAt(currentRoom, (int)pos.X, (int)pos.Y); 117 125 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs
r3563 r3568 49 49 public abstract void initRoom(); 50 50 51 protected void createLevelDecorations() 52 { 53 int level = Game.LevelGen.level; 54 createBorders(Game.getTopBottomWall(level), Game.getLeftRightWall(level)); 55 addDoors(Game.objectTextures[0]); 56 roomDecorations.Add(createBackground(Game.getLevelBackground(level))); 57 } 58 51 59 public void buildLevel() 52 60 { … … 95 103 public void addBlock(IPhysicsObject obj, int bx, int by) 96 104 { 97 if (bx >= bWidth || bx < 0 || by >= bHeight || by < 0 || insideObjects[bx, by] != null) throw new Exception("Can't put block to " + bx + " , " + by);105 if (bx >= bWidth || bx < 0 || by >= bHeight || by < 0) throw new Exception("Can't put block to " + bx + " , " + by); 98 106 obj.Left = insidePos.X + (bx * blockWidth); 99 107 obj.Top = insidePos.Y - (by * blockHeight); 100 108 insideObjects[bx, by] = obj; 109 } 110 111 public void addBlock(IPhysicsObject obj, int bx, int by, Vector offset) 112 { 113 addBlock(obj, bx, by); 114 obj.Position += offset; 101 115 } 102 116 … … 115 129 ent.Top = insidePos.Y + (by * blockHeight); 116 130 insideObjects[bx, by] = ent; 131 } 132 133 public void deleteBlock(int bx, int by) 134 { 135 insideObjects[bx, by].Destroy(); 136 insideObjects[bx, by] = null; 117 137 } 118 138 -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/RoomTemplates.cs
r3563 r3568 10 10 namespace Rooms 11 11 { 12 class TestRoom : Room12 class EmptyRoom : Room 13 13 { 14 public TestRoom(TheDungeonGame game, Vector pos, Vector size, double thickness)14 public EmptyRoom(TheDungeonGame game, Vector pos, Vector size, double thickness) 15 15 : base(game, pos, size, thickness) 16 16 { … … 19 19 public override void initRoom() 20 20 { 21 int level = Game.LevelGen.level; 22 createBorders(Game.getTopBottomWall(level), Game.getLeftRightWall(level)); 23 addDoors(Game.objectTextures[0]); 24 roomDecorations.Add(createBackground(Game.getLevelBackground(level))); 25 ItemEntity testItem = new ItemEntity(new Items.TestItem(TheDungeonGame.LoadImage("items/testItem"), "Test Item", true)); 26 addBlock(testItem, 0, 0); 27 //TestEntity entity = new TestEntity(Game, Vector.Zero, new Vector(40, 40), Shape.Rectangle); 28 //addEntityAt(entity, 0, 0); 29 //RandomMoverBrain brain = new RandomMoverBrain(10000); 30 //brain.ChangeMovementSeconds = 0.5; 31 //entity.Brain = brain; 32 //entity.Brain.Active = true; 21 createLevelDecorations(); 33 22 } 34 23 } 35 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 } 42 43 class RoomType2 : Room 44 { 45 public RoomType2(TheDungeonGame game, Vector pos, Vector size, double thickness) 46 : base(game, pos, size, thickness) 47 { 48 } 49 50 public override void initRoom() 51 { 52 createLevelDecorations(); 53 54 for (int i = 0; i < 4; i++) 55 { 56 addBlock(new ObjectRock(blockWidth, blockHeight), 1, 1 + i, new Vector(0, -50)); 57 } 58 59 for (int i = 0; i < 4; i++) 60 { 61 addBlock(new ObjectRock(blockWidth, blockHeight), 8, 1 + i, new Vector(0, -50)); 62 } 63 } 64 } 65 66 class RoomType3 : Room 67 { 68 public RoomType3(TheDungeonGame game, Vector pos, Vector size, double thickness) 69 : base(game, pos, size, thickness) 70 { 71 } 72 73 public override void initRoom() 74 { 75 createLevelDecorations(); 76 77 for (int i = 0; i < 4; i++) 78 { 79 addBlock(new ObjectRock(blockWidth, blockHeight), i, 1); 80 } 81 82 for (int i = 0; i < 4; i++) 83 { 84 addBlock(new ObjectRock(blockWidth, blockHeight), i, 4); 85 } 86 87 for (int i = 0; i < 4; i++) 88 { 89 addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 1); 90 } 91 92 for (int i = 0; i < 4; i++) 93 { 94 addBlock(new ObjectRock(blockWidth, blockHeight), i + 6, 4); 95 } 96 } 97 } 98 99 class RoomType4 : Room 100 { 101 public RoomType4(TheDungeonGame game, Vector pos, Vector size, double thickness) 102 : base(game, pos, size, thickness) 103 { 104 } 105 106 public override void initRoom() 107 { 108 createLevelDecorations(); 109 110 for (int y = 1; y < bHeight; y++) 111 { 112 for (int x = 1; x < bWidth - 1; x++) 113 { 114 if (x % 2 != 0 && y % 2 != 0) 115 addBlock(new ObjectRock(blockWidth, blockHeight), x, y, new Vector(40, 0)); 116 } 117 } 118 } 119 } 120 121 class RoomType5 : Room 122 { 123 public RoomType5(TheDungeonGame game, Vector pos, Vector size, double thickness) 124 : base(game, pos, size, thickness) 125 { 126 } 127 128 public override void initRoom() 129 { 130 createLevelDecorations(); 131 132 for (int y = 0; y < 3; y++) 133 { 134 for (int x = 0; x < 3; x++) 135 { 136 addBlock(new ObjectRock(blockWidth, blockHeight), x + 3, y + 1, new Vector(30, -20)); 137 } 138 } 139 140 deleteBlock(bWidth / 2 - 1, bHeight / 2); 141 } 142 } 143 144 class RoomType6 : Room 145 { 146 public RoomType6(TheDungeonGame game, Vector pos, Vector size, double thickness) 147 : base(game, pos, size, thickness) 148 { 149 } 150 151 public override void initRoom() 152 { 153 createLevelDecorations(); 154 155 for (int i = 0; i < 5; i++) 156 { 157 int bx = RandomGen.NextInt(bWidth); 158 int by = RandomGen.NextInt(bHeight); 159 addBlock(new ObjectRock(blockWidth, blockHeight), bx, by); 160 } 161 } 162 } 163 164 class RoomCreator 165 { 166 public static Room createRoom(TheDungeonGame game, Vector pos, Vector size, double thickness, int room) 167 { 168 Room result = null; 169 if (room == 0) 170 result = new EmptyRoom(game, pos, size, thickness); 171 else if (room == 1) 172 result = new RoomType1(game, pos, size, thickness); 173 else if (room == 2) 174 result = new RoomType2(game, pos, size, thickness); 175 else if (room == 3) 176 result = new RoomType3(game, pos, size, thickness); 177 else if (room == 4) 178 result = new RoomType4(game, pos, size, thickness); 179 else if (room == 5) 180 result = new RoomType5(game, pos, size, thickness); 181 else if (room == 6) 182 result = new RoomType6(game, pos, size, thickness); 183 184 return result; 185 } 186 } 36 187 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs
r3563 r3568 46 46 generator = new LevelGenerator(this, Level.Size, new Vector(20, 20)); 47 47 generator.generateRandomLevel(5, 10); 48 generator.initDungeon(); 48 49 generator.buildDungeon(); 49 50 Room centerRoom = generator.getRoomAt((int)(generator.CenterRoom.X), (int)(generator.CenterRoom.Y)); … … 128 129 player.Position = generator.getRoomAt(generator.CenterRoom).Position + new Vector(ROOMWIDTH / 2, -ROOMHEIGHT / 2); 129 130 player.currentRoom = generator.getRoomAt(generator.CenterRoom); 130 Add(player, 1);131 Add(player, 2); 131 132 } 132 133 … … 136 137 generator = new LevelGenerator(this, Level.Size, new Vector(20, 20)); 137 138 generator.generateRandomLevel(10, 15); 139 generator.initDungeon(); 138 140 generator.buildDungeon(); 139 141 player.currentRoom = generator.getRoomAt(generator.CenterRoom); -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.csproj
r3563 r3568 113 113 </ItemGroup> 114 114 <ItemGroup> 115 <Compile Include="CollisionGroups.cs" /> 115 116 <Compile Include="Entity.cs" /> 116 117 <Compile Include="EntityTemplates.cs" /> … … 119 120 <Compile Include="ItemEntity.cs" /> 120 121 <Compile Include="LevelGenerator.cs" /> 122 <Compile Include="ObjectRock.cs" /> 121 123 <Compile Include="Room.cs" /> 122 124 <Compile Include="Player.cs" /> -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGameContent/TheDungeonGameContent.contentproj
r3563 r3568 91 91 </Compile> 92 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="objects\rock.png"> 95 <Name>rock</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 93 100 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 94 101 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.