//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); } }
//TEMP void Awake() { //TEMP ProtoHealth(); if (this.CompareTag(enemyTag) && this.transform.name == "Head") { this.zomboHealth = this.transform.parent.GetComponent <ZomboHealth>(); this.bodyPart = 2; } else if (this.CompareTag(enemyTag)) //checking if attached gameObject is a Zombo and then ref. { this.zomboHealth = this.GetComponent <ZomboHealth>(); this.bodyPart = 1; } }