Ejemplo n.º 1
0
        /// <summary>
        /// Update the monster for this frame.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            // start any waiting action immediately
            if ((CombatAction != null) &&
                (CombatAction.Stage == CombatAction.CombatActionStage.NotStarted))
            {
                CombatAction.Start();
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the combatant for this frame.
        /// </summary>
        public virtual void Update(GameTime gameTime)
        {
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // update the combat action
            if (combatAction != null)
            {
                // update the combat action
                combatAction.Update(gameTime);
                // remove the combat action if it is done and set the turn-taken flag
                if (combatAction.Stage == CombatAction.CombatActionStage.Complete)
                {
                    combatAction = null;
                    isTurnTaken  = true;
                }
            }


            // update the combat sprite animation
            CombatSprite.UpdateAnimation(elapsedSeconds);

            // check for death
            if (!IsDeadOrDying && (Statistics.HealthPoints <= 0))
            {
                AudioManager.PlayCue("Death");
                State = RolePlayingGameData.Character.CharacterState.Dying;
            }
            // check for waking up
            else if (IsDeadOrDying && (Statistics.HealthPoints > 0))
            {
                State = RolePlayingGameData.Character.CharacterState.Idle;
            }
            else if (CombatSprite.IsPlaybackComplete)
            {
                if (State == RolePlayingGameData.Character.CharacterState.Hit)
                {
                    State = RolePlayingGameData.Character.CharacterState.Idle;
                }
                else if (State == RolePlayingGameData.Character.CharacterState.Dying)
                {
                    State = RolePlayingGameData.Character.CharacterState.Dead;
                }
            }
        }
        /// <summary>
        /// Choose the next action for the monster.
        /// </summary>
        /// <returns>The chosen action, or null if no action is desired.</returns>
        public CombatAction ChooseAction()
        {
            CombatAction combatAction = null;

            // determine if the monster will use a defensive action
            if ((monster.Monster.DefendPercentage > 0) &&
                (defensiveActions.Count > 0) &&
                (Session.Random.Next(0, 100) < monster.Monster.DefendPercentage))
            {
                combatAction = ChooseDefensiveAction();
            }

            // if we do not have an action yet, choose an offensive action
            combatAction = (combatAction ?? ChooseOffensiveAction());

            // reset the action to the initial state
            combatAction.Reset();

            return(combatAction);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the combatant for this frame.
        /// </summary>
        public virtual void Update(GameTime gameTime)
        {
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // update the combat action
            if (combatAction != null)
            {
                // update the combat action
                combatAction.Update(gameTime);
                // remove the combat action if it is done and set the turn-taken flag
                if (combatAction.Stage == CombatAction.CombatActionStage.Complete)
                {
                    combatAction = null;
                    isTurnTaken = true;
                }
            }


            // update the combat sprite animation
            CombatSprite.UpdateAnimation(elapsedSeconds);

            // check for death
            if (!IsDeadOrDying && (Statistics.HealthPoints <= 0))
            {
                AudioManager.PlayCue("Death");
                State = RolePlayingGameData.Character.CharacterState.Dying;
            }
            // check for waking up
            else if (IsDeadOrDying && (Statistics.HealthPoints > 0))
            {
                State = RolePlayingGameData.Character.CharacterState.Idle;
            }
            else if (CombatSprite.IsPlaybackComplete)
            {
                if (State == RolePlayingGameData.Character.CharacterState.Hit)
                {
                    State = RolePlayingGameData.Character.CharacterState.Idle;
                }
                else if (State == RolePlayingGameData.Character.CharacterState.Dying)
                {
                    State = RolePlayingGameData.Character.CharacterState.Dead;
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Compares the combat actions by their heuristic, in descending order.
 /// </summary>
 public static int CompareCombatActionsByHeuristic(
     CombatAction a, CombatAction b)
 {
     return b.Heuristic.CompareTo(a.Heuristic);
 }
 /// <summary>
 /// Compares the combat actions by their heuristic, in descending order.
 /// </summary>
 public static int CompareCombatActionsByHeuristic(
     CombatAction a, CombatAction b)
 {
     return(b.Heuristic.CompareTo(a.Heuristic));
 }