Ejemplo n.º 1
0
    public void TakeDamage(int damage, GameObject attacker = null)
    {
        if (gameObject.GetComponent <TroopClass> () == null)
        {
            Death();
        }
        health      -= damage;
        damageTaken += damage;
        gameObject.GetComponent <TroopClass> ().anim.SetTrigger("GetHit");

        if (healthBar != null)
        {
            healthBar.color = Color.Lerp(Color.white, Color.red, damageTaken / 100);
        }

        if (health <= 0)
        {
            Death();
        }

        // On non-player controlled characters, for now they just attack anybody that hits them
        if (!tc.pc)
        {
            tc.SetCombatTarget(attacker);
        }
    }
Ejemplo n.º 2
0
 public static void SetAttackTarget(TroopClass troop)
 {
     if (target != null)
     {
         troop.SetCombatTarget(target);
     }
 }