public LevelEditor(SpriteFont _arial32, SpriteFont _arial16, Texture2D _whiteTexture) { arial32 = _arial32; arial14 = _arial16; whiteTexture = _whiteTexture; CameraManager.SwitchCamera((RoomsManager.Rooms)currentRoomNumber, 0); }
//Half the size of the portion of game world framed in the camera. //Equivalent to zooming in. public static void Zoom1() { gameWidth = minViewportWidth; gameHeight = minViewportHeight; nativeRenderTarget = renderTarget_zoom1; CameraManager.SwitchCamera(RoomsManager.CurrentRoom); }
//Double the size of the portion of game world framed in the camera. //Equivalent to zooming out. public static void Zoom0Dot5() { gameWidth = minViewportWidth * 2; gameHeight = minViewportHeight * 2; nativeRenderTarget = renderTarger_zoom0dot5; CameraManager.SwitchCamera(RoomsManager.CurrentRoom); }
//state machine managing the movement between rooms static bool switchRoom() { switch (currentRoom) { case Rooms.tutorial0: if (Player.position.X > MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to tutorial1 currentRoom = Rooms.tutorial1; previousRoom = Rooms.tutorial0; CameraManager.SwitchCamera(Rooms.tutorial1); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to tutorial4 currentRoom = Rooms.tutorial4; previousRoom = Rooms.tutorial0; CameraManager.SwitchCamera(Rooms.tutorial4); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.tutorial1: if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to tutorial2 currentRoom = Rooms.tutorial2; previousRoom = Rooms.tutorial1; CameraManager.SwitchCamera(Rooms.tutorial2); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X + Player.width < 0) {//move to tutorial0 currentRoom = Rooms.tutorial0; previousRoom = Rooms.tutorial1; CameraManager.SwitchCamera(Rooms.tutorial0); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X > MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to tutorial3 currentRoom = Rooms.tutorial3; previousRoom = Rooms.tutorial1; CameraManager.SwitchCamera(Rooms.tutorial3); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.tutorial2: if (Player.position.Y+Player.height<0) { if (Player.position.X>= MapsManager.maps[(int)Rooms.tutorial1].RoomWidthtPx) {//move to tutorial3 currentRoom = Rooms.tutorial3; previousRoom = Rooms.tutorial2; CameraManager.SwitchCamera(Rooms.tutorial3); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx-Player.height; Player.position.X -= MapsManager.maps[(int)Rooms.tutorial1].RoomWidthtPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else {//move to tutorial1 currentRoom = Rooms.tutorial1; previousRoom = Rooms.tutorial2; CameraManager.SwitchCamera(Rooms.tutorial1); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } } else if (Player.position.X+Player.width<0) {//moveto tutorial4 currentRoom = Rooms.tutorial4; previousRoom = Rooms.tutorial2; CameraManager.SwitchCamera(Rooms.tutorial4); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.tutorial3: if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to tutorial2 currentRoom = Rooms.tutorial2; previousRoom = Rooms.tutorial3; CameraManager.SwitchCamera(Rooms.tutorial2); Player.position.X += MapsManager.maps[(int)Rooms.tutorial1].RoomWidthtPx; Player.position.Y = -10; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X<0) {//move to tutorial1 currentRoom = Rooms.tutorial1; previousRoom = Rooms.tutorial3; CameraManager.SwitchCamera(Rooms.tutorial1); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx-Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X> MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to churchBellTower0 currentRoom = Rooms.churchBellTower0; previousRoom = Rooms.tutorial3; CameraManager.SwitchCamera(Rooms.churchBellTower0); Player.position.X = 0; Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx- MapsManager.maps[(int)Rooms.tutorial3].RoomHeightPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.tutorial4: if (Player.position.X > MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to tutorial2 currentRoom = Rooms.tutorial2; previousRoom = Rooms.tutorial4; CameraManager.SwitchCamera(Rooms.tutorial2); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y+Player.height<0) {//move to tutorial0 currentRoom = Rooms.tutorial0; previousRoom = Rooms.tutorial4; CameraManager.SwitchCamera(Rooms.tutorial0); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx-Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to escape2 currentRoom = Rooms.escape2; previousRoom = Rooms.tutorial4; CameraManager.SwitchCamera(Rooms.escape2); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.churchBellTower0: if (Player.position.X+Player.width<0) {//move to tutorial3 currentRoom = Rooms.tutorial3; previousRoom = Rooms.churchBellTower0; CameraManager.SwitchCamera(Rooms.tutorial3); Player.position.X= MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx - MapsManager.maps[(int)Rooms.churchBellTower0].RoomHeightPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y+Player.height<0) {//move up to churchBellTower1 currentRoom = Rooms.churchBellTower1; previousRoom = Rooms.churchBellTower0; CameraManager.SwitchCamera(Rooms.churchBellTower1); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X> MapsManager.maps[(int)currentRoom].RoomWidthtPx) { if (Player.position.Y> 496) {//move to churchGroundFloor0 currentRoom = Rooms.churchGroundFloor0; previousRoom = Rooms.churchBellTower0; CameraManager.SwitchCamera(Rooms.churchGroundFloor0); Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx - MapsManager.maps[(int)Rooms.churchBellTower0].RoomHeightPx; Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y>248) {//church1stFloor0 currentRoom = Rooms.church1stFloor0; previousRoom = Rooms.churchBellTower0; CameraManager.SwitchCamera(Rooms.church1stFloor0); Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx + MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomHeightPx - MapsManager.maps[(int)Rooms.churchBellTower0].RoomHeightPx; Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else {//church2ndFloor0 currentRoom = Rooms.church2ndFloor0; previousRoom = Rooms.churchBellTower0; CameraManager.SwitchCamera(Rooms.church2ndFloor0); Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx + MapsManager.maps[(int)Rooms.church1stFloor0].RoomHeightPx + MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomHeightPx - MapsManager.maps[(int)Rooms.churchBellTower0].RoomHeightPx; Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } } break; case Rooms.churchBellTower1: if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move down to chirchBellTower0 currentRoom = Rooms.churchBellTower0; previousRoom = Rooms.churchBellTower1; CameraManager.SwitchCamera(Rooms.churchBellTower0); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y + Player.height < 0) {//move up to chirchBellTower2 currentRoom = Rooms.churchBellTower2; previousRoom = Rooms.churchBellTower1; CameraManager.SwitchCamera(Rooms.churchBellTower2); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.churchBellTower2: if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move down to chirchBellTower1 currentRoom = Rooms.churchBellTower1; previousRoom = Rooms.churchBellTower2; CameraManager.SwitchCamera(Rooms.churchBellTower1); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y + Player.height < 0) {//move up to midBoss currentRoom = Rooms.midBoss; previousRoom = Rooms.churchBellTower2; CameraManager.SwitchCamera(Rooms.midBoss); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.midBoss: if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move down to chirchBellTower1 currentRoom = Rooms.churchBellTower2; previousRoom = Rooms.midBoss; CameraManager.SwitchCamera(Rooms.churchBellTower2); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.churchGroundFloor0: if (Player.position.X+Player.width<0) {//move to churchBellTower0 currentRoom = Rooms.churchBellTower0; previousRoom = Rooms.churchGroundFloor0; CameraManager.SwitchCamera(Rooms.churchBellTower0); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx - MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomHeightPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X> MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to churchAltarRoom currentRoom = Rooms.churchAltarRoom; previousRoom = Rooms.churchGroundFloor0; CameraManager.SwitchCamera(Rooms.churchAltarRoom); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.churchAltarRoom: if (Player.position.X+Player.width<0) {//move to churchGroundFloor0 currentRoom = Rooms.churchGroundFloor0; previousRoom = Rooms.churchAltarRoom; CameraManager.SwitchCamera(Rooms.churchGroundFloor0); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y+Player.height<0) {//move to church1stFloor0 currentRoom = Rooms.church1stFloor0; previousRoom = Rooms.churchAltarRoom; CameraManager.SwitchCamera(Rooms.church1stFloor0); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; Player.position.X += MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomWidthtPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to descent currentRoom = Rooms.descent; previousRoom = Rooms.churchAltarRoom; CameraManager.SwitchCamera(Rooms.descent); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.church1stFloor0: if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to churchAltarRoom currentRoom = Rooms.churchAltarRoom; previousRoom = Rooms.church1stFloor0; CameraManager.SwitchCamera(Rooms.churchAltarRoom); Player.position.Y = 0; Player.position.X -= MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomWidthtPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y +Player.height <0) {//move to church2ndFloor0 currentRoom = Rooms.church2ndFloor0; previousRoom = Rooms.church1stFloor0; CameraManager.SwitchCamera(Rooms.church2ndFloor0); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X+Player.width<0) {//move to churchBellTower0 currentRoom = Rooms.churchBellTower0; previousRoom = Rooms.church1stFloor0; CameraManager.SwitchCamera(Rooms.churchBellTower0); Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx - MapsManager.maps[(int)Rooms.church1stFloor0].RoomHeightPx - MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomHeightPx; Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx-Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.church2ndFloor0: if (Player.position.X+Player.width<0) {//move to churchBellTower0 currentRoom = Rooms.churchBellTower0; previousRoom = Rooms.church2ndFloor0; CameraManager.SwitchCamera(Rooms.churchBellTower0); Player.position.Y += MapsManager.maps[(int)currentRoom].RoomHeightPx - MapsManager.maps[(int)Rooms.church1stFloor0].RoomHeightPx - MapsManager.maps[(int)Rooms.churchGroundFloor0].RoomHeightPx -MapsManager.maps[(int)Rooms.church2ndFloor0].RoomHeightPx; Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to church1stFloor0 currentRoom = Rooms.church1stFloor0; previousRoom = Rooms.church2ndFloor0; CameraManager.SwitchCamera(Rooms.church1stFloor0); Player.position.Y = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.descent: if (Player.position.Y+Player.height<0) {//move to churchAltarRoom currentRoom = Rooms.churchAltarRoom; previousRoom = Rooms.descent; CameraManager.SwitchCamera(Rooms.churchAltarRoom); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx-Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) {//move to finalBoss currentRoom = Rooms.finalBoss; previousRoom = Rooms.descent; Game1.Zoom0Dot5(); CameraManager.SwitchCamera(Rooms.finalBoss); Player.position.Y = 0; Player.position.X += MapsManager.maps[(int)currentRoom].RoomWidthtPx - MapsManager.maps[(int)Rooms.descent].RoomWidthtPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } break; case Rooms.finalBoss: if (Player.position.X+Player.width<0) {//move to escape0 currentRoom = Rooms.escape0; previousRoom = Rooms.finalBoss; Game1.Zoom1(); CameraManager.SwitchCamera(Rooms.escape0); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx-Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if(Player.position.Y+Player.height<0) {//move to descent currentRoom = Rooms.descent; previousRoom = Rooms.finalBoss; Game1.Zoom1(); CameraManager.SwitchCamera(Rooms.descent); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx - Player.height; Player.position.X += MapsManager.maps[(int)currentRoom].RoomWidthtPx - MapsManager.maps[(int)Rooms.finalBoss].RoomWidthtPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y> MapsManager.maps[(int)currentRoom].RoomHeightPx) { Player.takeDamage(Player.maxHealthPoints, true); } break; case Rooms.escape0: if (Player.position.X > MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to finalBoss currentRoom = Rooms.finalBoss; previousRoom = Rooms.escape0; Game1.Zoom0Dot5(); CameraManager.SwitchCamera(Rooms.finalBoss); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X + Player.width<0) {//move to escape1 currentRoom = Rooms.escape1; previousRoom = Rooms.escape0; CameraManager.SwitchCamera(Rooms.escape1); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; Player.position.Y += MapsManager.maps[(int)Rooms.descent].RoomHeightPx - MapsManager.maps[(int)Rooms.tutorial2].RoomHeightPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx + 24) { Player.takeDamage(Player.maxHealthPoints, true); } break; case Rooms.escape1: if (Player.position.X> MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to escape0 currentRoom = Rooms.escape0; previousRoom = Rooms.escape1; CameraManager.SwitchCamera(Rooms.escape0); Player.position.X = 0; Player.position.Y-= MapsManager.maps[(int)Rooms.descent].RoomHeightPx - MapsManager.maps[(int)Rooms.tutorial2].RoomHeightPx; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.X+Player.width<0) {//move to escape2 currentRoom = Rooms.escape2; previousRoom = Rooms.escape1; CameraManager.SwitchCamera(Rooms.escape2); Player.position.X = MapsManager.maps[(int)currentRoom].RoomWidthtPx - Player.width; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx + 24) { Player.takeDamage(Player.maxHealthPoints, true); } break; case Rooms.escape2: if (Player.position.X> MapsManager.maps[(int)currentRoom].RoomWidthtPx) {//move to escape1 currentRoom = Rooms.escape1; previousRoom = Rooms.escape2; CameraManager.SwitchCamera(Rooms.escape1); Player.position.X = 0; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if(Player.position.Y+Player.height<0) {//move to tutorial4 currentRoom = Rooms.tutorial4; previousRoom = Rooms.escape2; CameraManager.SwitchCamera(Rooms.tutorial4); Player.position.Y = MapsManager.maps[(int)currentRoom].RoomHeightPx-Player.height; FireBallsManager.Reset(); LavaGeyserManager.Reset(); ProjectilesManager.Reset(); return true; } else if (Player.position.Y > MapsManager.maps[(int)currentRoom].RoomHeightPx + 24) { Player.takeDamage(Player.maxHealthPoints, true); } break; } return false; }
public static void Inizialize() { currentRoom = Rooms.tutorial0; previousRoom = Rooms.tutorial0; CameraManager.SwitchCamera(currentRoom); }
//state machine that allows to traverse the menus void MenuLoop(MouseState mouseState, MouseState previousMouseState, int tilesPerRow, int infoBoxHeighPx) { switch (menu) { case MenuState.start: if (Game1.currentKeyboard.IsKeyDown(Keys.Enter)) { menu = MenuState.none; message = ""; } break; case MenuState.none: if (Game1.currentKeyboard.IsKeyDown(Keys.M)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } break; case MenuState.main: if (Game1.currentKeyboard.IsKeyDown(Keys.R)) { menu = MenuState.rooms; message = "Press:\nA-Change room\nB-Change room size"; } else if (Game1.currentKeyboard.IsKeyDown(Keys.T)) { menu = MenuState.tiles; message = "Press:\nA-Change tile type\nB-Random tile mode"; } else if (Game1.currentKeyboard.IsKeyDown(Keys.V)) { menu = MenuState.view; message = "Press:\nA-Highlight solid tiles\nB-Highlight deadly tiles"; } else if (Game1.currentKeyboard.IsKeyDown(Keys.S)) { menu = MenuState.none; message = ""; saveMaps(); } else if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.none; message = ""; } break; case MenuState.rooms: if (Game1.currentKeyboard.IsKeyDown(Keys.A)) { menu = MenuState.pickRoom; message = "Room index: "; userInputInt = 0; } else if (Game1.currentKeyboard.IsKeyDown(Keys.B)) { menu = MenuState.pickRoomSize; message = "Room size in tiles (format: width,height): "; userInputString = ""; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } break; case MenuState.tiles: if (Game1.currentKeyboard.IsKeyDown(Keys.A)) { menu = MenuState.pickTileIndex; message = "Tile index: "; userInputInt = 0; } else if (Game1.currentKeyboard.IsKeyDown(Keys.B)) { menu = MenuState.selectRandomTiles; message = "Enter the indexes of the tiles you want to\nrandomly select from (format: index1,index2...)\n" + "You can also click the tiles displayed on the right.\nIndexes: "; userInputString = ""; randomTiles.Clear(); } else if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } break; case MenuState.view: if (Game1.currentKeyboard.IsKeyDown(Keys.A)) { menu = MenuState.none; message = ""; solidView = !solidView; } else if (Game1.currentKeyboard.IsKeyDown(Keys.B)) { menu = MenuState.none; message = ""; deadlyView = !deadlyView; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } break; case MenuState.pickRoom: if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } else if (GetIntInput()) { message = "Room index: " + userInputInt; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter)) { currentRoomNumber = userInputInt < (int)RoomsManager.Rooms.total ? userInputInt : ((int)RoomsManager.Rooms.total - 1); CameraManager.SwitchCamera((RoomsManager.Rooms)currentRoomNumber, 0); CameraManager.pointLocked = new Vector2(0, 0); userInputInt = 0; menu = MenuState.none; message = ""; } break; case MenuState.pickRoomSize: if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } else if (GetStringInput()) { message = "Room size in tiles (format: width,height): " + userInputString; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter)) { string[] arr = userInputString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length != 2) { break; } widthTiles = int.Parse(arr[0]); widthTiles = MathHelper.Clamp( widthTiles, (Game1.gameWidth + (int)(Tile.tileSize) - 1) / (int)(Tile.tileSize), 500); heightTiles = int.Parse(arr[1]); heightTiles = MathHelper.Clamp( heightTiles, (Game1.gameHeight + 2 * CameraManager.maxOffsetY + (int)(Tile.tileSize) - 1) / (int)(Tile.tileSize), 500); menu = MenuState.pickResizingDirection; userInputString = "U,R"; message = "Use the arrows to select\nthe edges (top/bottom and left/right)\n" + "to shift to resize the room.\n" + userInputString; } break; case MenuState.pickResizingDirection: if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; userInputString = ""; heightTiles = 0; widthTiles = 0; } else if (getDirectionalInput()) { message = "Use the arrows to select\nthe edges (top/bottom and left/right)\n" + "to shift to resize the room.\n" + userInputString; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter) && !Game1.previousKeyboard.IsKeyDown(Keys.Enter)) { RoomMap newMap = new RoomMap(heightTiles, widthTiles); int oldHeightTiles = MapsManager.maps[currentRoomNumber].roomHeightTiles; int oldWidthTiles = MapsManager.maps[currentRoomNumber].roomWidthTiles; for (int row = 0; row < Math.Min(oldHeightTiles, heightTiles); row++) { for (int col = 0; col < Math.Min(oldWidthTiles, widthTiles); col++) { if (userInputString == "D,R") { newMap.array[row, col].tileType = MapsManager.maps[currentRoomNumber].array[row, col].tileType; } else if (userInputString == "U,R") { newMap.array[heightTiles - 1 - row, col].tileType = MapsManager.maps[currentRoomNumber].array[oldHeightTiles - 1 - row, col].tileType; } else if (userInputString == "D,L") { newMap.array[row, widthTiles - 1 - col].tileType = MapsManager.maps[currentRoomNumber].array[row, oldWidthTiles - 1 - col].tileType; } else if (userInputString == "U,L") { newMap.array[heightTiles - 1 - row, widthTiles - 1 - col].tileType = MapsManager.maps[currentRoomNumber].array[oldHeightTiles - 1 - row, oldWidthTiles - 1 - col].tileType; } } } MapsManager.maps[currentRoomNumber] = newMap; CameraManager.SwitchCamera((RoomsManager.Rooms)currentRoomNumber, 0); menu = MenuState.none; message = ""; userInputString = ""; heightTiles = 0; widthTiles = 0; } break; case MenuState.pickTileIndex: if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } else if (GetIntInput()) { message = "Tile index: " + userInputInt; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter)) { currentTileType = userInputInt < (int)Tile.TileType.total ? userInputInt : ((int)Tile.TileType.total - 1); userInputInt = 0; menu = MenuState.none; message = ""; randomMode = false; PreviousTileHovered = new Point(-1, -1); } break; case MenuState.selectRandomTiles: if (Game1.currentKeyboard.IsKeyDown(Keys.Back) && !Game1.previousKeyboard.IsKeyDown(Keys.Back)) { menu = MenuState.main; message = "Main Menu (backspace to exit). Press:\nR-Room Options\nT-Tile options\nV-View options\nS-Save maps"; } else if (GetStringInput()) { message = "Enter the indexes of the tiles you want to\nrandomly select from (format: index1,index2...)\n" + "You can also click the tiles displayed on the right.\nIndexes: " + userInputString; } else if (mouseState.X >= Game1.gameWidth * Game1.scale && mouseState.X < Game1.viewportRectangle.Width && mouseState.Y >= 0 && mouseState.Y < Game1.viewportRectangle.Height && mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton != ButtonState.Pressed) { int newTileType = (mouseState.X - Game1.gameWidth * Game1.scale) / (Tile.tileSize * Game1.scale) + (mouseState.Y / (Tile.tileSize * Game1.scale) * tilesPerRow); userInputString += ("," + newTileType + ","); message = "Enter the indexes of the tiles you want to\nrandomly select from (format: index1,index2...)\n" + "You can also click the tiles displayed on the right.\nIndexes: " + userInputString; } else if (Game1.currentKeyboard.IsKeyDown(Keys.Enter)) { randomTiles.Clear(); string[] arr = userInputString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); userInputString = ""; if (arr.Length == 0) { break; } else if (arr.Length == 1) { menu = MenuState.none; message = ""; randomMode = false; PreviousTileHovered = new Point(-1, -1); int tile = int.Parse(arr[0]); currentTileType = tile < (int)Tile.TileType.total ? tile : ((int)Tile.TileType.total - 1); break; } foreach (string s in arr) { int tile = int.Parse(s); tile = tile < (int)Tile.TileType.total ? tile : ((int)Tile.TileType.total - 1); randomTiles.Add(tile); } randomMode = true; menu = MenuState.none; message = ""; } break; default: break; } }
public void ApplySaveData() { GameStats.Inizialize(gameTime, deathsCount, hitsCount); FinalBoss.Dead = finalBossDead; MidBoss.Dead = midBossDead; RoomsManager.CurrentRoom = (RoomsManager.Rooms)currentRoom; RoomsManager.PreviousRoom = (RoomsManager.Rooms)previousRoom; Player.healthPoints = health; Player.position = new Vector2(playerPosition[0], playerPosition[1]); if (eventAlreadyHappened[(int)GameEvents.Events.unlockDoubleJump]) {//enable double jump if it was already unlocked Player.doubleJumpUnlocked = true; AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite( new AnimatedSprite(new Vector2(211, 926), AnimatedSprite.AnimationType.displayDoubleJumpRelic, false)); } if (eventAlreadyHappened[(int)GameEvents.Events.unlockWallJump]) {//enable wall jump if it was already unlocked Player.wallJumpUnlocked = true; AnimatedSpritesManager.animatedSpritesRoomManagers[(int)RoomsManager.Rooms.churchBellTower0].AddTempAnimatedSprite( new AnimatedSprite(new Vector2(239, 926), AnimatedSprite.AnimationType.displayWallJumpRelic, false)); } foreach (CollectablesRoomManager r in CollectablesManager.collectablesRoomManagers) {//remove collectables already collected for (int i = 0; i < r.collectables.Count; i++) { bool delete = true; foreach (int j in itemsOnMap) { if (r.collectables[i].ID == j || r.collectables[i].ID == -1) { delete = false; break; } } if (delete) { r.collectables.RemoveAt(i); i--; } } } CollectablesManager.collectedItems.Clear(); foreach (int i in itemsInInventory) {//place items in inventory CollectablesManager.AddToInventory(new Collectable(Point.Zero, (Collectable.ItemType)i)); } int room = 0; foreach (DoorsRoomManager r in DoorsManager.doorsRoomManagers) {//remove doors that have been opend already for (int i = 0; i < r.doors.Count; i++) { bool delete = true; foreach (int j in closedDoor) { if (r.doors[i].ID == j) { delete = false; break; } } if (delete) { r.doors[i].OpenDoor(room); r.doors.RemoveAt(i); i--; } } room++; } GameEvents.eventAlreadyHappened = eventAlreadyHappened; PlayerDeathManager.ResetVariables(); CameraManager.SwitchCamera(RoomsManager.CurrentRoom); }
public static void ResetVariables() {//reposition the player and reset some classes to their intial state Player.IsOnMovingPlatform = false; elapsedTimeBeforeResuming = 0; Game1.currentGameState = Game1.GameStates.playing; CameraManager.Reset(); LavaGeyserManager.Reset(); FireBallsManager.Reset(); ProjectilesManager.Reset(); EnemyManager.Reset(); if (!MidBoss.Dead) { MidBoss.Reset(); } CollectablesManager.ResetHearts(); GameEvents.Reset(); switch (RoomsManager.CurrentRoom) { case RoomsManager.Rooms.tutorial0: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial4) { Player.position = new Vector2(152, 192); } else if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial1) { Player.position = new Vector2(903, 185); } else { Player.position = new Vector2(152, 150); } break; case RoomsManager.Rooms.tutorial1: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial0) { Player.position = new Vector2(18, 185); } else { Player.position = new Vector2(550, 193); } break; case RoomsManager.Rooms.tutorial2: if (Player.position.Y < 80 && RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial1 && (Player.position.X < 366 || Player.position.X > 426)) { RoomsManager.CurrentRoom = RoomsManager.Rooms.tutorial1; RoomsManager.PreviousRoom = RoomsManager.Rooms.tutorial0; CameraManager.SwitchCamera(RoomsManager.Rooms.tutorial1); Player.position = new Vector2(18, 185); } else { Player.position = new Vector2(388, 153); } break; case RoomsManager.Rooms.tutorial3: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0) { Player.position = new Vector2(776, 193); } else { Player.position = new Vector2(91, 193); } break; case RoomsManager.Rooms.tutorial4: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape2) { Player.position = new Vector2(64, 153); } else { Player.position = new Vector2(166, 153); } break; case RoomsManager.Rooms.churchBellTower0: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower1) { if (Player.position.X < 436 && Player.position.X >= 60) { Player.position = new Vector2(405, 161); } else if (Player.position.X >= 436) { Player.position = new Vector2(456, 961); } else { Player.position = new Vector2(23, 961); } } else if (RoomsManager.PreviousRoom == RoomsManager.Rooms.tutorial3) { Player.position = new Vector2(23, 961); } else { Player.position = new Vector2(456, 961); } break; case RoomsManager.Rooms.churchBellTower1: if (Player.position.X >= 436) { Player.position = new Vector2(458, 1097); } else if (Player.position.X < 60) { Player.position = new Vector2(23, 1097); } else { if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0) { Player.position = new Vector2(372, 1097); } else { Player.position = new Vector2(111, 121); } } break; case RoomsManager.Rooms.churchBellTower2: if (Player.position.X >= 436 && Player.position.Y > 110) { Player.position = new Vector2(464, 1177); } else if (Player.position.X >= 60) { if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower1) { Player.position = new Vector2(119, 1177); } else { Player.position = new Vector2(457, 65); } } else { Player.position = new Vector2(23, 1177); } break; case RoomsManager.Rooms.midBoss: Player.position = new Vector2(452, 25); break; case RoomsManager.Rooms.churchGroundFloor0: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0) { Player.position = new Vector2(22, 465); } else { Player.position = new Vector2(1160, 465); } break; case RoomsManager.Rooms.churchAltarRoom: if (Player.position.X < 104) { Player.position = new Vector2(22, 465); } else { Player.position = new Vector2(250, 465); } break; case RoomsManager.Rooms.church1stFloor0: if (Player.position.X < 1288) { if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchAltarRoom) { Player.position = new Vector2(1208, 217); } else { Player.position = new Vector2(18, 217); } } else { Player.position = new Vector2(1320, 217); } break; case RoomsManager.Rooms.church2ndFloor0: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchBellTower0) { Player.position = new Vector2(37, 481); } else { Player.position = new Vector2(1289, 481); } break; case RoomsManager.Rooms.descent: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.churchAltarRoom) { Player.position = new Vector2(339, 121); } else { Player.position = new Vector2(318, 233); } break; case RoomsManager.Rooms.finalBoss: Game1.Zoom0Dot5(); MediaPlayer.Stop(); if (!FinalBoss.Dead) { Player.position = new Vector2(734, 41); } else { Player.position = new Vector2(17, 41); } break; case RoomsManager.Rooms.escape0: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.finalBoss) { Player.position = new Vector2(1726, 129); } else { Player.position = new Vector2(18, 49); } break; case RoomsManager.Rooms.escape1: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape0) { Player.position = new Vector2(1320, 89); } else { Player.position = new Vector2(12, 289); } break; case RoomsManager.Rooms.escape2: if (RoomsManager.PreviousRoom == RoomsManager.Rooms.escape1) { Player.position = new Vector2(500, 289); } else { Player.position = new Vector2(21, 129); } break; } }