private IEnumerator RoundEnding() { // Clear the winner from the previous round. m_RoundWinner = null; // See if there is a winner now the round is over. m_RoundWinner = GetRoundWinner(); // If there is a winner, increment their score. if (m_RoundWinner != null) { m_RoundWinner.wins++; } // Now the winner's score has been incremented, see if someone has one the game. m_GameWinner = GetGameWinner(); // Get a message based on the scores and whether or not there is a game winner and display it. RpcUpdateMessage(EndMessage(0)); //notify client they should disable tank control RpcEndRound(); // Wait for the specified length of time until yielding control back to the game loop. yield return(m_EndWait); }
/// <summary> /// Adds the player. /// </summary> /// <param name="player">Player.</param> /// <param name="playerNumber">Player number.</param> /// <param name="color">Color.</param> /// <param name="name">Name.</param> static public void AddPlayer(GameObject player, int playerNumber, Color color, string name) { Debug.LogFormat("Player '{0}' joined the game.", playerNumber); NetworkTankManager tankManager = new NetworkTankManager(); tankManager.instance = player; tankManager.playerNumber = playerNumber; tankManager.playerColor = color; tankManager.playerName = name; tankManager.Setup(); tanks.Add(tankManager); }
/// <summary> /// Removes the player. /// </summary> /// <param name="player">Player.</param> public void RemovePlayer(GameObject player) { NetworkTankManager toRemove = null; foreach (var tank in tanks) { if (tank.instance == player) { toRemove = tank; break; } } if (toRemove != null) { tanks.Remove(toRemove); Debug.LogFormat("Player '{0}' leaves the game.", player); } }