Exemplo n.º 1
0
    void TryCapture(Transform other)
    {
        try {
            if (other.gameObject.transform.root.gameObject.GetComponent <FlagManager>().hasFlag)
            {
                other.gameObject.transform.root.gameObject.GetComponent <FlagManager>().hasFlag = false;

                Transform[] allChildren = other.gameObject.transform.root.gameObject.GetComponentsInChildren <Transform>();

                foreach (Transform child in allChildren)
                {
                    if (child.tag == "Flag")
                    {
                        Destroy(child.gameObject);
                    }
                }

                if (other.gameObject.transform.root.tag == "aiTeam1")
                {
                    scoreBoard.UpdateCaptures(1);
                }
                else
                {
                    scoreBoard.UpdateCaptures(2);
                }

                FlagManager flagManager = other.gameObject.transform.root.gameObject.GetComponent <FlagManager>();
                flagManager.ReturnFlag();
                flagManager.WaypointManager.GetComponent <FlagWaypoints>().SetLocationState(LocationState.goToFlag);
            }
        } catch {
        }
    }