Exemplo n.º 1
0
        private IEnumerator NewRound()
        {
            yield return(new WaitForSecondsRealtime(3));

            foreach (PlayerStatus s in playerStatuses)
            {
                s.RpcSetTextActive(false);
            }
            Debug.Log("coroutine");
            List <GameObject> newPlayers = new List <GameObject>();

            for (int i = 0; i < playerStatuses.Count; i++)
            {
                GameObject obj = Instantiate(lobbyManager.gamePlayerPrefab.gameObject) as GameObject;
                newPlayers.Add(obj);

                // get start position from base class
                Transform startPos = lobbyManager.GetStartPosition();
                if (startPos != null)
                {
                    obj.transform.position = startPos.transform.position;
                    obj.transform.rotation = startPos.rotation;
                }
                else
                {
                    obj.transform.position = startPos.transform.position;
                    obj.transform.rotation = startPos.rotation;
                }
                NetworkServer.ReplacePlayerForConnection(playerStatuses[i].connectionToClient, obj, playerStatuses[i].playerControllerId);
                Destroy(playerStatuses[i].gameObject);
            }
            playerStatuses.Clear();

            foreach (GameObject o in newPlayers)
            {
                playerStatuses.Add(o.GetComponent <PlayerStatus>());
            }
        }