- Timestamp:
- 2012-07-05 11:22:43 (11 years ago)
- Location:
- 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs
r3570 r3572 16 16 protected List<IPhysicsObject> roomDecorations = new List<IPhysicsObject>(); 17 17 protected List<IPhysicsObject> roomObjects = new List<IPhysicsObject>(); 18 p rivatebool isBuilt = false;18 public bool isBuilt = false; 19 19 protected IPhysicsObject[,] insideObjects; 20 20 protected PhysicsObject[] doors = new PhysicsObject[4]; … … 98 98 if (obj != null) 99 99 obj.Destroy(); 100 } 101 } 102 103 public void hideLevel() 104 { 105 if (roomDecorations.Count == 0) throw new Exception("Cannot hide empty room!"); 106 if (!isBuilt) return; 107 108 foreach (IPhysicsObject obj in roomDecorations) 109 { 110 obj.IsVisible = false; 111 } 112 foreach (IPhysicsObject obj in roomObjects) 113 { 114 obj.IsVisible = false; 115 } 116 foreach (IPhysicsObject obj in insideObjects) 117 { 118 if (obj != null) 119 obj.IsVisible = false; 120 } 121 } 122 123 public void restoreLevel() 124 { 125 if (roomDecorations.Count == 0) throw new Exception("Cannot hide empty room!"); 126 if (!isBuilt) return; 127 128 foreach (IPhysicsObject obj in roomDecorations) 129 { 130 obj.IsVisible = true; 131 } 132 foreach (IPhysicsObject obj in roomObjects) 133 { 134 obj.IsVisible = true; 135 } 136 foreach (IPhysicsObject obj in insideObjects) 137 { 138 if (obj != null) 139 obj.IsVisible = true; 100 140 } 101 141 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs
r3570 r3572 46 46 generator.generateRandomLevel(5, 10); 47 47 generator.initDungeon(); 48 // generator.buildDungeon();49 48 Room centerRoom = generator.getRoomAt((int)(generator.CenterRoom.X), (int)(generator.CenterRoom.Y)); 50 49 Camera.Position = centerRoom.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 51 //Camera.ZoomToLevel();52 //Camera.Zoom(0.5);53 50 54 51 player = new Player(this, Vector.Zero, playerPic); … … 101 98 newPos = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 102 99 oldRoom = player.currentRoom; 103 room.buildLevel(); 100 if (room.isBuilt) room.restoreLevel(); 101 else room.buildLevel(); 104 102 moveCameraTo(newPos - oldPos); 105 103 player.Position = player.currentRoom.getDoor(dir).Position + RoomDirection.getOffsetFromWorldDir(dir) * 130; … … 124 122 Camera.Position = newPos; 125 123 moveCamera = false; 126 oldRoom. destroyLevel();124 oldRoom.hideLevel(); 127 125 } 128 126 }
Note: See TracChangeset
for help on using the changeset viewer.