Esempio n. 1
0
    void OnTriggerEnter(Collider obj)
    {
        GameObject coll    = obj.gameObject;
        string     collTag = obj.gameObject.tag;

        if (coll == target)
        {
            if (collTag == "Flag")
            {
                chest   = coll;
                hasFlag = true;
                coll.transform.parent   = transform;
                coll.transform.position = transform.position + new Vector3(0, 3.0f, 0f);
                UpdateGoal(GameObject.Find(tag + " Podium"), -1f);
            }
            else if (coll.name == tag + " Podium")
            {
                ReturnChest();
                GameObject.Find(gameObject.tag + " Team Controller").GetComponent <TeamController>().score++;
                UpdateGoal(null, Mathf.Infinity);
            }
            else if (coll.name == "NPC")
            {
                if (collTag != tag)
                {
                    GameObject  tagged  = coll.gameObject;
                    GoalManager tagGoal = tagged.GetComponent <GoalManager>();

                    if (tagGoal.hasFlag)
                    {
                        tagGoal.ReturnChest();
                    }

                    StartCoroutine("Freeze", coll.gameObject);
                }
                else
                {
                    StartCoroutine("UnFreeze", coll.gameObject);
                }

                UpdateGoal(null, Mathf.Infinity);
            }
        }
    }