Esempio n. 1
0
    private void Update()
    {
        if (doTheCleanup)
        {
            var clientDictionary = ClientScene.objects;

            GameObject playerOne = null;
            GameObject playerTwo = null;
            foreach (var item in clientDictionary)
            {
                Debug.Log("Key: " + item.Key + " Value: " + item.Value);
                if (item.Value.name.Equals("Player1") || item.Value.name.Equals("player1(Clone)"))
                {
                    playerOne = item.Value.gameObject;
                }
                if (item.Value.name.Equals("Player2") || item.Value.name.Equals("player2(Clone)"))
                {
                    playerTwo = item.Value.gameObject;
                }
            }

            var playerScriptOne = (TriggerScript)playerOne.GetComponent <TriggerScript>();
            playerScriptOne.DoTheCleanup();

            var playerScriptTwo = (TriggerScript)playerTwo.GetComponent <TriggerScript>();
            playerScriptTwo.DoTheCleanup();

            doTheCleanup = false;
        }

        if (globalController == null && ClientScene.objects.Count != 0)
        {
            globalController = (GlobalController)GameObject.Find("GlobalControllerGameObject").GetComponent <GlobalController>();
        }

        if (ClientScene.objects.Count == 4 && !firstCheck)
        {
            var clientDictionary = ClientScene.objects;

            GameObject playerOne = null;
            GameObject playerTwo = null;
            foreach (var item in clientDictionary)
            {
                //Debug.Log("Key: " + item.Key + " Value: " + item.Value);
                if (item.Value.name.Equals("Player1") || item.Value.name.Equals("player1(Clone)"))
                {
                    playerOne = item.Value.gameObject;
                }
                if (item.Value.name.Equals("Player2") || item.Value.name.Equals("player2(Clone)"))
                {
                    playerTwo = item.Value.gameObject;
                }
            }

            var playerScriptOne = (TriggerScript)playerOne.GetComponent <TriggerScript>();
            playerScriptOne.ThisIsYourGlobal(globalController);

            var playerScriptTwo = (TriggerScript)playerTwo.GetComponent <TriggerScript>();
            playerScriptTwo.ThisIsYourGlobal(globalController);

            globalController.ClientCheckedInTrigger();
            globalController.ClientCheckedInTrigger();

            firstCheck = true;
        }
    }