/// <summary> /// Called once on creation /// </summary> private void Start() { Instance = this; var players = SpawnPlayers_(); FollowScript.SetPlayers(players, FollowDirection.Right); FollowZoomScript.SetPlayers(players, FollowDirection.Right); // initialise the timeout _overallLimit = (TimeLimit)gameObject.AddComponent(typeof(TimeLimit)); _overallLimit.Initialise(TIME_LIMIT, PlayerTickCallback, PlayerTimeoutCallback); // initialise the timeout after a player completes _endingTimer = (TimeLimit)gameObject.AddComponent(typeof(TimeLimit)); _endingTimer.Initialise(10, EndGameTimeoutTick, EndGameTimeout); // start the timer _overallLimit.StartTimer(); // start spawning rocks foreach (var spawner in RockSpawners) { spawner.Enable(); } // spawn initial points SpawnPowerUpBoostsInitial_(); // start randomly spawning points StartCoroutine(SpawnPowerUpBoosts_()); }
/// <summary> /// Starts the game /// </summary> private void StartGame_() { _overallLimit.StartTimer(); _pointCountdown.StartTimer(); _active = true; UpperTransport.StartNoteMovement(); }
/// <summary> /// Starts the game /// </summary> void StartGame_() { _gameRunning = true; // start creating balls StartCoroutine(GenerateBalls_()); // start the timer _overallLimit.StartTimer(); }
/// <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> /// Start the game /// </summary> void StartGame_() { // start all players foreach (var player in _players) { player.Activate(); } // start timer _countdownTimer.StartTimer(); }
/// <summary> /// Randomly selects an influencer from list of players who are yet to have all their turns /// </summary> private IEnumerator SelectInfluencer_() { // briefly wait yield return(new WaitForSeconds(3)); // clear round counts foreach (var pl in _players) { pl.NewRound(); } ResetSpriteImage_(); // show trending panel TrendingPanel.SetActive(true); // flick through each player for (int i = 0; i < 50; i++) { TxtTrendingMessage.text = "@" + _players[i % _players.Count].GetPlayerName(); ImgInfluencer.sprite = CharacterSprites[_players[i % _players.Count].GetCharacterIndex()]; ImgInfluencerBG.color = ColourFetcher.GetColour(i % _players.Count); yield return(new WaitForSeconds(0.1f)); } // ensure the list is empty _playersInZone.Clear(); // pick a random player var r = UnityEngine.Random.Range(0, _remainingTurns.Count); _currentInfluencer = _players[_remainingTurns[r]]; _remainingTurns.RemoveAt(r); // display selection TxtTrendingMessage.text = "@" + _currentInfluencer.GetPlayerName(); ImgInfluencer.sprite = CharacterSprites[_currentInfluencer.GetCharacterIndex()]; ImgInfluencerBG.color = ColourFetcher.GetColour(_currentInfluencer.GetPlayerIndex()); // show zone InfluencerZone.gameObject.SetActive(true); InfluencerZone.SetParent(_currentInfluencer.MovementObject()); InfluencerZone.localPosition = new Vector3(0, 0, 2f); // increase size StartCoroutine(GrowZone_()); // start timer _turnLimit.StartTimer(); _turnRunning = true; StartCoroutine(CheckZone_()); }
/// <summary> /// Begins the game - everyone becomes active /// </summary> void StartGame_() { _active = true; // start the coroutine that spawns batteries throughout the game StartCoroutine(SpawnBatteries()); // start the timer _overallLimit.StartTimer(); _minBatteryWait = 2 + 4 - PlayerManagerScript.Instance.GetPlayerCount(); _maxBatteryWait = 9 - PlayerManagerScript.Instance.GetPlayerCount(); }
/// <summary> /// Sets up all elements for the next shot /// </summary> void SetupNextShot_() { _cancelled = false; PlayerCam.SetActive(false); SetAnimators_("Idle"); ResetPositions_(); _throwIndex++; // if that was the third shot, move to the next player if (_throwIndex > 2) { NextPlayer_(); } else { _playerLimit.StartTimer(); } FinalRoundDescription.SetActive((_roundIndex == 2 && _throwIndex == 2)); ThrowLabel.text = "THROW " + (_throwIndex + 1); }
/// <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> /// Starts a countdown before the race starts /// </summary> /// <returns></returns> IEnumerator StartCountdown_() { for (int i = 3; i > 0; i--) { TxtStartCountdown.text = i.ToString(); yield return(new WaitForSeconds(1)); } TxtStartCountdown.text = ""; // setup action list and show first action foreach (var p in _players) { var marshmallows = FindObjectsOfType <MarshmallowScript>(); var playerMarshmallows = marshmallows.Where(m => m.name.Contains((p.GetPlayerIndex() + 1).ToString())); p.SetActionList(playerMarshmallows.Count() - 1); } // start the timer _overallLimit.StartTimer(); _pointCountdown.StartTimer(); }
/// <summary> /// Callback for when the player reaches the platform position /// </summary> void RunOnCallback() { foreach (var cart in Carts) { cart.SetContents(MineItemDrop.None); } // enable players except the one that needs to run off foreach (var p in _players) { if (p.GetPlayerIndex() != _activePlayerIndex) { p.CanMove(true); } } _selectionState = MineSelectionState.GoldDestination; // start a timeout _zoneSelectionLimit.StartTimer(); TxtCommentary.text = _players[_activePlayerIndex].GetPlayerName() + ":\nIn which cart would you like to place the GOLD?"; }
/// <summary> /// Sets the specified player as active /// </summary> /// <param name="index">The index of the player who is now active</param> public void SetActivePlayer(int index) { if (_ended) { return; } _activePlayerIndex = index; // back to the first one _state = SelectionState.PickingFirst; // set the active player _players[_activePlayerIndex].ActivePlayer(true, 0); // hide spinning wheel SpinWheelScreen.SetActive(false); // restart the player limit time if (CardsRemaining_()) { // restart the player countdown _playerLimit.StartTimer(); } // sets the player display for (int i = 0; i < PlayerDisplays.Length; i++) { var rect = PlayerDisplays[i].GetComponentInChildren <RectTransform>(); rect.offsetMax = new Vector2(i == index ? 125 : 0, rect.offsetMax.y); } // sets the time displays for (int i = 0; i < TxtPlayerTimes.Length; i++) { TxtPlayerTimes[i].gameObject.SetActive(i == index); } }
/// <summary> /// Enables racers, starts timer and begins the race /// </summary> private IEnumerator StartRace_() { CameraLerpController.enabled = true; Leaderboard.SetActive(true); string[] messages = new string[] { "", "Here we go", "Get Ready", "On your marks", "Get set", "Go!" }; // show countdown for (int i = 0; i < StarterLightSprites.Length; i++) { // wait, then update image yield return(new WaitForSeconds(1)); StarterLights.sprite = StarterLightSprites[i]; TxtRemainingTime.text = messages[i]; } _running = true; // enable all players foreach (var player in _players) { player.StartRace(); } yield return(new WaitForSeconds(1)); // start timer _raceTimer.StartTimer(); yield return(new WaitForSeconds(3)); StarterLights.sprite = StarterLightSprites[0]; // start process of spawning power ups StartCoroutine(SpawnPowerups()); StartCoroutine(RotatePowerups()); }
/// <summary> /// Start the game and start the countdown timers /// </summary> private void StartGame() { _overallLimit.StartTimer(); ShowCharacterWheel(); }