// Update is called once per frame void Update() { float time = ((TeamDeathmatch)MultiplayerManager.GetCurrentGamemode()).timeRemaining; if (time < 0) { GetComponent <Text>().text = "Overtime!"; } else { int seconds = (int)(time % 60); GetComponent <Text>().text = (int)(time / 60) + ":" + (seconds >= 10 ? seconds.ToString() : ("0" + seconds)); } }
public void RpcEndGame(short winner, int[] teamScores) { if (!isLocalPlayer) { return; } MultiplayerManager.ClientNotifyGameEnd(winner); //Disable active camera controller, enable death camera controller activeCamera.GetComponent <BoatCameraNetworked>().enabled = false; activeCamera.GetComponent <OrbitalCamera>().enabled = true; gameOver = true; //Set up game-over screen with relevant information GameObject endScreen = GameObject.Find("Canvas(Health)").transform.Find("EndScreen").gameObject; endScreen.SetActive(true); Text teamWin = endScreen.transform.Find("TeamWinText").GetComponent <Text>(); teamWin.gameObject.SetActive(true); teamWin.text = "Team " + MultiplayerManager.GetTeam(winner).teamName + " wins!"; teamWin.color = MultiplayerManager.GetTeam(winner).teamColor; if (winner == team) { endScreen.transform.Find("YouWin").gameObject.SetActive(true); } else { endScreen.transform.Find("YouLose").gameObject.SetActive(true); } Text scoreText = endScreen.transform.Find("FinalScore").GetComponent <Text>(); scoreText.text = "Scores: \n"; for (short i = 0; i < MultiplayerManager.GetCurrentGamemode().NumTeams(); i++) { scoreText.text += MultiplayerManager.GetTeam(i).teamName + ": " + teamScores[i] + "\n"; } //play sounds if (winner == team) { transform.Find("ShipSounds").Find("MatchWin").GetComponent <AudioSource>().Play(); } else { transform.Find("ShipSounds").Find("MatchLose").GetComponent <AudioSource>().Play(); } GameObject.Find("InGame").GetComponent <AudioSource>().volume = 0.1f; InputWrapper.CaptureKeyboard(); InputWrapper.CaptureMouse(); }
void OnGUI() { if (!showGUI) { return; } int xpos = 10 + offsetX; int ypos = 40 + offsetY; int spacing = 24; //This disabled code is what makes the standard buttons for starting/joining a server appear //Uncomment this block if that is desired /*if (!NetworkClient.active && !NetworkServer.active && manager.matchMaker == null) * { * if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Host")) * { * manager.StartHost(); * } * ypos += spacing; * * if (GUI.Button(new Rect(xpos, ypos, 95, 20), "LAN Client")) * { * manager.StartClient(); * } * manager.networkAddress = GUI.TextField(new Rect(xpos + 105, ypos, 95, 20), manager.networkAddress); * ypos += spacing; * * if (GUI.Button(new Rect(xpos, ypos, 200, 20), "LAN Server Only")) * { * manager.StartServer(); * } * ypos += spacing; * } * else * {*/ //Uncomment this code to display the server address and port in the top left /*if (NetworkServer.active) * { * GUI.Label(new Rect(xpos, ypos, 300, 20), "Server: port=" + manager.networkPort); * ypos += spacing; * } * if (NetworkClient.active) * { * GUI.Label(new Rect(xpos, ypos, 300, 20), "Client: address=" + manager.networkAddress + " port=" + manager.networkPort); * ypos += spacing; * }*/ //} //This disabled code was where the player specified name/team in the HUD //Uncomment if that behaviour is desired /*if (NetworkClient.active && !ClientScene.ready) * { * GUI.Label(new Rect(xpos, ypos, 50, 20), "Name: "); * manager.localPlayerName = GUI.TextField(new Rect(xpos + 60, ypos, 140, 20), manager.localPlayerName); * ypos += spacing; * * GUI.Label(new Rect(xpos, ypos, 50, 20), "Team: "); * manager.localPlayerTeam = (Team) GUI.SelectionGrid(new Rect(xpos + 60, ypos, 140, 20), (int)manager.localPlayerTeam, new string[] { "Red", "Blue" }, 2); * ypos += spacing; * if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Join")) * { * manager.SpawnClient(); * } * ypos += spacing; * }*/ //Uncomment this code to show basic player info and stop button in top left /*if (NetworkServer.active || manager.IsClientConnected()) * { * if (ClientScene.ready) * { * GUI.Label(new Rect(xpos, ypos, 300, 20), "Name: " + manager.localPlayerName); * ypos += spacing; * GUI.Label(new Rect(xpos, ypos, 300, 20), "Team: " + manager.localPlayerTeam.ToString()); * ypos += spacing; * } * if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)")) * { * manager.StopHost(); * } * ypos += spacing; * }*/ if (showDebug) { GUI.Label(new Rect(xpos, ypos, 300, 20), "Client?: " + MultiplayerManager.IsClient()); ypos += spacing; GUI.Label(new Rect(xpos, ypos, 300, 20), "Host?: " + MultiplayerManager.IsHost()); ypos += spacing; GUI.Label(new Rect(xpos, ypos, 300, 20), "Server?: " + MultiplayerManager.IsServer()); ypos += spacing; } //***SCORE FEED*** GUI.color = Color.white; if (messageStack.Count > 0) { if (scoreFeedStyle == null) { scoreFeedStyle = new GUIStyle(GUI.skin.label); scoreFeedStyle.fontSize = 20; } ypos = Screen.height / 2; xpos = Screen.width / 2 - 30; foreach (string msg in messageStack) { GUI.Label(new Rect(xpos, ypos, 200, 30), msg, scoreFeedStyle); ypos += 33; } } GUI.color = Color.white; //***SCOREBOARD*** if (showScoreboard) { if (scoreboardStyle == null) { scoreboardStyle = new GUIStyle(GUI.skin.box); scoreboardStyle.normal.background = Texture2D.whiteTexture; } int cellCount = manager.playerList.Count + 2; int cellHeight = Mathf.Clamp(Screen.height / cellCount, 1, Mathf.RoundToInt(Screen.height * 0.1f)); int cellWidth = Mathf.RoundToInt(Screen.width * 0.75f); xpos = Screen.width / 2 - cellWidth / 2; if (cellCount < 20) { ypos = Screen.height / 2 - (cellCount * cellHeight) / 2; } else { ypos = 0; } defaultColor = GUI.backgroundColor; GUI.contentColor = Color.black; for (short i = 0; i < MultiplayerManager.GetCurrentGamemode().NumTeams(); i++) { Team currentTeam = MultiplayerManager.GetTeam(i); Color teamColor = currentTeam.teamColor; GUI.backgroundColor = teamColor; DrawScoreboardRow(xpos, ypos, cellWidth, cellHeight, "Team " + currentTeam.teamName, "Kills/Deaths/Bounty", manager.teamScores[i].ToString()); ypos += cellHeight + 1; foreach (Player player in manager.playerList) { if (player.team == i) { if (player.connectionId == manager.client.connection.connectionId) { GUI.Box(new Rect(xpos, ypos, cellWidth, cellHeight), GUIContent.none, scoreboardStyle); } DrawScoreboardRow(xpos, ypos, cellWidth, cellHeight, player.name, player.kills + "/" + player.deaths + "/" + player.GetBounty(), player.score.ToString()); ypos += cellHeight + 1; } } } GUI.backgroundColor = defaultColor; GUI.contentColor = Color.white; } }