コード例 #1
0
ファイル: HealthContainer.cs プロジェクト: WoodNeck/wagon
    public virtual void Damage(GameObject attackedObject, float amount)
    {
        // Make minimum unit of hp to 0.5
        amount = Mathf.FloorToInt(amount * 2) / 2f;
        hp     = Mathf.Max(hp - amount, 0f);

        bool willDead = (hp <= 0);

        if (willDead)
        {
            if (!actor.isDead)
            {
                actor.GetComponent <Damageable>().Die(attackedObject);
            }
        }
        else
        {
            actor.EventDamaged();
        }
    }