예제 #1
0
 public override void TakeDamage(float damage, PlayerCombat.Attacks attackType)
 {
     guardTime = 0; // reset guard time on hit
     base.TakeDamage(damage, attackType);
 }
예제 #2
0
 public override void TakeDamage(float damage, PlayerCombat.Attacks attackType)
 {
     base.TakeDamage(damage, attackType);
 }
예제 #3
0
    /// <summary>
    /// Deals HP damage to this enemy
    /// </summary>
    /// <param name="damage">Amout of HP damage the enemy will take</param>
    public virtual void TakeDamage(float damage, PlayerCombat.Attacks attackType)
    {
        //Only actually take damage if your guard is down
        if (guardStacks == 0)
        {
            hp -= damage;
            //Flag as dead if out of HP
            if (hp <= 0)
            {
                //Flag as dead
                alive = false;
                //Play death sound effect
                SoundManager.PlaySound(soundEffect_Death, this.gameObject);
                //Get outta here to avoid wasting time on the other code
                return;
            }
            else
            {
                //play non-death sound effect
                SoundManager.PlaySound(soundEffect_Hit, this.gameObject);
            }
            hitsTakenRecently++;                        // increment number of recent hits taken
            increasedReactionWindowTimer = initialIRWT; // reset IRWT
            CancelOrHitStun(true);
            hitFlashTimer = 0.6f;
            damageTimer   = 0.2f;
        }

        //Get out of stun if your guard was broken and you're taking damage
        //        if (guardBroken)
        if (enemyState == EnemyStates.Stunned || enemyState == EnemyStates.Knockback)
        {
            //Reset stun
            stunTime = 0f;
            ResetCombatStates();
            Debug.Log("attack after guard break @ " + Time.fixedTime);
        }

        //Flag encounter if not yet flagged
        if (!inEncounter)
        {
            //If encounter is assigned, tell it to start an encounter
            if (encounter)
            {
                encounter.GetComponent <Encounter>().StartEncounter(this.faction);
            }
            else
            {
                //TODO: What if the enemy isn't attached to an encounter?????
                Debug.Log("Encounter object not yet assigned to this enemy!");
            }
        }
        else
        {
            if (alliedWithPlayer)
            {
                //Add to current aggression if allied with the player
                enemyMan.EncounterAggressionCurrent += damage;
            }
        }

        //If guard up...
        if (guardStacks > 0)
        {
            //If hit by thrust...
            if (attackType == PlayerCombat.Attacks.Thrust)
            {
                //Remove stack, and if that was the last one...
                if (--guardStacks <= 0)
                {
                    //Break their guard
                    BreakGuard(2f);
                    guarding = false;
                }
            }
            //if hit by slash...
            else if (attackType == PlayerCombat.Attacks.Slash)
            {
                //Play the rebound sound effect
                SoundManager.PlaySound(SoundManager.SoundEffects.PlayerSlashDeflected, player);
            }
        }

        // if not dead, try a reaction if not already trying one
        //        if (!guarding && !dodging && !counterattacking && !guardBroken)
        if (!guarding && !dodging && !counterattacking && enemyState != EnemyStates.Stunned && enemyState != EnemyStates.Knockback)
        {
            React();
        }
    }