예제 #1
0
    public void onReady()
    {
        GameObject[] lobbyPlayers = GameObject.FindGameObjectsWithTag("lobbyplayer");

        // May happen during network delays.
        if (lobbyPlayers.Length <= 0)
        {
            Debug.Log("LOBBY_HUD::onReady: No lobby players found!");
            //FindObjectOfType<NetworkPlayerSelect>().GetComponent<NetworkPlayerSelect>().TryToAddPlayer();
        }

        foreach (GameObject player in lobbyPlayers)
        {
            NetworkLobbyPlayer lobbyPlayer = player.GetComponent <NetworkLobbyPlayer>();

            if (!lobbyPlayer.isLocalPlayer)
            {
                continue;
            }

            if (!lobbyPlayer.readyToBegin)
            {
                lobbyPlayer.SendReadyToBeginMessage();
            }
            else
            {
                lobbyPlayer.SendNotReadyToBeginMessage();
            }

            StartCoroutine(this.initLobbyRoom(0.0f));
        }
    }
예제 #2
0
    public void NotReady()
    {
        SetUpButton(readyButton.GetComponent <_2DContextButton>());
        lobbyPlayer.SendNotReadyToBeginMessage();
        notReadyButton.gameObject.SetActive(false);
        readyButton.gameObject.SetActive(true);

        /*
         * networkMan.mapButton.gameObject.GetComponent<_2DContextButton>().westNeighbor = readyButton.gameObject;
         * networkMan.mapButton.gameObject.GetComponent<_2DContextButton>().eastNeighbor = readyButton.gameObject;
         * networkMan.addPlayerButton.GetComponent<_2DContextButton>().northNeighbor = readyButton.gameObject;
         * networkMan.addPlayerButton.GetComponent<_2DContextButton>().southNeighbor = readyButton.gameObject;
         */
    }
예제 #3
0
 public void ReadyButtonClick()
 {
     if (myPlayer != null)
     {
         if (!ReadyCheck.isOn)
         {
             Debug.Log("Sending ready message!");
             myPlayer.SendReadyToBeginMessage();
         }
         else
         {
             myPlayer.SendNotReadyToBeginMessage();
         }
     }
 }
예제 #4
0
 //Zmiana stanu gotowośći gracza
 public void Ready()
 {
     if (ready == true)
     {
         LobbyPlayer.SendReadyToBeginMessage();
         LobbyPlayer.gameObject.GetComponent <PlayerLobby>().CmdChangeState(ready);
         ready = false;
     }
     else
     {
         LobbyPlayer.SendNotReadyToBeginMessage();
         LobbyPlayer.gameObject.GetComponent <PlayerLobby>().CmdChangeState(ready);
         ready = true;
     }
 }
예제 #5
0
    void Update()
    {
        MainVRMenu.MenuInstance.ClearEachFrame = true;
        ScndVRMenu.MenuInstance.ClearEachFrame = true;

        bool noConnection = (client == null || client.connection == null ||
                             client.connection.connectionId == -1);

        //Debug.Log("NetworkServer.active: " + NetworkServer.active);
        //Debug.Log("IsClientConnected(): " + IsClientConnected());
        //Debug.Log("noConnection: " + noConnection);

        if (!NetworkServer.active && !IsClientConnected() && noConnection)
        {
            if (matchMaker != null)
            {
                if (matchInfo == null)
                {
                    if (matches == null)
                    {
                        MainVRMenu.MenuInstance.RegisterButton("Create Internet Match", () =>
                        {
                            Debug.Log("Create Internet Match");
                            //matchMaker.CreateMatch(matchName, matchSize, true, "", OnMatchCreate);
                            return(false);
                        });
                        MainVRMenu.MenuInstance.RegisterButton("Find Internet Match", () =>
                        {
                            Debug.Log("Find Internet Match");
                            //matchMaker.ListMatches(0, 20, "", OnMatchList);
                            return(false);
                        });
                    }
                    if (matches != null)
                    {
                        if (LastMathCount != matches.Count)
                        {
                            foreach (var match in matches)
                            {
                                MainVRMenu.MenuInstance.RegisterButton(match.name, () =>
                                {
                                    matchName = match.name;
                                    matchSize = (uint)match.currentSize;
                                    //matchMaker.JoinMatch(match.networkId, "", OnMatchJoined);
                                    return(true);
                                });
                            }
                        }

                        LastMathCount = matches.Count;
                    }
                }

                MainVRMenu.MenuInstance.RegisterButton("Restart Match Making", () =>
                {
                    Debug.Log("Restart Match Making");
                    StopMatchMaker();
                    StartMatchMaker();
                    return(false);
                });
            }
        }
        else
        {
            if (MatchInfo != null)
            {
                MatchInfo.text = matchName;
            }

            LobbyPlayer = FindObjectOfType <NetworkLobbyPlayer>();
            if (LobbyPlayer != null)
            {
                MainVRMenu.MenuInstance.RegisterButton("Ready", () =>
                {
                    LobbyPlayer.SendReadyToBeginMessage();
                    return(false);
                });
                MainVRMenu.MenuInstance.RegisterButton("Unready", () =>
                {
                    LobbyPlayer.SendNotReadyToBeginMessage();
                    return(false);
                });
            }
        }
    }