/// <summary> /// Ends the game and moves to the result /// </summary> /// <returns></returns> private IEnumerator GoToEndScene(bool complete) { // if already at end scene, don't move again if (!_ended) { _ended = true; // show the completion message CompletionMessage.SetActive(true); CompletionMessage.GetComponentsInChildren <Image>()[1].sprite = CompletionMessageSprites[complete ? 1 : 0]; // no player is active at this point foreach (var player in _players) { player.ActivePlayer(false, 0); } // stop timeouts _overallLimit.Abort(); _playerLimit.Abort(); yield return(new WaitForSeconds(3)); CompletionMessage.SetActive(false); LaterFader.StartFade(0, 1, ShowLaterMsg); } }
/// <summary> /// Starts the points ticking down for the lap /// </summary> void StartLapTimer_() { // points countdown _lapTimer.Abort(); _lapPoints = MAX_LAP_POINTS; _lapTimer.StartTimer(); // time stopwatch _lapStart = DateTime.Now; }
/// <summary> /// Displays results, then returns to central screen /// </summary> IEnumerator EndGame_() { // only do this once if (!_ended) { _ended = true; AlarmNoise.Stop(); // fire closes in more quickly _fireMoveX *= 10f; _fireMoveY *= 10f; // stop the timer _overallLimit.Abort(); _fastFireMove = true; StartCoroutine(RocketsFly_()); yield return(new WaitForSeconds(END_GAME_TIMEOUT)); _fastFireMove = false; AlarmOverlay.enabled = false; if (_players.Any(p => !p.Died())) { foreach (var v in FireCollidersX) { v.gameObject.SetActive(false); } foreach (var v in FireCollidersY) { v.gameObject.SetActive(false); } SpawnEndRockets_(); // sets the players CameraFollowScript.SetPlayers(_endRockets.Select(r => r.transform).ToList(), FollowDirection.Right); CameraZoomFollowScript.SetPlayers(_endRockets.Where(p => p.Rocket.gameObject.activeInHierarchy).Select(r => r.transform).ToList(), FollowDirection.Right); // move the rockets foreach (var rocket in _endRockets) { rocket.StartMove(); } } else { StartCoroutine(Complete_()); } } }
/// <summary> /// Called when the player selects destination for gold /// </summary> void GoldClaimSelected_(ButtonValues selection) { // stop the time limit _zoneSelectionLimit.Abort(); // store the selection _goldClaimZone = selection; _selectionState = MineSelectionState.None; // show carts and enable movement StartCoroutine(MoveCartsOn()); StartCoroutine(Runaround_()); }
/// <summary> /// Ends the game /// </summary> private IEnumerator EndGame_() { _ended = true; CameraFollowScript.enabled = false; // kill timers _overallLimit.Abort(); _pointCountdown.Abort(); yield return(new WaitForSeconds(2f)); StartCoroutine(Complete_()); }
/// <summary> /// Checks if all players are complete /// </summary> internal void CompleteGame() { // stop the overall time _overallLimit.Abort(); // if there is still a player playing, give them 10 seconds to complete if (_players.Any(p => !p.IsComplete())) { _endingTimer.StartTimer(); } else { // otherwise, just end the game Complete(); _endingTimer.Abort(); } }
/// <summary> /// Fires the ball /// </summary> private IEnumerator Fire_() { _playerLimit.Abort(); // rotate the ball Ball.transform.eulerAngles = Arrow.eulerAngles; // wait for the rotation to apply - required, annoyingly yield return(new WaitForSeconds(0.01f)); // throw the ball Ball.AddRelativeForce(Vector2.up * FIRE_FORCE * Arrow.localScale.y); // delay before setting the ball as active, so the velocity check does not apply immediately yield return(new WaitForSeconds(0.1f)); BallScript.Started(_overarm, Arrow.localScale.y, _windDirection); }
/// <summary> /// Ends the game /// </summary> private IEnumerator EndGame_() { _ended = true; CameraFollowScript.enabled = false; // kill timers _overallLimit.Abort(); _pointCountdown.Abort(); // hide the UI UI.SetActive(false); yield return(new WaitForSeconds(1)); // move players to correct position SetEndPositions_(); yield return(new WaitForSeconds(2f)); StartCoroutine(CallNextPlayer()); }
/// <summary> /// Pauses to display the joke, then resets card /// </summary> private IEnumerator Reset() { // stop the player timer _playerLimit.Abort(); // get the active player (before they are no longer active) var activePlayer = _players.Where(p => p.ActivePlayer()).FirstOrDefault(); // no player is active at this point foreach (var player in _players) { player.ActivePlayer(false, 0); } yield return(new WaitForSeconds(2)); // if the answer is correct... if (_selectedCards[0] != null && _selectedCards[1] != null && _selectedCards[0].GetJoke() == _selectedCards[1].GetJoke()) { CorrectAudio.Play(); // disable both cards foreach (var card in _selectedCards) { card.Remove(); } // add a joke to the players list activePlayer?.JokeEarned(_selectedCards.First().GetJoke()); // if none remaining, end game if (!CardsRemaining_()) { StartCoroutine(GoToEndScene(true)); } // current player can stay on if (activePlayer != null) { SetActivePlayer(activePlayer.GetPlayerIndex()); } else { ShowCharacterWheel(); } } else { // if wrong, flip cards back foreach (var card in _selectedCards) { card?.FlipBack(); } IncorrectAudio.Play(); yield return(new WaitForSeconds(1)); // next player ShowCharacterWheel(); } // clear out the selection for (int i = 0; i < _selectedCards.Length; i++) { _selectedCards[i] = null; } //reset texts foreach (var txt in NoteBookTexts) { txt.text = ""; } }