private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "TowerArea") { myTowerScript = other.GetComponent <Tower>(); myTowerScrollScript = other.GetComponent <TowerScroll>(); } if (other.gameObject.tag == "TowerShield") { TowerShield myTowerShieldScript = other.gameObject.GetComponent <TowerShield>(); int currentArmor = myTowerShieldScript.getCurrentArmor(); if (currentArmor >= attack) { //Debug.Log("armor: " + currentArmor + " attack: " + attack); myTowerShieldScript.underAttack(attack); Destroy(gameObject); //myGameController.gameSuspended = false; } else { myTowerShieldScript.underAttack(currentArmor); attack -= currentArmor; } } }
// Start is called before the first frame update void Start() { currentArmor = 0; thornDamage = 0; if (myType == ShieldType.Normal) { myTowerScript = transform.parent.GetComponent <Tower>(); } else { myTowerScript = transform.parent.parent.GetComponent <Tower>(); myTowerShield = transform.parent.gameObject; //offset = transform.localPosition.y - myTowerShield.transform.localPosition.y; offset = -1.0f; myTansform = transform; } myTowerScrollScript = transform.parent.GetComponent <TowerScroll>(); myEnemyScript = GameObject.FindWithTag("Enemy").GetComponent <Enemy>(); }