/// <summary> /// A coroutine used to handle the finish level sequence /// </summary> /// <returns></returns> protected virtual IEnumerator GoToNextLevelCoroutine() { // we trigger a fade if needed if (TriggerFade && (DelayBeforeTransition > 0f)) { MMFadeInEvent.Trigger(DelayBeforeTransition, FadeTween, FaderID, false, LevelManager.Instance.Players[0].transform.position); } // we freeze time if needed if (FreezeTime) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true); } // we freeze our character if needed if (FreezeCharacter && (_character != null)) { _character.Freeze(); } // we wait for the duration of the specified delay yield return(_delayWaitForSeconds); // finally we move to the next level GoToNextLevel(); }
public override bool Use() { base.Use(); MMInventoryEvent.Trigger(MMInventoryEventType.InventoryCloseRequest, null, this.name, null, 0, 0); MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeSpeed, Duration, true, 5f, false); return(true); }
/// <summary> /// Pauses the game or unpauses it depending on the current state /// </summary> public virtual void Pause(PauseMethods pauseMethod = PauseMethods.PauseMenu) { if ((pauseMethod == PauseMethods.PauseMenu) && _inventoryOpen) { return; } // // if time is not already stopped // if (Time.timeScale>0.0f) // { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true); Instance.Paused = true; if ((GUIManager.Instance != null) && (pauseMethod == PauseMethods.PauseMenu)) { GUIManager.Instance.SetPause(true); _pauseMenuOpen = true; SetActiveInventoryInputManager(false); } if (pauseMethod == PauseMethods.NoPauseMenu) { _inventoryOpen = true; } // } // else // { // UnPause(pauseMethod); // CorgiEngineEvent.Trigger(CorgiEngineEventTypes.UnPause); // } LevelManager.Instance.ToggleCharacterPause(); }
/// <summary> /// this method resets the whole game manager /// </summary> public virtual void Reset() { Points = 0; MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Set, 1f, 0f, false, 0f, false); Paused = false; GUIManager.Instance.RefreshPoints(); PointsOfEntry.Clear(); }
/// <summary> /// Starts the time scale modification /// </summary> public virtual void TimeControlStart() { if (Cooldown.Ready()) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeScale, Duration, LerpTimeScale, LerpSpeed, true); Cooldown.Start(); _timeControlled = true; } }
/// <summary> /// On update, we unfreeze time if needed /// </summary> public override void ProcessAbility() { base.ProcessAbility(); Cooldown.Update(); if ((Cooldown.CooldownState != MMCooldown.CooldownStates.Consuming) && _timeControlled) { _timeControlled = false; MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); } }
/// <summary> /// Modifies the timescale /// </summary> public virtual void ControlTime() { if (Mode == Modes.ExitBased) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeScale, Duration, LerpTimeScale, LerpSpeed, true); } else { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeScale, Duration, LerpTimeScale, LerpSpeed, false); } }
/// <summary> /// Asks the Game Manager to change the time scale for a specified duration. /// </summary> /// <returns>The time.</returns> protected virtual IEnumerator ChangeTime() { // we send a new time scale event for the GameManager to catch (and other classes that may listen to it too) MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeSpeed, Duration, false, 0f, false); GUIManager.Instance.SetTimeSplash(true); // we multiply the duration by the timespeed to get the real duration in seconds yield return(_changeTimeWFS); GUIManager.Instance.SetTimeSplash(false); gameObject.SetActive(false); }
/// <summary> /// On game over, freezes time and displays the game over screen /// </summary> /// <returns></returns> protected virtual IEnumerator GameOver() { yield return(new WaitForSeconds(2f)); if (WinnerID == "") { WinnerID = "Player1"; } MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true); _gameOver = true; TopDownEngineEvent.Trigger(TopDownEngineEventTypes.GameOver, null); }
/// <summary> /// Describes the events happening after the fade out is complete, so at the end of the teleport sequence /// </summary> protected virtual void SequenceEnd(GameObject collider) { if (FreezeCharacter && (_player != null)) { _player.UnFreeze(); } if (FreezeTime) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); } }
/// <summary> /// Unpauses the game /// </summary> public virtual void UnPauseGame() { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); Instance.Paused = false; if (GUIManager.Instance != null) { GUIManager.Instance.SetPause(false); _pauseMenuOpen = false; SetActiveInventoryInputManager(true); } LevelManager.Instance.ToggleCharacterPause(); }
public override void TriggerExitAction(GameObject collider) { base.TriggerExitAction(collider); if (Mode == Modes.ExitBased) { if (!CheckConditions(collider)) { return; } MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); } }
/// <summary> /// If we're in game over state, checks for input and restarts the game if needed /// </summary> protected virtual void CheckForGameOver() { if (_gameOver) { if ((Input.GetButton("Player1_Jump")) || (Input.GetButton("Player2_Jump")) || (Input.GetButton("Player3_Jump")) || (Input.GetButton("Player4_Jump"))) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Reset, 1f, 0f, false, 0f, true); LoadingSceneManager.LoadScene(SceneManager.GetActiveScene().name); } } }
/// <summary> /// Describes the events happening after the fade out is complete, so at the end of the teleport sequence /// </summary> protected virtual void SequenceEnd(Collider2D collider) { if (FreezeCharacter && (_player != null)) { _player.UnFreeze(); } if (FreezeTime) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); } SequenceEndFeedback?.PlayFeedbacks(); }
/// <summary> /// Asks the Game Manager to change the time scale for a specified duration. /// </summary> /// <returns>The time.</returns> protected virtual IEnumerator ChangeTime() { // we send a new time scale event for the GameManager to catch (and other classes that may listen to it too) MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeSpeed, Duration, false, 0f, false); GUIManager.Instance.SetTimeSplash(true); // we multiply the duration by the timespeed to get the real duration in seconds yield return(_changeTimeWFS); GUIManager.Instance.SetTimeSplash(false); // we re enable the sprite and collider, and desactivate the object gameObject.GetComponent <SpriteRenderer> ().enabled = true; gameObject.GetComponent <CircleCollider2D> ().enabled = true; gameObject.SetActive(false); }
/// <summary> /// Unpauses the game /// </summary> public virtual void UnPause(PauseMethods pauseMethod = PauseMethods.PauseMenu) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); Instance.Paused = false; if ((GUIManager.Instance != null) && (pauseMethod == PauseMethods.PauseMenu)) { GUIManager.Instance.SetPause(false); _pauseMenuOpen = false; SetActiveInventoryInputManager(true); } if (_inventoryOpen) { _inventoryOpen = false; } }
/// <summary> /// Pauses the game /// </summary> public virtual void PauseGame() { if (_inventoryOpen) { return; } MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true); Instance.Paused = true; if (GUIManager.Instance != null) { GUIManager.Instance.SetPause(true); _pauseMenuOpen = true; SetActiveInventoryInputManager(false); } LevelManager.Instance.ToggleCharacterPause(); }
/// <summary> /// When exiting, and if needed, we reset the time scale /// </summary> /// <param name="collider"></param> protected override void TriggerExit(GameObject collider) { base.TriggerExit(collider); if (Mode == Modes.ExitBased) { Character character = collider.gameObject.GetComponentNoAlloc <Character>(); CharacterButtonActivation characterButtonActivation = collider.gameObject.GetComponentNoAlloc <CharacterButtonActivation>(); if (!CheckConditions(character, characterButtonActivation)) { return; } MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false); } }
/// <summary> /// Describes the events happening before the initial fade in /// </summary> /// <param name="collider"></param> protected virtual void SequenceStart(GameObject collider) { ActivateZone(); if (CameraMode == CameraModes.TeleportCamera) { MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing); } if (FreezeTime) { MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0f, 0f, false, 0f, true); } if (FreezeCharacter && (_player != null)) { _player.Freeze(); } }