Ejemplo n.º 1
0
        /// 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;
            }
        }
Ejemplo n.º 2
0
        /// 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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void update(GamePadState state, InformationDisplay mainID, LoadGame mainLG, Player mainPlayer, HUD mainHUD, ref bool ExitGame)
        {
            if (mainID.GamePaused == false && mainID.ShowPlayer == true)                                                  // If the game is not paused allow the game to be paused as long as the player graphic is currently shown
            {
                if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter) == true) // once start or enter pressed, close title screen.
                {
                    mainID.GamePaused          = true;                                                                    // pause game
                    mainID.RegisterStartPress  = false;
                    mainID.RegisterSelectPress = false;
                    OptionNumber = 1;                     // default option number to 1
                    ArrowPos     = new Vector2(250, 315); // default arrow position
                }
            }

            if (mainID.GamePaused == true)
            {
                if (mainID.RegisterSelectPress == true)
                {
                    if (state.Buttons.LeftStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.S) == true)
                    {
                        OptionNumber += 1;                         // Increment option number by 1 each time start or enter pressed

                        if (OptionNumber == 4)
                        {
                            OptionNumber = 1;
                        }                                                                    // options only go upto 3 so reset to 1

                        if (OptionNumber == 1)
                        {
                            ArrowPos = new Vector2(250, 315);                             // change arrow position when option changed
                        }

                        if (OptionNumber == 2)
                        {
                            ArrowPos = new Vector2(250, 392);
                        }

                        if (OptionNumber == 3)
                        {
                            ArrowPos = new Vector2(250, 469);
                        }

                        mainID.RegisterSelectPress = false;                         // Only allow one option to be changed per press of button
                    }
                }

                if (mainID.RegisterStartPress == true)
                {
                    if (state.Buttons.RightStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Enter) == true)                     // once start or enter pressed, close title screen.
                    {
                        if (OptionNumber == 1)
                        {
                            mainID.GamePaused = false;                             // resume the game
                        }

                        if (OptionNumber == 2)
                        {
                            mainLG.SaveGameFile(mainPlayer, mainHUD, mainID);                           // Save the game file selected when started
                        }

                        if (OptionNumber == 3)
                        {
                            ExitGame = true;                             // Close the game
                        }

                        mainID.RegisterStartPress = false;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// Initialize method:
        /// The following method will instantiate objects used throughout the program and set up default values for variables.

        protected override void Initialize()
        {
            try
            {
                mainID           = new InformationDisplay();
                mainID.GameError = false;
            }
            catch
            {
                Console.WriteLine("[WARNING] A game error has occurred! " + "GE0000MID");
            }

            try
            {
                Window.Title = "Chevron Shards";

                // WINDOW SIZE
                graphics.PreferredBackBufferWidth  = 768;
                graphics.PreferredBackBufferHeight = 720;
                graphics.ApplyChanges();
            }
            catch
            {
                // IF AN ERROR OCCURS WHILE LOADING A TEXTURE
                mainID.GameErrorCode = "GE0006WIN";
                Console.WriteLine("[WARNING] A game error has occurred! " + mainID.GameErrorCode);
                mainID.GameError = true;
            }

            try{
                Console.WriteLine("Game is Initialising...");

                // TITLE SCREEN
                mainID.ShowTitleScreen = true;
                mainID.ShowLoadScreen  = false;
                mainID.ShowHUD         = false;

                //mainLG = new LoadGame();
                mainLG     = new LoadGame();
                mainPS     = new PauseScreen();
                mainLS     = new LoadScreen();
                mainHUD    = new HUD();
                mainPlayer = new Player();
                mainOWM    = new OverworldManager();        // OWM stands for OverWorldManager
                mainDM     = new DungeonManager();          // DM stands for DungeonManager
                mainBLM    = new BossLevelManager();        // BLM stands for BossLevelManager
                mainEM     = new EnemyManager();            // EM stands for EnemyManager
                mainIM     = new ItemManager();             // IM stands for ItemManager

                mainID.SplashScreenTime = 0;

                mainHUD.Initialise();

                mainPlayer.InOverworld = true;                 // set player location to overworld
                mainPlayer.InDungeon   = false;
                mainPlayer.InBossLevel = false;

                InterfaceUpdate();

                areaInt.ChangeSec = false;

                mainID.GamePaused = false;

                mainPlayer.AllowEntityMovement = false;
                mainPlayer.AllowWeaponFire     = false;
                mainPlayer.PlayerWeaponFiring  = false;
                mainPlayer.NewPlayerWeaponFire = true;
                mainPlayer.DrawWeapon          = false;

                mainPlayer.AllowEntityDirChange = true;
                mainPlayer.Orientation          = 'R';
                mainPlayer.CurrentWeapon        = "Sword";
                mainPlayer.ChangeWeapon();

                mainID.ShowPlayer   = false;
                mainID.NewEnemyList = true;

                mainID.ShowItems     = false;
                mainID.NewItemList   = true;
                mainID.EraseItemList = false;

                mainID.EnergyBarrierStatus = false;

                mainID.GameOver             = false;
                mainID.GameOverAniCompleted = false;
                mainID.GameOverTime         = 0;
                mainID.GameOverStoryTime    = 0;


                mainID.ElapsedTime = 0f;

                mainID.CurrentFrame = new Point(0, 0);

                mainID.EntityKilled       = false;
                mainID.KillAnimationTimer = 0;
            }
            catch
            {
                mainID.GameErrorCode = "GE0007INI";
                Console.WriteLine("[WARNING] A game error has occurred! " + mainID.GameErrorCode);
                mainID.GameError = true;
            }

            base.Initialize();             // THIS MUST BE LAST
        }