Example #1
0
    private void Update()
    {
        //Check cmmands
        for (int i = receivedCmds.Count - 1; i >= 0; i--)
        {
            Command cTemp = receivedCmds[i];
            if (cTemp is LobbyReadyCmd)
            {
                LobbyReadyCmd c = (LobbyReadyCmd)cTemp;
                isClientReady  = c.isReady;
                G_opponentName = c.opponentName;
                if (isClientReady > 0)
                {
                    startGameButton.GetComponentInChildren <Text>().color = new Color(1, 0, 0);
                    ClientSceneInfo.text =
                        "Client:  " + G_username + " VS " + G_opponentName
                        + " \n Host IP Address " + TargetURL;
                }
                else
                {
                    startGameButton.GetComponentInChildren <Text>().color = new Color(0, 0, 0);
                }

                HostUnitTypes = c.unitTypes;

                MapName       = c.mapName;
                mapImg.sprite = Resources.Load <Sprite>(MapName);
            }
            else if (cTemp is LobbyStartgameCmd)
            {
                LobbyStartgameCmd c = (LobbyStartgameCmd)cTemp;
                MapName       = c.mapName;
                mapImg.sprite = Resources.Load <Sprite>(MapName);
                SceneManager.LoadScene("Client_c");
            }
            // The unprocessed commands are saved for other child of IntersceneBehaviour
            else
            {
                continue;
            }
            receivedCmds.RemoveAt(i);
        }
    }
Example #2
0
 void Update()
 {
     if (AutoPlay.isOffline)
     {
         isClientReady = 1;
         return;
     }
     //Check cmmands
     for (int i = receivedCmds.Count - 1; i >= 0; i--)
     {
         Command cTemp = receivedCmds[i];
         if (cTemp is LobbyReadyCmd)
         {
             LobbyReadyCmd c = (LobbyReadyCmd)cTemp;
             isClientReady   = c.isReady;
             G_opponentName  = c.opponentName;
             ClientUnitTypes = c.unitTypes;    // Client's units
             if (isClientReady > 0)
             {
                 startGameButton.GetComponentInChildren <Text>().color = new Color(0, 0, 0);
                 HostSceneInfo.text =
                     "Host:  " + G_username + " VS " + G_opponentName
                     + " \n Host IP Address " + SelfURL;
             }
             else
             {
                 startGameButton.GetComponentInChildren <Text>().color = new Color(0.5f, 0.5f, 0.5f);
             }
             // return this cmd back to Client for checking
             // Tinaxd added unit type field
             tosendCmds.Add((Command)(new LobbyReadyCmd(isClientReady, G_username, GetHostUnits(), mapList[mapID])));
         }
         else
         {
             continue;
         }
         receivedCmds.RemoveAt(i);
     }
 }