Changeset 3562
- Timestamp:
- 2012-07-04 18:29:51 (11 years ago)
- Location:
- 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Player.cs
r3538 r3562 28 28 keyboard = game.Keyboard; 29 29 CanRotate = false; 30 currentRoom = game.LevelGen.getRoomAt(game.LevelGen.CenterRoom);31 30 setupKeys(); 32 31 } … … 51 50 { 52 51 room = game.LevelGen.getRoomAt(currentRoom.PosOnGrid + RoomDirection.getOffsetFromDir(RoomDirection.North)); 53 game.moveToRoom(room );52 game.moveToRoom(room, RoomDirection.North); 54 53 currentRoom = room; 55 54 }else … … 57 56 { 58 57 room = game.LevelGen.getRoomAt(currentRoom.PosOnGrid + RoomDirection.getOffsetFromDir(RoomDirection.East)); 59 game.moveToRoom(room );58 game.moveToRoom(room, RoomDirection.East); 60 59 currentRoom = room; 61 60 } … … 64 63 { 65 64 room = game.LevelGen.getRoomAt(currentRoom.PosOnGrid + RoomDirection.getOffsetFromDir(RoomDirection.South)); 66 game.moveToRoom(room );65 game.moveToRoom(room, RoomDirection.South); 67 66 currentRoom = room; 68 67 } … … 71 70 { 72 71 room = game.LevelGen.getRoomAt(currentRoom.PosOnGrid + RoomDirection.getOffsetFromDir(RoomDirection.West)); 73 game.moveToRoom(room );72 game.moveToRoom(room, RoomDirection.West); 74 73 currentRoom = room; 75 74 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs
r3547 r3562 17 17 private bool isBuilt = false; 18 18 protected IPhysicsObject[,] insideObjects; 19 protected IPhysicsObject[] doors = new IPhysicsObject[4];19 protected PhysicsObject[] doors = new PhysicsObject[4]; 20 20 protected double blockWidth, blockHeight; 21 21 protected double insideWidth, insideHeight; … … 155 155 } 156 156 157 public PhysicsObject getDoor(int dir) 158 { 159 PhysicsObject result = null; 160 for (int i = 0; i < doors.Length; i++ ) 161 { 162 PhysicsObject door = doors[i]; 163 if (door != null && (int)door.Tag == dir) 164 { 165 result = door; 166 return result; 167 } 168 169 } 170 return result; 171 } 172 157 173 public void createBorders() 158 174 { -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs
r3547 r3562 45 45 } 46 46 47 public void moveToRoom(Room room )47 public void moveToRoom(Room room, int dir) 48 48 { 49 49 currentPos = player.currentRoom.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 50 50 newPos = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 51 51 moveCameraTo(newPos - currentPos); 52 player.Position = generator.getRoomAt(room.PosOnGrid).Position + new Vector(ROOMWIDTH / 2, -ROOMHEIGHT / 2);52 player.Position = player.currentRoom.getDoor(dir).Position + RoomDirection.getOffsetFromWorldDir(dir) * 130; 53 53 } 54 54 … … 64 64 Camera.Velocity = cameraVelocity; 65 65 Vector remainingLenght = Camera.Position - newPos; 66 // Console.WriteLine(Math.Abs(remainingLenght.X)+", " + Math.Abs(remainingLenght.Y));67 66 if (Math.Abs((int)remainingLenght.X) < 20 && Math.Abs((int)remainingLenght.Y) < 20) 68 67 { … … 73 72 moveCamera = false; 74 73 } 75 76 74 } 77 75 78 76 private void setupPlayer() 79 77 { 80 player.Position = generator.getRoomAt((int)(generator.CenterRoom.X), (int)(generator.CenterRoom.Y)).Position + new Vector(ROOMWIDTH / 2, -ROOMHEIGHT / 2); 78 player.Position = generator.getRoomAt(generator.CenterRoom).Position + new Vector(ROOMWIDTH / 2, -ROOMHEIGHT / 2); 79 player.currentRoom = generator.getRoomAt(generator.CenterRoom); 81 80 Add(player, 1); 82 81 } … … 88 87 generator.generateRandomLevel(10, 15); 89 88 generator.buildDungeon(); 89 player.currentRoom = generator.getRoomAt(generator.CenterRoom); 90 90 } 91 91
Note: See TracChangeset
for help on using the changeset viewer.