Example #1
0
    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;
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     currentArmor = myTowerShieldScript.getCurrentArmor();
     armor.text   = "" + currentArmor;
     if (currentArmor > 0)
     {
         armor.enabled = true;
     }
     else
     {
         armor.enabled = false;
     }
 }