コード例 #1
0
        /// UPDATE METHOD

        public void update(AreaInterface areaInt, Player mainPlayer)
        {
            List <ItemInterface> ItemList = areaInt.ItemList;

            if (ItemList != null)
            {
                Rectangle playerRect = mainPlayer.Rect();

                for (int i = 0; i < ItemList.Count; i++)
                {                 // Cycle throught Items list to check for collisions
                    Rectangle ItemRect = new Rectangle((int)ItemList[i].ItemCoordinates.X, (int)ItemList[i].ItemCoordinates.Y, ItemList[i].Width, ItemList[i].Height);

                    if (ItemRect.Intersects(playerRect))                       // If rectangles collide then run following logic

                    {
                        if (ItemList[i].Name == "Coin")
                        {
                            mainPlayer.CoinCount = (mainPlayer.CoinCount + 1);
                        }

                        if (ItemList[i].Name == "Heart")
                        {
                            mainPlayer.Health = mainPlayer.Health + 15;
                        }

                        ItemList.RemoveAt(i);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: TheMattSykes/ChevronShards
        public bool PlayerEnemyWeaponCollision(AreaInterface areaPoly)
        {         // player hit by enemy weapon
            List <EnemyInterface> EnemyList = areaPoly.EnemyList;

            // Cycle through EnemyList, draw a rectangle around the enemies weapon and check for player intersection.
            for (int i = 0; i < EnemyList.Count; i++)
            {
                Rectangle CurrentRect = new Rectangle((int)EnemyList[i].EnemyWeapon.GetWeaponCoordinates().X, (int)EnemyList[i].EnemyWeapon.GetWeaponCoordinates().Y, EnemyList[i].EnemyWeapon.GetWeaponWidth(), EnemyList[i].EnemyWeapon.GetWeaponHeight());

                try
                {
                    if (Rect().Intersects(CurrentRect) == true && areaPoly.EnemyList[i].DrawWeapon == true)
                    {
                        if (_hitTime < 1)                         // only allow certain amount of hits by weapon at one time.
                        {
                            _playerHit = true;
                        }

                        _allowEntityMovement = true;
                        return(true);
                    }
                }
                catch {
                    return(false);
                }
            }
            return(false);
        }
コード例 #3
0
        public Vector2 ItemGenCoordinate(int ItemValue, Player mainPlayer, AreaInterface areaInt)
        {                                                       // Generates random Item coordaintes which must not intersect with the area structure or player when spawned and returns them
            List <ItemInterface> ItemList   = areaInt.ItemList; // List of items
            Rectangle            playerRect = mainPlayer.Rect();
            List <Rectangle>     RectList   = areaInt.CollisionRects;
            List <Rectangle>     ItemRects  = areaInt.ItemRects;

            Random  R = new Random();
            Vector2 FinalCoordinates;
            bool    useCoordinates = true;

            while (true)             // loop runs until break
            {
                useCoordinates = true;

                int     X = R.Next(60, 700);
                int     Y = R.Next(200, 566);
                Vector2 PossibleCoordinates = new Vector2(X, Y);


                Rectangle NewItemRect = new Rectangle(X, Y, ItemList[ItemValue].Width + 30, ItemList[ItemValue].Height + 30);                 // form a rectangle around the enemy for collision purposes, allows 10 pixels around it

                if (NewItemRect.Intersects(playerRect))
                {
                    useCoordinates = false;
                }

                // For loops cycle through ItemList

                // For loop to prevent spawning of items on other objects
                for (int i = 0; i < RectList.Count; i++)
                {
                    if (NewItemRect.Intersects(RectList[i]))
                    {
                        useCoordinates = false;
                    }
                }


                // For loop to prevent spawning of items on top of other items
                for (int i = 0; i < ItemRects.Count; i++)
                {
                    if (NewItemRect.Intersects(ItemRects[i]))
                    {
                        useCoordinates = false;
                    }
                }

                if (useCoordinates == true)
                {
                    FinalCoordinates = PossibleCoordinates;
                    _ItemCoordinates = FinalCoordinates;
                    break;
                }
            }


            ItemRects.Add(new Rectangle((int)FinalCoordinates.X, (int)FinalCoordinates.Y, _Width, _Height));             // Add item rectangle to list
            return(FinalCoordinates);
        }
コード例 #4
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, AreaInterface areaInt)
        {
            List <EnemyInterface> EnemyList = areaInt.EnemyList;

            if (EnemyList != null)             // If the enemy list is not empty
            {
                for (int i = 0; i < EnemyList.Count; i++)
                {                 // cycle through list of enemies and draw textures at denoted coordinates
                    if (EnemyList[i].DrawWeapon == true)
                    {
                        spriteBatch.Draw(EnemyList[i].EnemyWeapon.WeaponTexture, EnemyList[i].EnemyWeapon.GetWeaponCoordinates());
                    }


                    if (EnemyList[i].EnemyHitTime < 1)
                    {
                        spriteBatch.Draw(EnemyList[i].EnemyTexture, EnemyList[i].DrawCoordinates);
                    }
                    else
                    {
                        spriteBatch.Draw(EnemyList[i].EnemyTexture, EnemyList[i].DrawCoordinates, color: Color.Red);                         // Red transparency superimposed on enemy when hit
                    }
                }
            }
        }
コード例 #5
0
        // Load textures into Texture variables
        public void LoadContent(ContentManager Content, AreaInterface areaInt)
        {
            List <ItemInterface> ItemList = areaInt.ItemList;

            if (ItemList.Count != 0)                     // If item list is not empty
            {
                for (int i = 0; i < ItemList.Count; i++) // cycle through Item list and allocate textures
                {
                    ItemList[i].Texture = Content.Load <Texture2D>(ItemList[i].TextureName);
                }
            }
        }
コード例 #6
0
        /// DRAW METHOD
        public void Draw(SpriteBatch spriteBatch, AreaInterface areaInt)
        {
            List <ItemInterface> ItemList = areaInt.ItemList;

            if (ItemList != null)
            {
                for (int i = 0; i < ItemList.Count; i++)
                {                 // Cycle through Item List drawing their texture at their denoted coordinates
                    if (ItemList.Count != 0)
                    {
                        spriteBatch.Draw(ItemList[i].Texture, ItemList[i].ItemCoordinates);
                    }
                }
            }
        }
コード例 #7
0
        /// InterfaceUpdate Method:
        /// This method is used for setting an Interface of AreaInterface type to act as the object of the current area.

        public void InterfaceUpdate()
        {
            if (mainPlayer.InOverworld == true)
            {
                areaInt = mainOWM as AreaInterface;
            }
            if (mainPlayer.InDungeon == true)
            {
                areaInt = mainDM as AreaInterface;
            }
            if (mainPlayer.InBossLevel == true)
            {
                areaInt = mainBLM as AreaInterface;
            }
        }
コード例 #8
0
        public void LoadContent(ContentManager Content, AreaInterface areaInt)
        {
            // ENEMY GRAPHICS AND ENEMY WEAPON GRAPHICS
            if (areaInt.EnemyList != null)             // If the enemy list is not null load the enemy texture into the Texture variable for each enemy in the list.
            {
                if (areaInt.EnemyList.Count != 0)
                {
                    for (int i = 0; i < areaInt.EnemyList.Count; i++)                     // 0 to enemyList size
                    {
                        areaInt.EnemyList[i].EnemyTexture = Content.Load <Texture2D>(areaInt.EnemyList[i].GetEnemyTextureName());

                        // Set weapon texture based on object parameters
                        areaInt.EnemyList[i].EnemyWeapon.WeaponTexture = Content.Load <Texture2D>(areaInt.EnemyList[i].EnemyWeapon.GetWeaponTextureName(areaInt.EnemyList[i].Orientation));
                    }
                }
            }
        }
コード例 #9
0
        /// DefaultSettings
        /// If the player starts a new game the variables will be set to the values specified in the function.
        public void DefaultSettings(Player mainPlayer, InformationDisplay mainID, AreaInterface areaInt)
        {
            int STARTX = 2;             // inital starting section of overworld is 2,4
            int STARTY = 4;

            int STARTDUNNUM = 1;             // set default dungeon number

            mainID.ShowFirstDay = true;      // show the first day information screen on loading of game file.
            // Set variables for player object
            mainPlayer.CurrentOWSec         = new Vector2(STARTX, STARTY);
            mainPlayer.EntityPos            = new Vector2(144, 432);  // 144,432
            mainPlayer.CurrentDungeonNumber = STARTDUNNUM;
            mainPlayer.CurrentBLNumber      = STARTDUNNUM;

            areaInt.GenerateStructure(STARTX, STARTY);
            areaInt.GenerateRectangleCollisions();
        }
コード例 #10
0
        /// EnemyCollision Method:
        /// A for loop goes through a list of enemies forming a rectangle with their coordinates and size, this is compared to another rectangle to see if a intersection occurs.

        public bool EnemyAndPlayerCollision(int ListValue, Player mainPlayer, AreaInterface areaInt)
        {
            List <EnemyInterface> EnemyList  = areaInt.EnemyList;
            Rectangle             entityRect = (EnemyList[ListValue].EnemyRectangle);

            if (entityRect.Intersects(mainPlayer.Rect()))
            {
                return(true);                // Collision between enemy and player detected
            }

            for (int i = 0; i < EnemyList.Count; i++)
            {
                Rectangle CurrentRect = new Rectangle((int)areaInt.EnemyList[i].EnemyCoordinates.X, (int)EnemyList[i].EnemyCoordinates.Y, EnemyList[i].Width, EnemyList[i].Height);
                // Draw rectangle around current enemy in the list

                if (entityRect.Intersects(CurrentRect) == true && i != ListValue)
                {
                    return(true);                    // collision between two enemies detected
                }
            }
            return(false);            // no collision detected
        }
コード例 #11
0
ファイル: Player.cs プロジェクト: TheMattSykes/ChevronShards
        /// PLAYER COLLISION

        public bool PlayerEnemyCollision(AreaInterface areaPoly)
        {
            // Cycle through each enemy in the EnemyList, draw a rectangle around each one and check for player intersection.
            for (int i = 0; i < areaPoly.EnemyList.Count; i++)
            {
                Rectangle CurrentRect = new Rectangle((int)areaPoly.EnemyList[i].EnemyCoordinates.X, (int)areaPoly.EnemyList[i].EnemyCoordinates.Y, areaPoly.EnemyList[i].Width, areaPoly.EnemyList[i].Height);
                // draw a rectangle around the current enemy in the list

                if (Rect().Intersects(CurrentRect) == true)
                {
                    if (_hitTime < 1)                     // only allow certain amount of hits by enemy at one time.
                    {
                        _playerHit = true;
                    }

                    _allowEntityMovement = false;
                    entityReaction();                // call method for player to react to collision.
                    _allowEntityMovement = true;
                    return(true);                    // collision
                }
            }
            return(false);            // no collision
        }
コード例 #12
0
ファイル: Player.cs プロジェクト: TheMattSykes/ChevronShards
        /// END OF PLAYER COLLISION



        public void PlayerGenCoordinate(AreaInterface areaInt)
        {                                                       // Generate random new player coordaintes within bounds
            List <Rectangle> RectList = areaInt.CollisionRects; // List of all rectangles drawn around 48x48 structure blocks.

            Random  R = new Random();
            Vector2 FinalCoordinates;
            bool    useCoordinates = true;

            while (true)             // endless loop until break, the loop will break if coordaintes are allowed.
            {
                useCoordinates = true;

                // X and Y constraints
                int     X = R.Next(48, 300);
                int     Y = R.Next(240, 576);
                Vector2 PossibleCoordinates = new Vector2(X, Y);                          // proposed random coordaintes

                Rectangle NewPlayerRect = new Rectangle(X, Y, _Width + 30, _Height + 30); // form a rectangle around the enemy for collision purposes, allows 10 pixels around it

                // For loop to prevent spawning of enemies on other objects
                for (int i = 0; i < RectList.Count; i++)
                {
                    if (NewPlayerRect.Intersects(RectList[i]))
                    {
                        useCoordinates = false;                         // Do not use coordinates if they are within a 48x48 structure block.
                    }
                }

                if (useCoordinates == true)                 // use the coordaintes
                {
                    FinalCoordinates = PossibleCoordinates;
                    _entityPos       = FinalCoordinates;
                    _drawPos         = FinalCoordinates;
                    break;
                }
            }
        }
コード例 #13
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;
            }
        }
コード例 #14
0
ファイル: Player.cs プロジェクト: TheMattSykes/ChevronShards
        // NOTE: PLAYER ITEM COLLISION IS IN THE ITEM MANAGER - instantiated as mainIM in Game1 class.



        // MAIN FUNCTIONS


        public void Update(GameTime gameTime, GamePadState state, AreaInterface areaPoly, InformationDisplay mainID)
        {
            int playerSpeed = 4;             // player speed set

            if (_hasAnimationReset == true)
            {
                timeSinceLastFrame = 0;                 // resets animation
            }


            // CHECK MOVE MANAGER FUNCTIONS RETURN WHETHER THE PLAYER CAN MOVE IN THE DIRECTION THEY ARE FACING
            bool checkMove = false;


            checkMove = areaPoly.checkMoveManager(Rect());             // check whether the move is valid



            // CHECK EXIT MANAGER FUNCTIONS RETURN WHETHER THE PLAYER WILL MOVE INTO ANOTHER SECTION OF THE OVERWORLD OR DUNGEON
            string checkExit = "";

            if (mainID.EnergyBarrierStatus == false)             // CHANGE THIS TO JUST FALSE
            {
                if (_inOverworld == true)
                {
                    checkExit = areaPoly.checkExitManager(Rect(), CurrentOWSec);                     // checks to see if the player is near an exit
                }
                else
                {
                    checkExit = areaPoly.checkExitManager(Rect(), CurrentDUNSec);                     // checks to see if the player is near an exit
                }
            }


            // COLLISION WITH ENEMY ENTITIES
            bool checkEnemyCollision = false;

            if (areaPoly.EnemyList != null)
            {
                if (areaPoly.EnemyList.Count > 0)
                {
                    checkEnemyCollision = PlayerEnemyCollision(areaPoly);

                    PlayerEnemyWeaponCollision(areaPoly);                     // collisions with enemy weapons
                }
            }



            if (checkMove == false && checkEnemyCollision == false)
            {
                _drawPos = _entityPos;
            }                                                                                              // set draw coordaintes to equal the entity coordinates as they are valid.
            if ((checkMove == true || checkEnemyCollision == true) && _allowEntityDirChange == true)
            {
                _entityPos = _drawPos;
            }                                                                                                                               // Opposite to previous comment as they are not valid.


            // If statements and logic for the player traveling between areas

            if (_inOverworld == true)                                                                                             // if the player is in the overworld
            {
                bool checkDunEntrance = areaPoly.checkDunEntranceManager(_entityPos, _Height, _Width, ref _currentDungeonNumber); // check if the player has gone through dungeon entrance

                if (checkDunEntrance == true)
                {
                    if (areaPoly.EnemyList != null)
                    {
                        areaPoly.EnemyList.Clear();                         // clear the enemy list
                    }

                    _inDungeon      = true;                // enter the dungeon
                    _inOverworld    = false;
                    _inBossLevel    = false;
                    _hasChangedArea = true;

                    // default perameters/values for dungeons

                    _currentDUNSec  = new Vector2(2, 3);
                    _previousDUNSec = new Vector2(2, 3);

                    if (_currentDungeonNumber == 1)
                    {
                        _entityPos = new Vector2(288 - _Width, 650);
                        _drawPos   = _entityPos;
                    }

                    if (_currentDungeonNumber == 2)
                    {
                        _entityPos = new Vector2(288 - _Width, 650);
                        _drawPos   = _entityPos;
                    }

                    if (_currentDungeonNumber == 3)
                    {
                        _entityPos = new Vector2(288 - _Width, 650);
                        _drawPos   = _entityPos;
                    }
                }
            }


            if (_inDungeon == true)                                       // if the player is in a dungeon
            {
                bool checkDunExit = areaPoly.checkDunExitManager(Rect()); // check to see if player has collided with dungeon exit

                if (checkDunExit == true)
                {
                    if (areaPoly.EnemyList != null)
                    {
                        areaPoly.EnemyList.Clear();                         // clear the enemy list
                    }

                    // change area to overworld
                    _inDungeon      = false;
                    _inOverworld    = true;
                    _inBossLevel    = false;
                    _hasChangedArea = true;


                    // Set default entity position for overworld section to avoid collisions with structure
                    if ((int)_currentOWSec.X == 4 && (int)_currentOWSec.Y == 2)
                    {
                        _entityPos = new Vector2(366, 496);
                    }

                    if ((int)_currentOWSec.X == 1 && (int)_currentOWSec.Y == 0)
                    {
                        _entityPos = new Vector2(366, 496);
                    }

                    if ((int)_currentOWSec.X == 0 && (int)_currentOWSec.Y == 4)
                    {
                        _entityPos = new Vector2(510, 544);
                    }

                    _drawPos = _entityPos;
                }


                bool checkBossLevelEntrance = areaPoly.checkBossLevelEntranceManager(Rect());                 // check if player rectangle collides with BossLevel entrance

                if (checkBossLevelEntrance == true && mainID.EnergyBarrierStatus == false)
                {
                    // Change area to BossLevel
                    _inDungeon      = false;
                    _inOverworld    = false;
                    _inBossLevel    = true;
                    _hasChangedArea = true;

                    _entityPos = new Vector2(((720 / 2) - _Width), 520);                     // Default position when entering a boss level
                }
            }

            if (_inBossLevel == true)                         // player is located in BosLevel
            {
                if (areaPoly.CheckCompletedDungeon() == true) // check to see if dungeon has been completed
                {
                    _completedDungeons[areaPoly.GetBossLevelNumber() - 1] = true;
                    _justCompletedDungeon = true;

                    if (areaPoly.EnemyList != null)
                    {
                        areaPoly.EnemyList.Clear();                         // clear the enemy list
                    }

                    // Change location to the Overworld
                    _inDungeon      = false;
                    _inOverworld    = true;
                    _inBossLevel    = false;
                    _hasChangedArea = true;


                    // Default values when exiting BossLevel
                    if ((int)_currentOWSec.X == 4 && (int)_currentOWSec.Y == 2)
                    {
                        _entityPos = new Vector2(366, 496);
                    }

                    if ((int)_currentOWSec.X == 1 && (int)_currentOWSec.Y == 0)
                    {
                        _entityPos = new Vector2(366, 496);
                    }

                    if ((int)_currentOWSec.X == 0 && (int)_currentOWSec.Y == 4)
                    {
                        _entityPos = new Vector2(510, 544);
                    }

                    _drawPos = _entityPos;
                }
            }


            // Player weapon hit detection
            if (_playerHit == true)
            {
                if (_hitTime < 1)
                {
                    _Health -= 10;                     // deduct 10 health from the player

                    if (_Health <= 0)
                    {
                        _Health         = 0;
                        mainID.GameOver = true;                         // health is 0 so GameOver.
                    }
                }

                // Animation for player hit
                _hitTime           += gameTime.ElapsedGameTime.Milliseconds; // add time to variable
                timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds; // add time to variable
                Animation(gameTime, ref timeSinceLastFrame);                 // animate through the sprite sheet when moving

                // Check recovery
                if (_hitTime >= _recoveryTime)
                {
                    _playerHit = false;
                    _hitTime   = 0;
                }
            }



            // Switch Player Weapons
            if (_allowEntityMovement == true && mainID.RegisterSelectPress == true && _playerWeaponFiring == false)
            {
                if (state.Buttons.LeftStick == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.S) == true)
                {
                    WeaponOptNum++;                     // increase weapon option by 1

                    while (true)
                    {
                        if (WeaponOptNum > 4 || WeaponOptNum < 1)
                        {
                            WeaponOptNum = 1;                             // Reset Weapon Option Number to 1
                        }

                        // Change player weapon based on Weapon Option Number (Changed when player uses S key or SELECT button)
                        if (WeaponOptNum == 1)                         // Default weapon, accessible by all players
                        {
                            _currentWeapon = "Sword";
                            break;
                        }
                        // For the next weapons, they are only avaliable on the condition that a specific dungeon has been completed.
                        if (WeaponOptNum == 2 && CompletedDungeons[0] == true)
                        {
                            _currentWeapon = "Seed";
                            break;
                        }
                        if (WeaponOptNum == 3 && CompletedDungeons[1] == true)
                        {
                            _currentWeapon = "FireBall";
                            break;
                        }
                        if (WeaponOptNum == 4 && CompletedDungeons[2] == true)
                        {
                            _currentWeapon = "WaterBall";
                            break;
                        }

                        WeaponOptNum++;                         // increment the option by one, go back through loop.
                    }

                    ChangeWeapon();                     // Change the weapon and set objects
                    mainID.RegisterSelectPress = false; // Only allow one press of select or S key/button at a time.
                }
            }



            /// Player Movement and Overworld/Dungeon Section Exits

            if (_allowEntityDirChange == true && _allowEntityMovement == true && _entityPos == _drawPos)
            {             // If movement is allowed and player's coordinates are valid.
                if (state.IsButtonDown(Buttons.LeftThumbstickUp) || Keyboard.GetState().IsKeyDown(Keys.Up) || state.IsButtonDown(Buttons.LeftThumbstickDown) || Keyboard.GetState().IsKeyDown(Keys.Down) ||
                    state.IsButtonDown(Buttons.LeftThumbstickLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || state.IsButtonDown(Buttons.LeftThumbstickRight) ||
                    Keyboard.GetState().IsKeyDown(Keys.Right))
                {                                                                // If any movement key is currently being pressed
                    timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds; // add time to time since last frame
                    Animation(gameTime, ref timeSinceLastFrame);                 // Call animation function

                    // use information from CheckExit function if a value was returned
                    if (checkExit == "EXIT U" || checkExit == "EXIT D" || checkExit == "EXIT L" || checkExit == "EXIT R")
                    {
                        if (_inOverworld == true)
                        {
                            _previousOWSec     = new Vector2((int)_currentOWSec.X, (int)_currentOWSec.Y); // set previous overworld section
                            areaPoly.ChangeSec = true;                                                    // changing section
                            areaPoly.GeneratePreStructure((int)_previousOWSec.X, (int)_previousOWSec.Y);  // Generate the structure of the previous section
                            _visitedOWSections[(int)_previousOWSec.X, (int)_previousOWSec.Y] = true;      // the player has now visited the section
                        }

                        if (_inDungeon == true)
                        {
                            _previousDUNSec    = new Vector2((int)_currentDUNSec.X, (int)_currentDUNSec.Y); // set previous dungeon section
                            areaPoly.ChangeSec = true;                                                      // changing section
                            areaPoly.GeneratePreStructure((int)_previousDUNSec.X, (int)_previousDUNSec.Y);  // Generate the structure of the previous section
                            // the player has now visited the section, check which dungeon number section is in.
                            if (_currentDungeonNumber == 1)
                            {
                                _visitedDUN1Sections[(int)_previousDUNSec.X, (int)_previousDUNSec.Y] = true;
                            }
                            if (_currentDungeonNumber == 2)
                            {
                                _visitedDUN2Sections[(int)_previousDUNSec.X, (int)_previousDUNSec.Y] = true;
                            }
                            if (_currentDungeonNumber == 3)
                            {
                                _visitedDUN3Sections[(int)_previousDUNSec.X, (int)_previousDUNSec.Y] = true;
                            }
                        }
                    }
                }


                // MOVING BETWEEN SECTIONS OF THE OVERWORLD OR DUNGEONS

                // Direction depending on button pressed.

                if (state.IsButtonDown(Buttons.LeftThumbstickUp) || Keyboard.GetState().IsKeyDown(Keys.Up)) // this is the d-pad on some controllers
                {
                    _orientation = 'U';                                                                     // player is facing upwards

                    if (checkExit == "EXIT U")                                                              // player exits the overworld section up
                    {
                        if (_inOverworld == true)
                        {
                            _currentOWSec = new Vector2((int)_currentOWSec.X, (int)_currentOWSec.Y - 1);                             // move upwards by a section
                        }

                        if (_inDungeon == true)
                        {
                            _currentDUNSec = new Vector2((int)_currentDUNSec.X, (int)_currentDUNSec.Y - 1);                             // move upwards by a section
                        }

                        _entityPos = new Vector2(_entityPos.X, 670 - _Height);  // Set location player will spawn in the new section

                        areaPoly.ChangeDirection = 'U';                         // which direction is the new section in.
                    }

                    if (checkMove == false && checkEnemyCollision == false && mainID.GameOver == false)
                    {
                        _entityPos = new Vector2(_entityPos.X, _entityPos.Y - playerSpeed);                         // allow the player to move upwards 3 pixels at a time for each call of function
                    }
                }


                else if (state.IsButtonDown(Buttons.LeftThumbstickDown) || Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    _orientation = 'D';

                    if (checkExit == "EXIT D")                     // player exits the overworld section down
                    {
                        if (_inOverworld == true)
                        {
                            _currentOWSec = new Vector2((int)_currentOWSec.X, (int)_currentOWSec.Y + 1);                             // move downwards by a section
                        }

                        if (_inDungeon == true)
                        {
                            _currentDUNSec = new Vector2((int)_currentDUNSec.X, (int)_currentDUNSec.Y + 1);                             // move downwards by a section
                        }

                        _entityPos = new Vector2(_entityPos.X, 126);                         // Set location player will spawn in the new section
                        areaPoly.ChangeDirection = 'D';
                    }

                    if (checkMove == false && checkEnemyCollision == false && mainID.GameOver == false)
                    {
                        _entityPos = new Vector2(_entityPos.X, _entityPos.Y + playerSpeed);
                    }
                }

                else if (state.IsButtonDown(Buttons.LeftThumbstickLeft) || Keyboard.GetState().IsKeyDown(Keys.Left))
                {
                    _orientation = 'L';

                    if (checkExit == "EXIT L")                     // player exits the overworld section left
                    {
                        if (_inOverworld == true)
                        {
                            _currentOWSec = new Vector2((int)_currentOWSec.X - 1, (int)_currentOWSec.Y);                             // move left by a section
                        }

                        if (_inDungeon == true)
                        {
                            _currentDUNSec = new Vector2((int)_currentDUNSec.X - 1, (int)_currentDUNSec.Y);                             // move left by a section
                        }

                        _entityPos = new Vector2(680, _entityPos.Y);                         // Set location player will spawn in the new section
                        areaPoly.ChangeDirection = 'L';
                    }


                    if (checkMove == false && checkEnemyCollision == false && mainID.GameOver == false)
                    {
                        _entityPos = new Vector2(_entityPos.X - playerSpeed, _entityPos.Y);
                    }
                }

                else if (state.IsButtonDown(Buttons.LeftThumbstickRight) || Keyboard.GetState().IsKeyDown(Keys.Right))
                {
                    _orientation = 'R';

                    if (checkExit == "EXIT R")                     // player exits the overworld section right
                    {
                        if (_inOverworld == true)
                        {
                            _currentOWSec = new Vector2((int)_currentOWSec.X + 1, (int)_currentOWSec.Y);                             // move right by a section
                        }

                        if (_inDungeon == true)
                        {
                            _currentDUNSec = new Vector2((int)_currentDUNSec.X + 1, (int)_currentDUNSec.Y);                             // move right by a section
                        }

                        _entityPos = new Vector2(30, _entityPos.Y);                         // Set location player will spawn in the new section
                        areaPoly.ChangeDirection = 'R';
                    }

                    if (checkMove == false && checkEnemyCollision == false && mainID.GameOver == false)
                    {
                        _entityPos = new Vector2(_entityPos.X + playerSpeed, _entityPos.Y);
                    }
                }
            }

            _allowEntityDirChange = true;

            /// END OF PLAYER MOVEMENT AND SECTION EXITS



            // PLAYER WEAPON FIRE

            if (_allowWeaponFire == true && areaPoly.ChangeSec == false && mainID.GameOver == false)
            {
                _timeSincePlayerWeaponFire += gameTime.ElapsedGameTime.TotalMilliseconds;                 // add time to player weapon fire


                if (state.IsButtonDown(Buttons.A) || Keyboard.GetState().IsKeyDown(Keys.B))                 // A button is Keys.B on controller used for development
                {
                    if (_newPlayerWeaponFire == true)
                    {
                        _timeSincePlayerWeaponFire = 0;                         // reset timer
                        _playerWeaponFiring        = true;
                        _drawWeapon = true;
                        if (_currentWeapon == "Sword")
                        {
                            _playerWeapon.SetWeaponCoordinates(_entityPos);                             // set the weapons coordinates to fire from the players location
                            _playerWeapon.SetWeaponOrientation(_orientation);                           // Set the weapon ordientation in the direction the player is facing
                        }

                        if (_currentWeapon == "Seed")
                        {
                            _playerWeapon.SetWeaponCoordinates(_entityPos);                             // set the weapons coordinates to fire from the players location
                            _playerWeapon.SetWeaponOrientation(_orientation);                           // Set the weapon ordientation in the direction the player is facing
                        }

                        if (_currentWeapon == "FireBall")
                        {
                            _playerWeapon.SetWeaponCoordinates(_entityPos);                             // set the weapons coordinates to fire from the players location
                            _playerWeapon.SetWeaponOrientation(_orientation);                           // Set the weapon ordientation in the direction the player is facing
                        }

                        if (_currentWeapon == "WaterBall")
                        {
                            _playerWeapon.SetWeaponCoordinates(_entityPos);                             // set the weapons coordinates to fire from the players location
                            _playerWeapon.SetWeaponOrientation(_orientation);                           // Set the weapon ordientation in the direction the player is facing
                        }
                    }
                }


                // Fire Player Weapon
                if (_timeSincePlayerWeaponFire <= 410 && _playerWeaponFiring == true)
                {
                    _newPlayerWeaponFire = false;

                    _playerWeapon.FireWeapon();                     // Fire the weapon

                    // Set coordinates of player weapon based on direction
                    if (_playerWeapon.GetWeaponOrientation() == 'U')
                    {
                        _playerWeapon.SetWeaponCoordinates(new Vector2(_playerWeapon.GetWeaponCoordinates().X, _playerWeapon.GetWeaponCoordinates().Y - 7));
                    }

                    if (_playerWeapon.GetWeaponOrientation() == 'D')
                    {
                        _playerWeapon.SetWeaponCoordinates(new Vector2(_playerWeapon.GetWeaponCoordinates().X, _playerWeapon.GetWeaponCoordinates().Y + 7));
                    }

                    if (_playerWeapon.GetWeaponOrientation() == 'L')
                    {
                        _playerWeapon.SetWeaponCoordinates(new Vector2(_playerWeapon.GetWeaponCoordinates().X - 7, _playerWeapon.GetWeaponCoordinates().Y));
                    }

                    if (_playerWeapon.GetWeaponOrientation() == 'R')
                    {
                        _playerWeapon.SetWeaponCoordinates(new Vector2(_playerWeapon.GetWeaponCoordinates().X + 7, _playerWeapon.GetWeaponCoordinates().Y));
                    }
                }
                if (_timeSincePlayerWeaponFire > 400 && _timeSincePlayerWeaponFire <= 450 && _playerWeaponFiring == true)                 // stop displaying and firing weapon
                {
                    _playerWeaponFiring = false;
                    _drawWeapon         = false;
                }
                if (_timeSincePlayerWeaponFire > 500 && _playerWeaponFiring == false) // weapon cooldown
                {
                    _timeSincePlayerWeaponFire = 0;                                   // reset
                    _newPlayerWeaponFire       = true;
                }
            }
        }
コード例 #15
0
        public void Update(GameTime gameTime, AreaInterface areaInt, Player mainPlayer, InformationDisplay mainID)
        {
            Random R = new Random();                          // Random generator

            for (int i = 0; i < areaInt.EnemyList.Count; i++) // goes through the EnemyList which has the objects of all the enimies in an area.
            {
                List <EnemyInterface> EnemyList = areaInt.EnemyList;

                Rectangle WeaponRect = EnemyList[i].EnemyWeapon.GetWeaponRect();


                /// Enemy Weapons

                if (EnemyList[i].EnemyWeapon.WeaponFireTimeMax != 0)                                                                           // maximum weapon fire time cannot be 0
                {
                    EnemyList[i].EnemyWeapon.WeaponFireTime = EnemyList[i].EnemyWeapon.WeaponFireTime + gameTime.ElapsedGameTime.Milliseconds; // Increment weapon fire time
                }

                if (areaInt.EnemyList[i].EnemyWeapon.WeaponFireTime > 0 && areaInt.EnemyList[i].EnemyWeapon.WeaponFireTime <= areaInt.EnemyList[i].EnemyWeapon.WeaponFireTimeMax)
                {
                    areaInt.EnemyList[i].DrawWeapon = true;                     // Draw the enemies weapon

                    // Set the weapon coordinates to the position of the enemy depending on direction.
                    if (EnemyList[i].EnemyWeapon.GetWeaponOrientation() == 'U')
                    {
                        EnemyList[i].EnemyWeapon.SetWeaponCoordinates(new Vector2(areaInt.EnemyList[i].EnemyWeapon.GetWeaponCoordinates().X, EnemyList[i].EnemyWeapon.GetWeaponCoordinates().Y - 7));
                    }

                    if (EnemyList[i].EnemyWeapon.GetWeaponOrientation() == 'D')
                    {
                        EnemyList[i].EnemyWeapon.SetWeaponCoordinates(new Vector2(EnemyList[i].EnemyWeapon.GetWeaponCoordinates().X, EnemyList[i].EnemyWeapon.GetWeaponCoordinates().Y + 7));
                    }

                    if (EnemyList[i].EnemyWeapon.GetWeaponOrientation() == 'L')
                    {
                        EnemyList[i].EnemyWeapon.SetWeaponCoordinates(new Vector2(EnemyList[i].EnemyWeapon.GetWeaponCoordinates().X - 7, EnemyList[i].EnemyWeapon.GetWeaponCoordinates().Y));
                    }

                    if (EnemyList[i].EnemyWeapon.GetWeaponOrientation() == 'R')
                    {
                        EnemyList[i].EnemyWeapon.SetWeaponCoordinates(new Vector2(EnemyList[i].EnemyWeapon.GetWeaponCoordinates().X + 7, EnemyList[i].EnemyWeapon.GetWeaponCoordinates().Y));
                    }
                }



                /// Enemy Out of bounds checker

                if (EnemyList[i].DrawCoordinates.X <= 0 && EnemyList[i].DrawCoordinates.X >= 768 && EnemyList[i].DrawCoordinates.Y <= 0 && EnemyList[i].DrawCoordinates.Y >= 720)
                {
                    EnemyList.RemoveAt(i);                     // remove the enemy if it is outside the parameters (coordiante range) of the area
                }


                EnemyList[i].IsMoving = true;                 // Set the enemy to moving status


                // Rectangles drawn around the possible coordinates and the draw coordinates of the enemy
                Rectangle EnemyRectangle     = new Rectangle((int)EnemyList[i].EnemyCoordinates.X, (int)EnemyList[i].EnemyCoordinates.Y, EnemyList[i].Width, EnemyList[i].Height);
                Rectangle EnemyDrawRectangle = new Rectangle((int)EnemyList[i].EnemyCoordinates.X, (int)EnemyList[i].DrawCoordinates.Y, EnemyList[i].Width, EnemyList[i].Height);

                Vector2 TempCoordinates = EnemyList[i].EnemyCoordinates;                 // allows new coordinates to be set in another class

                int eGameTime = EnemyList[i].EnemyHitTime;

                if (EnemyList[i].BeenHit == true)
                {
                    EnemyList[i].EnemyHitTime = (eGameTime + gameTime.ElapsedGameTime.Milliseconds);

                    if (eGameTime > 200)                     // Recovery time over
                    {
                        EnemyList[i].EnemyHitTime = 0;
                        eGameTime            = 0;
                        EnemyList[i].BeenHit = false;
                    }
                }



                /// Enemy Logic and Movement
                bool AllowDirectionChange = EnemyList[i].AllowDirChange;
                bool AllowMovement        = EnemyList[i].AllowMovement;

                // collision checker

                bool checkMove = false;                 // false for no collision


                checkMove = areaInt.checkMoveManager(EnemyRectangle);                 // check if enemy rectangle collides with area structure


                bool checkEnemyAndPlayerCollision = EnemyAndPlayerCollision(i, mainPlayer, areaInt);                 // check collision between enemy and player


                EnemyList[i].EnemyCoordinates = TempCoordinates;                 // Set the preliminary coordinates to the temporary coordinates (possible coordinates to use).

                if (checkMove == false && checkEnemyAndPlayerCollision == false)
                {
                    EnemyList[i].DrawCoordinates = EnemyList[i].EnemyCoordinates;
                }
                if ((checkMove == true || checkEnemyAndPlayerCollision == true) && EnemyList[i].AllowDirChange == true)
                {
                    EnemyList[i].entityReaction(); EnemyList[i].EnemyCoordinates = EnemyList[i].DrawCoordinates;
                }

                EnemyList[i].AllowDirChange = AllowDirectionChange;         // (Dis)Allow the enemy to change direction
                EnemyList[i].AllowMovement  = AllowMovement;                // (Dis)Allow the enemy to move


                EnemyList[i].EnemyGameTime = (EnemyList[i].EnemyGameTime + gameTime.ElapsedGameTime.Milliseconds);


                if (AllowDirectionChange == true)
                {
                    // Change direction at random time interval
                    if (EnemyList[i].EnemyGameTime >= R.Next(1200, 1500))
                    {
                        int orientationNum = R.Next(0, 4);
                        if (orientationNum == 0)
                        {
                            EnemyList[i].Orientation = 'R';
                        }
                        if (orientationNum == 1)
                        {
                            EnemyList[i].Orientation = 'L';
                        }
                        if (orientationNum == 2)
                        {
                            EnemyList[i].Orientation = 'U';
                        }
                        if (orientationNum == 3)
                        {
                            EnemyList[i].Orientation = 'D';
                        }

                        EnemyList[i].EnemyGameTime = 0;
                    }
                }



                EnemyList[i].Update(gameTime, R, checkMove, checkEnemyAndPlayerCollision, mainPlayer, eGameTime); // update each enemy in the list



                EnemyList[i].AllowDirChange = true;

                if (EnemyList[i].Health <= 0)                 // kill enemy if health <= 0
                {
                    mainID.EntityKilled   = true;
                    mainID.KilledLocation = EnemyList[i].DrawCoordinates; // show kill animation
                    EnemyList.RemoveAt(i);                                // remove enemy from list
                }
            }
        }
コード例 #16
0
        /// GenerateItems
        /// Uses information gained previously from the text file, adds items to itemList through a for loop.
        public override void GenerateItems(Player mainPlayer, AreaInterface areaInt, InformationDisplay mainID)
        {
            if (mainID.EraseList == true)
            {
                _itemList.Clear();
                _itemRects.Clear();
                mainID.EraseList = false;
            }


            if (_ItemTypeA != null || _ItemTypeB != null && _ItemAAmount > 0)
            {
                if (_ItemTypeA != null)
                {
                    if (mainID.NewItemList == true)
                    {
                        for (int i = 0; i <= _ItemAAmount; i++)
                        {
                            if (_ItemTypeA == "Coin")
                            {
                                if (mainPlayer.VisitedOWSections[(int)mainPlayer.CurrentOWSec.X, (int)mainPlayer.CurrentOWSec.Y] == false) // if section has not been visited
                                {
                                    _itemList.Add(new Coin());                                                                             // add Coin object to list
                                }
                                else
                                {
                                    _ItemTypeA   = null;
                                    _ItemAAmount = 0;
                                }
                            }

                            if (_ItemTypeA == "Heart")
                            {
                                _itemList.Add(new Heart());                                 // add Heart object to list
                            }

                            if (_ItemTypeA != null)
                            {
                                _itemList[i].DrawItem = true;
                            }
                        }

                        for (int i = 0; i < _itemList.Count; i++)
                        {
                            // Generate random coordinate in bounds.
                            Vector2 coordinates = _itemList[i].ItemGenCoordinate(i, mainPlayer, areaInt);

                            _itemList[i].ItemCoordinates = coordinates;
                        }
                    }
                }

                if (_ItemTypeB != null)
                {
                    if (mainID.NewItemList == true)
                    {
                        for (int i = 0; i <= _ItemBAmount; i++)
                        {
                            if (_ItemTypeB == "Coin")
                            {
                                if (mainPlayer.VisitedOWSections[(int)mainPlayer.CurrentOWSec.X, (int)mainPlayer.CurrentOWSec.Y] == false) // if section has not been visited
                                {
                                    _itemList.Add(new Coin());                                                                             // add Coin object to list
                                }
                                else
                                {
                                    _ItemTypeB   = null;
                                    _ItemBAmount = 0;
                                }
                            }

                            if (_ItemTypeB == "Heart")
                            {
                                _itemList.Add(new Heart());                                 // add Heart object to list
                            }

                            if (_ItemTypeB != null)
                            {
                                _itemList[i].DrawItem = true;
                            }
                        }

                        for (int i = 0; i < _itemList.Count; i++)
                        {
                            // Generate random coordinate in bounds.
                            Vector2 coordinates = _itemList[i].ItemGenCoordinate(i, mainPlayer, areaInt);

                            _itemList[i].ItemCoordinates = (coordinates);
                        }
                    }
                }

                mainID.NewItemList = false;
            }
        }
コード例 #17
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;
                        }
                    }
                }
            }
        }
コード例 #18
0
ファイル: Area.cs プロジェクト: TheMattSykes/ChevronShards
 public virtual void GenerateItems(Player mainPlayer, AreaInterface areaInt, InformationDisplay mainID)
 {
 }