コード例 #1
0
ファイル: AIBehaviors.cs プロジェクト: gary9716/NTU_CGHW2
        /// <summary>
        /// Tells the AI that it got hit and it will subtract the amount of health passed from its' total health
        /// </summary>
        public void GotHit(float damage)
        {
            // We don't want to enable this state if the FSM is dead
            GotHitState gotHitState = GetState <GotHitState>();

            if (gotHitState != null && gotHitState.CanGetHit(this))
            {
                SubtractHealthValue(damage * GetDamageMultiplier());

                if (gotHitState.CoolDownFinished())
                {
                    ChangeActiveState(gotHitState);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Tells the AI that it got hit and it will subtract the amount of health passed from its' total health
        /// </summary>
        public void Damage(float damage)
        {
            // We don't want to enable this state if the FSM is dead
            GotHitState gotHitState = GetState <GotHitState>();

            if (gotHitState != null && gotHitState.CanGetHit(this))
            {
                float totalDamage = damage * GetDamageMultiplier();
                SubtractHealthValue(totalDamage);
                Debug.Log("Got " + totalDamage + " damage");

                if (gotHitState.CoolDownFinished())
                {
                    ChangeActiveState(gotHitState);
                }
            }
        }