Example #1
0
        // 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;
                }
            }
        }
        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
                }
            }
        }