Ejemplo n.º 1
0
        /// <summary>
        /// Will update the given enemy character.
        /// </summary>
        private void updateEnemy(Character.Enemy enemy)
        {
            //if the character is jumping right
              if (enemy.isJumpingRight())
              {
            enemy.setRightMove();
              }
              //or if the character is jumping left
              else if (enemy.isJumpingLeft())
              {
            enemy.setLeftMove();
              }
              //if the player is jumping
              if (enemy.isJumping() == true)
              {
            //if the player has reached the max jumping height
            if (enemy.jumpHeightReached())
            {
              //then begin their decent
              enemy.fall();
            }
            //otherwise, the player is still jumping
            else
            {
              enemy.jump();
            }
              }
              //or if the player is falling
              else if (enemy.isFalling() == true)
              {
            //make them fall
            enemy.fall();
              }

              //for character alive right now
              foreach (Character.Character character in this.aliveCharacters())
              {
            //if they are within view distance of this enemy
            if (character.Equals(enemy) == false && enemy.canSee(character) == true)
            {
              //then update this enemy accordingly
              enemy.react(character);
            }
              }
              enemy.Personality().update();
        }