/// Update public void update(GameTime gameTime, Player mainPlayer, HUD mainHUD, AreaInterface areaInt, LoadGame mainLG, GamePadState state) { // REGISTER BUTTON PRESS RESETS, ALLOWS ONLY ONE REGISTER OF BUTTON PRESS FOR START AND SELECT if ((state.Buttons.RightStick != ButtonState.Pressed && Keyboard.GetState().IsKeyUp(Keys.Enter) == true) && _registerStartPress == false) // once start or enter pressed, close title screen. { _registerStartPress = true; } if ((state.Buttons.A != ButtonState.Pressed && Keyboard.GetState().IsKeyUp(Keys.B) == true) && _ShowTitleScreen == false && _registerBPress == false) // once start or enter pressed, close title screen. { _registerBPress = true; } if ((state.Buttons.LeftStick != ButtonState.Pressed && Keyboard.GetState().IsKeyUp(Keys.S) == true) && _ShowTitleScreen == false && _registerSelectPress == false) // once start or enter pressed, close title screen. { _registerSelectPress = true; } // GAMEOVER - The a player killed animation is shown for 3000ms then the gameover screen is displayed for 5000ms. if (_GameOver == true) { if (mainHUD.TotalTime == 0) { mainLG.DeleteGameFile(_SaveFileNumber); // IF the player runs out of time, DELETE the game save file. } _GameOverTime += gameTime.ElapsedGameTime.Milliseconds; _EntityKilled = true; _KilledLocation = mainPlayer.EntityPos; _showPlayer = false; if (_GameOverTime >= 3000 && GameOverStoryTime < 9000) { _GameOverStoryTime += gameTime.ElapsedGameTime.Milliseconds; _EntityKilled = false; _GameOverAniCompleted = true; } if (GameOverStoryTime >= 9000) { _init = true; // restart the game } } if (_gameComplete == true) { // IF the game has been completed, the player is shown information, if they press enter or push start they will be able to start again. if ((state.Buttons.RightStick == ButtonState.Pressed && Keyboard.GetState().IsKeyDown(Keys.Enter) == true)) { mainLG.DeleteGameFile(_SaveFileNumber); _init = true; } } // TITLE SCREEN if (ShowTitleScreen == true) { _SplashScreenTime += gameTime.ElapsedGameTime.Milliseconds; // Controls Screen if (_SplashScreenTime > 5000 && _SplashScreenTime < 14000) { if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter)) // once start or enter pressed, close title screen. { // Skip to title screen _SplashScreenTime = 14000; _registerStartPress = false; } } // Title Screen if (_SplashScreenTime > 14000 && RegisterStartPress == true) { if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter)) // once start or enter pressed, close title screen. { // Go to the LoadScreen. _ShowTitleScreen = false; _showLoadScreen = true; _showFirstDay = false; _registerStartPress = false; } } } // Splash screens showing the current day to the player, they are shown for a limited time. // THE FIRST DAY GRAPHIC IS SHOWN if (_showFirstDay == true) { GraphicShowTime += gameTime.ElapsedGameTime.Milliseconds; if (GraphicShowTime >= 2000) { mainHUD.Dawn = (true); mainHUD.Dusk = (false); _showFirstDay = false; _showHUD = true; mainPlayer.AllowEntityMovement = true; mainPlayer.AllowWeaponFire = true; _showPlayer = true; _showEnemies = true; _showItems = true; _eraseList = false; GraphicShowTime = 0; } } // THE FINAL DAY GRAPHIC IS SHOWN if (_showFinalDay == true) { GraphicShowTime += gameTime.ElapsedGameTime.Milliseconds; mainPlayer.AllowEntityMovement = false; mainPlayer.AllowWeaponFire = false; mainPlayer.PlayerWeaponFiring = false; mainPlayer.NewPlayerWeaponFire = true; mainPlayer.DrawWeapon = false; _showPlayer = false; if (GraphicShowTime >= 2000) { mainHUD.Dawn = (true); mainHUD.Dusk = (false); _showFinalDay = false; _showHUD = true; mainPlayer.AllowEntityMovement = true; mainPlayer.AllowWeaponFire = true; _showPlayer = true; _showEnemies = true; _showItems = true; _eraseList = false; FinalDayShown = true; GraphicShowTime = 0; } } // DUNGEON COMPLETED SCREEN shown for a limited time. if (mainPlayer.JustCompletedDungeon == true) { GraphicShowTime += gameTime.ElapsedGameTime.Milliseconds; mainPlayer.AllowEntityMovement = false; mainPlayer.AllowWeaponFire = false; mainPlayer.PlayerWeaponFiring = false; mainPlayer.NewPlayerWeaponFire = true; mainPlayer.DrawWeapon = false; _showPlayer = false; if (GraphicShowTime >= 5000) { mainPlayer.JustCompletedDungeon = false; if (mainPlayer.CompletedDungeons[0] == true && mainPlayer.CompletedDungeons[1] == true && mainPlayer.CompletedDungeons[2] == true) { // If all three dungeons have been completed then the game has been completed. _gameComplete = true; } else { _showHUD = true; mainPlayer.AllowEntityMovement = true; mainPlayer.AllowWeaponFire = true; _showPlayer = true; _showEnemies = true; _showItems = true; _eraseList = false; FinalDayShown = true; GraphicShowTime = 0; } } } // ENERGY BARRIERS PREVENTING EXIT FROM DUNGEON SECTION if (areaInt.EnemyList != null && _gamePaused == false) { if (areaInt.EnemyList.Count > 0 && mainPlayer.InDungeon == true) { // Enable the energy barrier if there are enemies present in a dungeon section. _EnergyBarrierStatus = true; } else { _EnergyBarrierStatus = false; } } else { _EnergyBarrierStatus = false; } }
/// Update public void update(GamePadState state, InformationDisplay mainID, LoadGame mainLG, Player mainPlayer, HUD mainHUD, AreaInterface areaInt) { mainLG.INIT(ref ActiveSaves, ref CompletedDungeons); // initialise if (mainID.RegisterSelectPress == true) { if (DeleteMode == true) { // DELETE MODE // If conditions: so that program only registers one press of each specified button at a time. if (state.Buttons.LeftStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.S) == true) { mainID.RegisterSelectPress = false; } if (mainID.RegisterBPress == true) // confirm the player wants to delete the save file { if (state.Buttons.A == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.B) == true) // player chooses not to delete { DeleteMode = false; // exit delete mode mainID.RegisterBPress = false; } } // Player chooses to delete file if (mainID.RegisterStartPress == true) // if start button can be pressed { if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter) == true) { mainLG.DeleteGameFile(LoadOptionNumber); // Delete file DeleteMode = false; // exit delete mode mainID.RegisterStartPress = false; } } } if (DeleteMode == false) // If not in delete mode { // SWITCHING OPTIONS if (state.Buttons.LeftStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.S) == true) { LoadOptionNumber += 1; if (LoadOptionNumber >= 4) { LoadOptionNumber = 1; } // only allow upto 4 options // Move the position of the arrow graphic in accordance to the option number if (LoadOptionNumber == 1) { ArrowPos = new Vector2(40, 180); } if (LoadOptionNumber == 2) { ArrowPos = new Vector2(40, 340); } if (LoadOptionNumber == 3) { ArrowPos = new Vector2(40, 500); } mainID.RegisterSelectPress = false; } // CHECK TO SEE IF ENTERING DELETE MODE if (mainID.RegisterBPress == true) { if (state.Buttons.A == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.B) == true) { if (ActiveSaves[LoadOptionNumber - 1] == true) // -1 as option number minimum is 1 compared with Active saves which starts with 0. { DeleteMode = true; // enter delete mode } mainID.RegisterBPress = false; } } // LOAD GAME FILE AND SETUP, LoadOptionNumber 1 corresponds with file 0. if (mainID.RegisterStartPress == true) { if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter) == true) { if (ActiveSaves[LoadOptionNumber - 1] == true) // -1 as option number minimum is 1 compared with Active saves which starts with 0. { mainLG.LoadGameFile(mainID, mainPlayer, mainHUD, LoadOptionNumber); areaInt.GenerateStructure((int)mainPlayer.CurrentOWSec.X, (int)mainPlayer.CurrentOWSec.Y); areaInt.GenerateRectangleCollisions(); mainPlayer.PlayerGenCoordinate(areaInt); RegularSettings(mainPlayer, mainID); } else { DefaultSettings(mainPlayer, mainID, areaInt); } mainID.ShowPlayer = true; mainID.SaveFileNumber = LoadOptionNumber; mainID.ShowLoadScreen = false; mainID.RegisterStartPress = false; } } } } }