コード例 #1
0
        void PostGameUpdate()
        {
            int currentPlayerCount = CustomNetworkManager.Instance.ConnectedPlayers.Count;

            // Reset everything, send everyone back to the lobby.
            randomColorArray = new int[0];
            for (int id = 0; id < currentPlayerCount; ++id)
            {
                NetworkVRPlayer player = CustomNetworkManager.Instance.ConnectedPlayers[id];
                if (player != null && player.InGameStatus)
                {
                    player.RpcClearColor();
                    player.SetPlayerInGame(false);
                    player.RpcMoveToLobbySpawn();
                }
            }

            // Remove all Targets from the game
            foreach (GameObject target in targetList)
            {
                NetworkServer.UnSpawn(target);
                DestroyObject(target);
            }
            targetList = new List <GameObject>();

            activeState = GameState.Lobby;
        }
コード例 #2
0
        void PreGameSetupUpdate()
        {
            gameStartTime = serverTime;
            scoreManager.ClearScoreList();

            int currentPlayerCount = CustomNetworkManager.Instance.ConnectedPlayers.Count;

            randomColorArray = Utilities.ColorRandomizer.GetNewRandomColors(currentPlayerCount);

            // Assign colors to players and place them in the game.
            for (int id = 0; id < currentPlayerCount; ++id)
            {
                NetworkVRPlayer player = CustomNetworkManager.Instance.ConnectedPlayers[id];
                if (player != null)
                {
                    player.activeColorIndex = randomColorArray[id];
                    player.SetPlayerInGame(true);
                    player.RpcMoveToGameSpawn();
                    scoreManager.RegisterPlayerToScoreList();
                }
            }

            // Spawn 3 times as many targets as players
            for (int i = 0; i < currentPlayerCount * 3; ++i)
            {
                Vector3    targetPos = GetTargetSpawnManager().GetRandomTargetSpawn();
                GameObject newTarget = Instantiate(targetPrefab, targetPos, Quaternion.identity);
                newTarget.GetComponent <Target>().UpdateActiveColorIndex();

                NetworkServer.Spawn(newTarget);
                targetList.Add(newTarget);
            }

            activeState = GameState.Game;
        }
コード例 #3
0
        public void RegisterNetworkPlayer(NetworkVRPlayer newPlayer)
        {
            Debug.Log("New player joined");

            ConnectedPlayers.Add(newPlayer);

            UpdatePlayerIDs();
        }
コード例 #4
0
 public void ClearAllReadyStates()
 {
     for (int i = 0; i < ConnectedPlayers.Count; ++i)
     {
         NetworkVRPlayer player = ConnectedPlayers[i];
         if (player != null)
         {
             player.ClearReady();
         }
     }
 }