コード例 #1
0
ファイル: Enemy.cs プロジェクト: ryanyoshijohn/UnityPortFate
    public override void TakeDamage(Damage damage)
    {
        int random = Random.Range(0, 101);

        /*print(random)*/
        ;
        //print(damage.HitChance);
        print("hit chance: " + damage.HitChance);
        print("dodge: " + Stats.Dodge);
        if (((damage.HitChance - Stats.Dodge) < random))
        {
            FloatingText floatingText = FloatingTextController.CreateFloatingText("MISS", gameObject.transform);
            floatingText.transform.localScale = new Vector3(1.25f, 1.25f);
        }
        else // DID HIT
        {
            FloatingText floatingText = FloatingTextController.CreateFloatingText(damage.DamageAmount.ToString(), gameObject.transform);
            if (damage.DidCrit)
            {
                floatingText.transform.localScale = new Vector3(1.4f, 1.4f);
                floatingText.SetCritColor();
            }
            EnemyMovement.knockable.AddXKnockback(damage.Knockback);
            EnemyMovement.stun.AddStun(damage.Stun);
            HealthDamaged(damage.DamageAmount);
        }
        if (Stats.CurrentHealth <= 0)
        {
            PlayDeathAnim();
        }
    }