Пример #1
0
        private void OnLoadedGameScene(Scene scene, LoadSceneMode mode)
        {
            if (scene.buildIndex != 1)
            {
                Debug.LogError("Loaded Scene that wasn't Game scene width buildIndex " + scene.buildIndex);
                return;
            }

            CurrentScene     = (MultiplayerRacerScenes)scene.buildIndex; //set current scene to game scene build index(should be 1)
            CurrentGamePhase = GamePhase.SETUP;
            SetReady(false);                                             //reset ready value for usage in game scene

            //now that currentScene is updated, we set our canvas reference
            UI = helper.GetCanvasReference(CurrentScene);
            Debug.LogError("loaded");
            //and set it up
            Room room = PhotonNetwork.CurrentRoom;

            UI.SetupRoomInfo(PhotonNetwork.NickName, room);
            room.IsOpen = false; //New players cannot join the game if the game scene has been loaded

            //update players in game values and tell others buffered to setup game scene
            PV.RPC("UpdatePlayersInGameScene", RpcTarget.MasterClient, true);

            //unsubscribe from scene loaded event
            SceneManager.sceneLoaded -= OnLoadedGameScene;
        }
Пример #2
0
        private void AttachUI(MultiplayerRacerScenes scene)
        {
            switch (scene)
            {
            case MultiplayerRacerScenes.LOBBY:
                UI = GameObject.FindGameObjectWithTag("Canvas")?.GetComponent <LobbyUI>();
                ((LobbyUI)UI).SetupConnectButton(OnConnectButtonClick);
                break;

            case MultiplayerRacerScenes.GAME:
                UI = GameObject.FindGameObjectWithTag("Canvas")?.GetComponent <GameUI>();
                break;

            default:
                break;
            }
        }
Пример #3
0
 private void Start()
 {
     UI = helper.GetCanvasReference(CurrentScene);
 }