Beispiel #1
0
        public GameObject SpawnPlayerUIPrefab(PlayerNetwork player)
        {
            GameObject newUIPlayer = Instantiate(UIPlayerPrefab, UIPlayerParent);

            newUIPlayer.GetComponent <UIPlayer> ().SetPlayer(player);
            newUIPlayer.transform.SetSiblingIndex(player.playerIndex - 1);

            return(newUIPlayer);
        }
Beispiel #2
0
 public override void OnStartClient()
 {
     if (isLocalPlayer)
     {
         localPlayer = this;
     }
     else
     {
         Debug.Log($"Spawning other player UI Prefab");
         //playerLobbyUI = UIManager.instance.SpawnPlayerUIPrefab (this);
     }
 }
Beispiel #3
0
 public void PlayerDisconnected(PlayerNetwork player, string _matchID)
 {
     for (int i = 0; i < matches.Count; i++)
     {
         if (matches[i].matchID == _matchID)
         {
             int playerIndex = matches[i].players.IndexOf(player.gameObject);
             matches[i].players.RemoveAt(playerIndex);
             roomListManager.FillList(matches[i].players.ToArray(), matches[i].matchID);
             Debug.Log($"Player disconnected from match {_matchID} | {matches[i].players.Count} players remaining");
             /* player.currentMatch = new Match(); */
             if (matches[i].players.Count == 0)
             {
                 Debug.Log($"No more players in Match. Terminating {_matchID}");
                 matches.RemoveAt(i);
                 matchIDs.Remove(_matchID);
                 roomListManager.roomData.RemoveAt(i);
             }
             break;
         }
     }
 }
Beispiel #4
0
        public void BeginGame(string _matchID)
        {
            GameObject newTurnManager = Instantiate(turnManagerPrefab);

            NetworkServer.Spawn(newTurnManager);
            newTurnManager.GetComponent <NetworkMatchChecker> ().matchId = _matchID.ToGuid();
            TurnManager turnManager = newTurnManager.GetComponent <TurnManager> ();

            for (int i = 0; i < matches.Count; i++)
            {
                if (matches[i].matchID == _matchID)
                {
                    matches[i].inMatch = true;
                    foreach (var player in matches[i].players)
                    {
                        PlayerNetwork _player = player.GetComponent <PlayerNetwork> ();
                        _player.StartGame();
                    }
                    break;
                }
            }
        }
Beispiel #5
0
 public void SetPlayer(PlayerNetwork player)
 {
     this.player = player;
     text.text   = "Player " + player.playerIndex.ToString();
 }