public override void OnStartClient()
        {
            if (LogFilter.Debug)
            {
                Debug.LogFormat("OnStartClient {0}", SceneManager.GetActiveScene().name);
            }

            base.OnStartClient();
            NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

            /*
             *  This demonstrates how to set the parent of the RoomPlayerPrefab to an arbitrary scene object
             *  A similar technique would be used if a full canvas layout UI existed and we wanted to show
             *  something more visual for each player in that layout, such as a name, avatar, etc.
             *
             *  Note: RoomPlayer prefab will be marked DontDestroyOnLoad and carried forward to the game scene.
             *        Because of this, NetworkRoomManager must automatically set the parent to null
             *        in ServerChangeScene and OnClientChangeScene.
             */

            if (room != null && SceneManager.GetActiveScene().name == room.RoomScene)
            {
                gameObject.transform.SetParent(GameObject.Find("Players").transform);
            }
        }
Exemple #2
0
    public override void OnGUI()
    {
        NetworkRoomManager roomManager = NetworkManager.singleton as NetworkRoomManager;

        if (roomManager)
        {
            if (SceneManager.GetActiveScene().name != roomManager.RoomScene)
            {
                return;
            }

            if (!isUIInstantiated)
            {
                lobbyScrollViewContent = GameObject.Find("LobbyScrollViewContent");

                GameObject playerCard = Instantiate(playerLobbyUI) as GameObject;

                if (lobbyScrollViewContent != null)
                {
                    //player joined the lobby
                    isUIInstantiated = true;
                }
            }
            else
            {
                return;
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     networkLobby     = GameObject.FindObjectOfType <NetworkRoomManager>();
     lobbyButton      = GameManager.FindObjectOfType <NetworkLobbyButton>();
     isPressedNetwork = false;
     networkCanvas.SetActive(false);
 }
Exemple #4
0
    private void UpdateDisplayAllPlayers()
    {
        bool allplayersReady    = true;
        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        for (int i = 0; i < room.roomSlots.Count; i++)
        {
            Room ui = room.roomSlots[i].gameObject.GetComponent <Room>();
            ui.UpdateDisplay();

            if (!room.roomSlots[i].readyToBegin)
            {
                allplayersReady = false;
            }
        }

        Debug.Log("All players ready : " + allplayersReady);
        Debug.Log("Index : " + index);
        if (allplayersReady)
        {
            Room ui = room.roomSlots[0].gameObject.GetComponent <Room>();
            ui.ShowStartButton(true);
        }
        else
        {
            Room ui = room.roomSlots[0].gameObject.GetComponent <Room>();
            ui.ShowStartButton(false);
        }
    }
Exemple #5
0
// TODO: This should be updated to return to the game client when that is complete
// Currently it just uses the logic in the game lobby to return to that and if the host presses on it, both players return to the lobby
    void OnClick()
    {
        if (localPlayer && state == State.OVER)
        {
            NetworkRoomManager networkRoomManager = FindObjectOfType <NetworkRoomManager>();
            networkRoomManager.ServerChangeScene(networkRoomManager.RoomScene);
        }
    }
    private IEnumerator EndGame()
    {
        yield return(new WaitForSeconds(10f));

        NetworkRoomManager nm = NetworkManager.singleton as NetworkRoomManager;

        nm.ServerChangeScene(nm.RoomScene);
    }
 // Start is called before the first frame update
 void Start()
 {
     networkLobby        = GameObject.FindObjectOfType <NetworkRoomManager>();
     networkDiscovery    = FindObjectOfType <NetworkDiscovery>();
     networkManager      = FindObjectOfType <NetworkManager>();
     networkDiscoveryHUD = FindObjectOfType <NetworkDiscoveryHUD>();
     InvokeRepeating("Discovery", 0, .5f);
 }
Exemple #8
0
    public void onStartGamelButton()
    {
        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;
        Room ui = room.roomSlots[0].gameObject.GetComponent <Room>();

        ui.ShowStartButton(false);
        room.ServerChangeScene(room.GameplayScene);
    }
Exemple #9
0
    public void readyStarteChanged()
    {
        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        for (int i = 0; i < room.numPlayers; i++)
        {
            if (room.roomSlots[i].isLocalPlayer)
            {
                room.roomSlots[i].CmdChangeReadyState(true);
                //roomSlotPanel[i].GetComponent<Image>().color = Color.green;
            }
        }
        readyButton.GetComponentInChildren <Text>().text = "Canel";
    }
    public void CmdStartGame()
    {
        if (!isHost)
        {
            return;
        }

        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        if (room == null)
        {
            return;
        }

        /*if (!room.allPlayersReady)
         *  return;*/
        room.ServerChangeScene(room.GameplayScene);
    }
Exemple #11
0
    public override void OnGUI()
    {
        if (!showRoomGUI)
        {
            return;
        }

        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        if (room)
        {
            if (!NetworkManager.IsSceneActive(room.RoomScene))
            {
                return;
            }

            DrawPlayerReadyState();
            DrawPlayerReadyButton();
        }
    }
    public void CmdPlayerKickNum(int num)
    {
        // check if player is host
        if (!isHost)
        {
            return;//hack?
        }
        // check if kicking self
        if (index == num)
        {
            return;
        }

        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        if (room == null)
        {
            return;
        }

        room.roomSlots[num].connectionToClient.Disconnect();
    }
Exemple #13
0
    // Update is called once per frame
    void Update()
    {
        if (managerExt == null)
        {
            if (NetworkManager.singleton != null && NetworkManager.singleton is NetworkRoomManager)
            {
                managerExt = NetworkManager.singleton as NetworkRoomManager;
            }

            return;
        }

        if (playerEntity == null)
        {
            playerEntity = RoomPlayerEntity.localRoomPlayer;
        }

        if (Input.GetButtonDown("Cancel"))
        {
            ToggleExitWindow(!youSureWindow.activeInHierarchy);
        }
    }
Exemple #14
0
    void Start()
    {
        PauseMenu.isOn = false;
        GameManager.instance.onGameOverCallback += GameOverScreen;
        PlayerShoot playerShoot = player.GetComponent <PlayerShoot>();

        playerShoot.crosshair   = crosshair;
        playerShoot.sniperScope = scope;

        // Enable room UI
        room = NetworkManager.singleton as NetworkRoomManager;
        if (room)
        {
            if (NetworkManager.IsSceneActive(room.RoomScene))
            {
                readyPanel.SetActive(true);
            }
            room.onRoomStatusChanged += UpdateReadyStatus;
            foreach (NetworkRoomPlayer player in room.roomSlots)
            {
                if (player.readyToBegin)
                {
                    room.playersReady++;
                }
            }
            if (room.countdown > 0)
            {
                UpdateReadyStatus(true, room.countdown);
            }
            else
            {
                UpdateReadyStatus(false);
            }
        }
        player.zombifyPlayer += ZombifyUI;

        StartCoroutine(Countdown((int)GameManager.instance.matchSettings.playerLoadTime));
    }
Exemple #15
0
    public void UpdateDisplay()
    {
        NetworkRoomManager room = NetworkManager.singleton as NetworkRoomManager;

        for (int i = 0; i < roomSlotPanel.Count; i++)
        {
            if (i < room.roomSlots.Count)
            {
                if (room.roomSlots[i].readyToBegin)
                {
                    roomSlotPanel[i].GetComponent <Image>().color = Color.green;
                }
                else
                {
                    roomSlotPanel[i].GetComponent <Image>().color = Color.red;
                }
            }
            else
            {
                roomSlotPanel[i].GetComponent <Image>().color = Color.red;
            }
        }
    }
Exemple #16
0
 private void Start()
 {
     _networkManager = (NetworkRoomManager)NetworkManager.singleton;
 }
Exemple #17
0
 public override void OnStartClient()
 {
     base.OnStartClient();
     nrm = NetworkManager.singleton as NetworkRoomManager;
 }
 private void Start()
 {
     networkRoomManager = NetworkManager.singleton as NetworkRoomManager;
 }