public override void OnStartLocalPlayer() { gameObject.name = "LOCAL Player"; remotePScript.enabled = false; localPScript.enabled = true; CmdSetColor(); score = 0; scored_ThisRound = 0; scored_TimeBonus = 0; scored_FirstBonus = false; scored_WasGuessed = false; AudioManagerScript.instance.PlaySFX(AudioManagerScript.SFXClips.DanceTogether); GUIManagerScript.SetRulesButton(true); GUIManagerScript.SetPregameParent(true); GUIManagerScript.SetSongSetButton(true); SetReady(false); if (isServer) { GUIManagerScript.versionText.text = "v" + versionNum + " Host"; } else { GUIManagerScript.versionText.text = "v" + versionNum + " Client"; } base.OnStartLocalPlayer(); }
public void RpcStartGame(int s) { songID = s; scored_ThisRound = 0; scored_TimeBonus = 0; scored_FirstBonus = false; scored_WasGuessed = false; //playerParent.GetComponent<PlayerParentScript>().Unlock(); // Bullshit code. Temp? Maybe not? // What if player WAS ready, but now that we're actually starting they are no longer? // Too late for them! Let's double check if (!ready) { Assert.IsFalse(ready, "Player wasn't ready, but the server thought they were!"); // Oh noes! What do we do? Let's cheat: SetReady(true); // See buddy, you were ready the whole time, right? } ResetMatch(); if (isLocalPlayer) { GUIManagerScript.SetButton(false); GUIManagerScript.SetBackButton(false); Color clr = ColorScript.GetColor(GetColor()); clr = clr * 0.5f; GUIManagerScript.SetNumberInputFieldColor(clr); GUIManagerScript.ClearNumberInput(); GUIManagerScript.SetSongSetButton(false); //Hacky bullshit for finding which kind of game we're in? GameManagerScript gameManager = FindObjectOfType <GameManagerScript>(); Assert.IsNotNull <GameManagerScript>(gameManager); int index = gameManager.GetSongSet(); AudioManagerScript.instance.StartGameMusic(index); GUIManagerScript.SetClassicGameParent(color, ColorScript.GetColor(color), ColorScript.GetColorName(color)); localPScript.reminded = false; } List <CaptainsMessPlayer> players = GetPlayers(); foreach (CaptainsMessPlayer player in players) { NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>(); if (!nps.isLocalPlayer) { player.GetComponent <NetworkedPlayerScript>().playerButton.SetActive(true); player.GetComponent <NetworkedPlayerScript>().playerButton.GetComponent <Button>().interactable = true; } } }
public void RpcEndGame() { SetReady(false); if (isLocalPlayer) { GUIManagerScript.SetButton(true); GUIManagerScript.SetBackButton(false); AudioManagerScript.instance.EndGameMusic(); AudioManagerScript.instance.PlayRoundEnd(scored_GuessedCorrect); GUIManagerScript.HideClassicGameParent(); GUIManagerScript.SetSongSetButton(true); } }
// Redundant? Possible. But I am not sure // Unity says this is the one to use, yet OnDestroy works and possibly works better? // Let's do both to be safe. new void OnDestroy() { //print("Player was was destroyed"); if (playerButton != null) { Destroy(playerButton); } if (isLocalPlayer) { GUIManagerScript.SetPregameParent(false); GUIManagerScript.SetButton(false); GUIManagerScript.SetRulesButton(false); GUIManagerScript.SetBackButton(false); GUIManagerScript.HideClassicGameParent(); GUIManagerScript.SetSongSetButton(false); if (GUIManagerScript.countdownText != null) { GUIManagerScript.countdownText.enabled = false; } if (AudioManagerScript.instance != null) { AudioManagerScript.instance.StopSFX(); AudioManagerScript.instance.EndGameMusic(); AudioManagerScript.instance.StartMenuMusic(); } } // If this is a client player on the server then OnClientExitLobby will not be called. // Call it here instead. if (networkManager.IsHost() && networkManager.localPlayer != this) { OnClientExitLobby(); } base.OnDestroy(); }