void Update() { if (Input.GetKeyDown(KeyCode.R)) { ShallowGames.GameOver(); } }
public void Play() { if (currentGame != null) { ShallowGames.NewGame(currentGame); } else { Debug.LogWarning("The currentGame is not set. No game to load."); } }
IEnumerator Start() { #if UNITY_EDITOR if (UnityEditor.EditorApplication.isPlaying) #endif { if (ShallowGames.ContainsScore(playerID)) { color = PlayerManager.Instance.GetColor(playerID); SetScore(ShallowGames.GetPlayerScore(playerID).PrevScore); yield return(new WaitForSeconds(1.0f)); SetScore(ShallowGames.GetPlayerScore(playerID).RoundScore); } else { gameObject.SetActive(false); } } }
void Start() { playerText.text = string.Format("Player {0}", playerID + 1); PlayerManager.inputAdded.AddListener(PlayerAdded); PlayerManager.inputRemoved.AddListener(PlayerRemoved); ShallowGames.scoreUpdated.AddListener(ScoreUpdated); #if UNITY_EDITOR if (UnityEditor.EditorApplication.isPlaying) #endif { color = PlayerManager.Instance.GetColor(playerID); if (PlayerManager.Contains(playerID)) { if (Lobby.Instance != null) { PlayerScore playerScore = ShallowGames.GetPlayerScore(playerID); ScoreUpdated(new PlayerScoreUpdate(playerID, playerScore.Score, playerScore.Score)); } notJoinedParent.SetActive(false); joinedParent.SetActive(true); } else { if (Lobby.Instance == null) { notJoinedParent.SetActive(false); joinedParent.SetActive(false); } else { notJoinedParent.SetActive(true); joinedParent.SetActive(false); } } } }
public void PlayGame() { ShallowMusic.Play("UI", 1, BeatValue.Quarter); ShallowGames.NewGame(gameConfig); }
IEnumerator WaitToStart() { yield return(new WaitForSecondsRealtime(0.5f)); Dictionary <int, bool> playersReady = new Dictionary <int, bool>(); foreach (var item in PlayerManager.players) { playersReady.Add(item.Key, false); playerScores[item.Key].Waiting(); } bool startGame = false; while (!startGame) { foreach (var item in PlayerManager.players) { if (item.Value.FirstActionWasPressed) { playersReady[item.Key] = true; playerScores[item.Key].PlayerReady(); startGame = true; foreach (var playerReady in playersReady.Values) { if (!playerReady) { startGame = false; break; } } } } yield return(null); } // we can start game for (int i = 3; i > 0; i--) { ShallowGames.DisplayTitle("Starting in\n" + i); yield return(new WaitForSecondsRealtime(1.0f)); } foreach (var item in PlayerManager.players) { playerScores[item.Key].GameStarted(); } ShallowGames.HideTitle(); gameStarted = true; Time.timeScale = 1.0f; waitingToStartGroup.alpha = 0.0f; while (wait) { yield return(null); } for (float dt = Config.Instance.activeGame.gameLength; dt >= 0; dt -= Time.deltaTime) { string indexStr = Mathf.Ceil(dt).ToString(); //.ToString(dt < 1.0f ? "0.0" : "0"); if (dt <= 3) { ShallowGames.DisplayTitle(indexStr); ShallowGames.SetTimer(""); } else { ShallowGames.SetTimer(indexStr); } yield return(null); } Time.timeScale = 0.0f; ShallowGames.DisplayTitle("Game!"); yield return(new WaitForSecondsRealtime(2.0f)); Time.timeScale = 1.0f; ShallowGames.GameOver(); }