示例#1
0
        void OnTriggerEnter(Collider other)
        {
            //Debug.Log (other.tag);
            if (other.tag == "Towers")
            {
                T            = other.GetComponentInParent <Tower> ();
                BuildingType = false;
            }
            else if (other.tag == "Castle")
            {
                C            = other.GetComponentInParent <Castle> ();
                BuildingType = true;
                //anim.SetBool ("ToCastle", false);
            }
            if (BuildingType)
            {
                if (C.Health > 0)
                {
                    C.TakeHit(Stats.AttackDamage);
                }
                else
                {
                    Destroy(C.gameObject);
                }
            }
            else
            {
                if (T.Health > 0)
                {
                    T.TakeHit(Stats.AttackDamage);
                }
                else
                {
                    Destroy(T.gameObject);
                }
            }
            //Debug.Log (gameObject.name);
            var exp = Instantiate(explosion, transform.position, transform.rotation);

            //	exp.transform.position = transform.position;
            //	exp.transform.rotation = transform.rotation;
            Destroy(gameObject, 1f);
            Destroy(exp, 3f);
        }