예제 #1
0
    void OnTriggerStay(Collider other)
    {
        if (other.GetComponent <UnitIdentity> () == null)
        {
            return;
        }

        if (other.GetComponent <UnitIdentity> ().id == GetComponent <UnitIdentity> ().id)
        {
            return;
        }



        if (timer >= AttackSpeed)
        {
            timer = 0;
        }
        else
        {
            return;
        }



        if (other.tag == "anthill")
        {
            if (other.GetComponent <Anthill> ().health <= 0)
            {
                GameObject.Find("Canvas").transform.FindChild("Victory").gameObject.SetActive(true);
            }
            else
            {
                localPlayer.Cmd_dealDamage(gameObject, other.gameObject);
            }

            Debug.Log("anthill detected");
        }


        if (other.tag == "unit")
        {
            if (other.GetComponent <Beatle>())
            {
                other.GetComponent <Animation>().CrossFade("fire");
            }

            if (other.GetComponent <BasicAnt>())
            {
                other.GetComponent <Animation>().CrossFade("ant-bite");
            }
            Debug.Log("works");

            if (localPlayer == null)
            {
                localPlayer = WorldHandler.findLocalPlayer().GetComponent <WorldHandler> ();
            }

            localPlayer.Cmd_dealDamage(gameObject, other.gameObject);
        }

        if (other.GetComponent <UnitIdentity> ().id != GetComponent <UnitIdentity> ().id&& other.GetComponent <Anthill>() == null)
        {
            other.transform.LookAt(transform);
            transform.LookAt(other.transform);
        }
    }