/// <summary> /// On play we trigger the selected fade event /// </summary> /// <param name="position"></param> /// <param name="feedbacksIntensity"></param> protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f) { if (Active) { _position = GetPosition(position); _fadeType = FadeType; if (!NormalPlayDirection) { if (FadeType == FadeTypes.FadeIn) { _fadeType = FadeTypes.FadeOut; } else if (FadeType == FadeTypes.FadeOut) { _fadeType = FadeTypes.FadeIn; } } switch (_fadeType) { case FadeTypes.Custom: MMFadeEvent.Trigger(FeedbackDuration, TargetAlpha, Curve, ID, IgnoreTimeScale, _position); break; case FadeTypes.FadeIn: MMFadeInEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position); break; case FadeTypes.FadeOut: MMFadeOutEvent.Trigger(FeedbackDuration, Curve, ID, IgnoreTimeScale, _position); break; } } }
/// <summary> /// Waits for a short time and then loads the specified level /// </summary> /// <returns>The level co.</returns> /// <param name="levelName">Level name.</param> protected virtual IEnumerator GotoLevelCo(string levelName) { if (Players != null && Players.Count > 0) { foreach (Character player in Players) { player.Disable(); } } MMFadeInEvent.Trigger(OutroFadeDuration, FadeCurve); if (Time.timeScale > 0.0f) { yield return(new WaitForSeconds(OutroFadeDuration)); } // we trigger an unPause event for the GameManager (and potentially other classes) TopDownEngineEvent.Trigger(TopDownEngineEventTypes.UnPause, null); if (string.IsNullOrEmpty(levelName)) { LoadingSceneManager.LoadScene("StartScreen"); } else { LoadingSceneManager.LoadScene(levelName); } }
/// <summary> /// Describes the events happening after the initial delay has passed /// </summary> /// <param name="collider"></param> protected virtual void AfterInitialDelay(GameObject collider) { if (TriggerFade) { MMFadeInEvent.Trigger(FadeOutDuration, FadeTween, FaderID, false, LevelManager.Instance.Players[0].transform.position); } }
/// <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(); }
protected virtual IEnumerator TeleportEnd() { if (FadeToBlack) { if (TeleportCamera) { LevelManager.Instance.LevelCameraController.FollowsPlayer = false; } MMFadeInEvent.Trigger(FadeDuration); yield return(new WaitForSeconds(FadeDuration)); if (TeleportCamera) { LevelManager.Instance.LevelCameraController.TeleportCameraToTarget(); LevelManager.Instance.LevelCameraController.FollowsPlayer = true; } MMFadeOutEvent.Trigger(FadeDuration); } else { if (TeleportCamera) { LevelManager.Instance.LevelCameraController.TeleportCameraToTarget(); } } }
protected virtual IEnumerator TeleportSequence(GameObject collider) { BeforeFadeIn(collider); if (FadeToBlack) { MMFadeInEvent.Trigger(FadeDuration, FaderCurve, FaderID, false, collider.transform.position); FadeInComplete(collider); yield return(new WaitForSeconds(FadeDuration)); } else { FadeInComplete(collider); } if (FadeToBlack) { yield return(new WaitForSeconds(BetweenFadeDuration)); } AfterFadePause(collider); if (FadeToBlack) { MMFadeOutEvent.Trigger(FadeDuration, FaderCurve, FaderID, false, collider.transform.position); } AfterFadeOut(collider); }
/// <summary> /// Gets the player to the specified level /// </summary> /// <param name="levelName">Level name.</param> public virtual void GotoLevel(string levelName) { CorgiEngineEvent.Trigger(CorgiEngineEventTypes.LevelEnd); MMGameEvent.Trigger("Save"); MMFadeInEvent.Trigger(OutroFadeDuration); StartCoroutine(GotoLevelCo(levelName)); }
/// <summary> /// Coroutine that kills the player, stops the camera, resets the points. /// </summary> /// <returns>The player co.</returns> protected virtual IEnumerator SoloModeRestart() { if ((PlayerPrefabs.Count() <= 0) && (SceneCharacters.Count <= 0)) { yield break; } // if we've setup our game manager to use lives (meaning our max lives is more than zero) if (GameManager.Instance.MaximumLives > 0) { // we lose a life GameManager.Instance.LoseLife(); // if we're out of lives, we check if we have an exit scene, and move there if (GameManager.Instance.CurrentLives <= 0) { TopDownEngineEvent.Trigger(TopDownEngineEventTypes.GameOver, null); if ((GameManager.Instance.GameOverScene != null) && (GameManager.Instance.GameOverScene != "")) { LoadingSceneManager.LoadScene(GameManager.Instance.GameOverScene); } } } MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing); MMFadeInEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position); yield return(new WaitForSeconds(OutroFadeDuration)); yield return(new WaitForSeconds(RespawnDelay)); GUIManager.Instance.SetPauseScreen(false); GUIManager.Instance.SetDeathScreen(false); MMFadeOutEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position); MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing); if (CurrentCheckpoint == null) { CurrentCheckpoint = InitialSpawnPoint; } if (Players[0] == null) { InstantiatePlayableCharacters(); } if (CurrentCheckpoint != null) { CurrentCheckpoint.SpawnPlayer(Players[0]); } _started = DateTime.UtcNow; // we send a new points event for the GameManager to catch (and other classes that may listen to it too) TopDownEnginePointEvent.Trigger(PointsMethods.Set, 0); TopDownEngineEvent.Trigger(TopDownEngineEventTypes.RespawnComplete, Players[0]); yield break; }
/// <summary> /// Gets the player to the specified level /// </summary> /// <param name="levelName">Level name.</param> public virtual void GotoLevel(string levelName, bool fadeOut = true) { CorgiEngineEvent.Trigger(CorgiEngineEventTypes.LevelEnd); MMGameEvent.Trigger("Save"); if (fadeOut) { if (Players.Count > 0) { MMFadeInEvent.Trigger(OutroFadeDuration, FadeTween, FaderID, true, Players[0].transform.position); } else { MMFadeInEvent.Trigger(OutroFadeDuration, FadeTween, FaderID, true, Vector3.zero); } } StartCoroutine(GotoLevelCo(levelName, fadeOut)); }
/// <summary> /// On play we trigger the selected fade event /// </summary> /// <param name="position"></param> /// <param name="attenuation"></param> protected override void CustomPlayFeedback(Vector3 position, float attenuation = 1.0f) { if (Active) { _position = GetPosition(position); switch (FadeType) { case FadeTypes.Custom: MMFadeEvent.Trigger(Duration, TargetAlpha, Curve, ID, IgnoreTimeScale, _position); break; case FadeTypes.FadeIn: MMFadeInEvent.Trigger(Duration, Curve, ID, IgnoreTimeScale, _position); break; case FadeTypes.FadeOut: MMFadeOutEvent.Trigger(Duration, Curve, ID, IgnoreTimeScale, _position); break; } } }
protected override IEnumerator TeleportEnd() { if (FadeToBlack) { //if (TeleportCamera) //{ // LevelManager.Instance.LevelCameraController.FollowsPlayer = false; //} MMFadeInEvent.Trigger(FadeDuration); yield return(new WaitForSeconds(FadeDuration)); //if (TeleportCamera) //{ // LevelManager.Instance.LevelCameraController.TeleportCameraToTarget (); // LevelManager.Instance.LevelCameraController.FollowsPlayer = true; //} MMFadeOutEvent.Trigger(FadeDuration); } else { if (TeleportCamera) { LevelManager.Instance.LevelCameraController.TeleportCameraToTarget(); } } foreach (var vCam in virtualCameras.ToList()) { vCam.Priority = 10; } activeCam.Priority = activeCam.Priority + 10; //LevelManager.Instance.GetComponent<FollowPlayer>().SetActiveCamera(); //LevelManager.Instance.GetComponent<FollowPlayer>().SetActiveCamera(); }
/// <summary> /// What happens when the main button is pressed /// </summary> public virtual void ButtonPressed() { MMFadeInEvent.Trigger(FadeOutDuration, Tween); // if the user presses the "Jump" button, we start the first level. StartCoroutine(LoadFirstLevel()); }