예제 #1
0
    //Called by Zombo Movement in this version. Can be called from Zombo AI manager in the future
    public void Attack(Transform target) //transform can be optimised
    {
        if (target.gameObject.CompareTag(playerTag))
        {
            PlayerHealth playerHealth = target.GetComponent <PlayerHealth>();

            if (playerHealth != null)
            {
                playerHealth.TakeDamage(zomboAttackDamage);
                attackCount++;
                //playAnim();  (1.06f)
                //playAudio();
            }
            else
            {
                Debug.Log("ERROR: Can't find target health " + this.transform.name);
            }
        }
        else if (target.gameObject.CompareTag(enemyTag)) // ZvZ action BOIS :)
        {
            ZomboHealth zomboHealth = target.GetComponent <ZomboHealth>();
            zomboHealth.ApplyDamage((float)zomboAttackDamage, 1);
        }
        else
        {
            Debug.Log("ERROR: Can't find target health " + this.transform.name);
        }
    }
    public void TakeDamage(float amount)
    {
        if (this.CompareTag(enemyTag))
        {
            zomboHealth.ApplyDamage(amount, bodyPart);
        }
        else
        {
            health -= amount;

            //TEMP
            color = new Color32((byte)(health), 0, 0, 255);
            tempMatHealth.material.color = color;
            //TEMP

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