/// <summary> /// Returns the character to the state it was in before its current state /// </summary> public virtual void RestorePreviousState() { // we restore our previous state CurrentState = PreviousState; if (TriggerEvents) { MMEventManager.TriggerEvent(new MMStateChangeEvent <T> (this)); } }
/// <summary> /// if the scene name is not null, go to the level /// </summary> public virtual void GoToLevel() { //if (SceneName != "") LevelManager.Instance.GotoLevel(SceneName); if (SceneName != "") { MMEventManager.TriggerEvent(new MMGameEvent("Save")); SceneManager.LoadScene(SceneName, LoadSceneMode.Single); MMEventManager.TriggerEvent(new MMGameEvent("Load")); } }
protected virtual void Swipe() { MMSwipeEvent swipeEvent = new MMSwipeEvent(_swipeDirection, _angle, _length, _firstTouchPosition, _destination); MMEventManager.TriggerEvent(swipeEvent); if (ZoneSwiped != null) { ZoneSwiped.Invoke(swipeEvent); } }
public static void Trigger(float duration, MMTweenType tween, int id = 0, bool ignoreTimeScale = true, Vector3 worldPosition = new Vector3()) { e.ID = id; e.Duration = duration; e.Curve = tween; e.IgnoreTimeScale = ignoreTimeScale; e.WorldPosition = worldPosition; MMEventManager.TriggerEvent(e); }
public static void Trigger(MMTimeScaleMethods timeScaleMethod, float timeScale, float duration, bool lerp, float lerpSpeed, bool infinite) { e.TimeScaleMethod = timeScaleMethod; e.TimeScaleProperty.TimeScale = timeScale; e.TimeScaleProperty.Duration = duration; e.TimeScaleProperty.Lerp = lerp; e.TimeScaleProperty.LerpSpeed = lerpSpeed; e.TimeScaleProperty.Infinite = infinite; MMEventManager.TriggerEvent(e); }
public static void Trigger(MMPossibleSwipeDirections direction, float angle, float length, Vector2 origin, Vector2 destination, float swipeDuration) { e.SwipeDirection = direction; e.SwipeAngle = angle; e.SwipeLength = length; e.SwipeOrigin = origin; e.SwipeDestination = destination; e.SwipeDuration = swipeDuration; MMEventManager.TriggerEvent(e); }
public static void Trigger(float duration, float targetAlpha, MMTween.MMTweenCurve tween = MMTween.MMTweenCurve.LinearTween, int id = 0, bool ignoreTimeScale = true, Vector3 worldPosition = new Vector3()) { e.ID = id; e.Duration = duration; e.TargetAlpha = targetAlpha; e.Curve = tween; e.IgnoreTimeScale = ignoreTimeScale; e.WorldPosition = worldPosition; MMEventManager.TriggerEvent(e); }
/// <summary> /// Toggles the timescale modification /// </summary> protected virtual void ToggleSlowMotion() { TimeAltered = !TimeAltered; if (TimeAltered) { MMEventManager.TriggerEvent(new MMTimeScaleEvent(MMTimeScaleMethods.For, TimescaleModifier, 1f, true, 5f, true)); } else { MMEventManager.TriggerEvent(new MMTimeScaleEvent(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false)); } }
/// <summary> /// Unlocks the achievement, asks for a save of the current achievements, and triggers an MMAchievementUnlockedEvent for this achievement. /// This will usually then be caught by the MMAchievementDisplay class. /// </summary> public virtual void UnlockAchievement() { // if the achievement has already been unlocked, we do nothing and exit if (UnlockedStatus) { return; } UnlockedStatus = true; MMEventManager.TriggerEvent(new MMGameEvent("Save")); MMEventManager.TriggerEvent(new MMAchievementUnlockedEvent(this)); }
/// <summary> /// Instantiates an achievement display prefab and shows it for the specified duration /// </summary> /// <returns>The achievement.</returns> /// <param name="achievement">Achievement.</param> public virtual IEnumerator DisplayAchievement(MMAchievement achievement) { if ((this.transform == null) || (AchievementDisplayPrefab == null)) { yield break; } // we instantiate our achievement display prefab, and add it to the group that will automatically handle its position GameObject instance = (GameObject)Instantiate(AchievementDisplayPrefab.gameObject); instance.transform.SetParent(this.transform, false); // we get the achievement displayer MMAchievementDisplayItem achievementDisplay = instance.GetComponent <MMAchievementDisplayItem> (); if (achievementDisplay == null) { yield break; } // we fill our achievement achievementDisplay.Title.text = achievement.Title; achievementDisplay.Description.text = achievement.Description; achievementDisplay.Icon.sprite = achievement.UnlockedImage; if (achievement.AchievementType == AchievementTypes.Progress) { achievementDisplay.ProgressBarDisplay.gameObject.SetActive(true); } else { achievementDisplay.ProgressBarDisplay.gameObject.SetActive(false); } // we play a sound if set if (achievement.UnlockedSound != null) { MMEventManager.TriggerEvent(new MMSfxEvent(achievement.UnlockedSound)); } // we fade it in and out CanvasGroup achievementCanvasGroup = instance.GetComponent <CanvasGroup> (); if (achievementCanvasGroup != null) { achievementCanvasGroup.alpha = 0; StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 1)); yield return(_achievementFadeOutWFS); StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 0)); } }
/// <summary> /// Changes the current movement state to the one specified in the parameters, and triggers exit and enter events if needed /// </summary> /// <param name="newState">New state.</param> public virtual void ChangeState(T newState) { // if the "new state" is the current one, we do nothing and exit if (newState.Equals(CurrentState)) { return; } // we store our previous character movement state PreviousState = CurrentState; CurrentState = newState; if (TriggerEvents) { MMEventManager.TriggerEvent(new MMStateChangeEvent <T> (this)); } }
/// <summary> /// Returns the character to the state it was in before its current state /// </summary> public virtual void RestorePreviousState() { // if we've chosen to trigger events, we trigger our exit event /*if (TriggerEvents) * { * MMEventManager.TriggerEvent(TargetName+CurrentState.ToString()+"Exit"); * }*/ // we restore our previous state CurrentState = PreviousState; // if we've chosen to trigger events, we trigger our enter event /*if (TriggerEvents) * { * MMEventManager.TriggerEvent(TargetName+CurrentState.ToString()+"Enter"); * }*/ if (TriggerEvents) { MMEventManager.TriggerEvent(new MMStateChangeEvent <T> (this)); } }
public static void Trigger(string sceneName, LoadingStatus status) { e.Status = status; e.SceneName = sceneName; MMEventManager.TriggerEvent(e); }
public static void Trigger(MMSoundManagerAllSoundsControlEventTypes eventType) { e.EventType = eventType; MMEventManager.TriggerEvent(e); }
public static void Trigger(MMAchievement newAchievement) { e.Achievement = newAchievement; MMEventManager.TriggerEvent(e); }
public static void Trigger(float duration) { e.Duration = duration; MMEventManager.TriggerEvent(e); }
public static void Trigger(string newName) { e.EventName = newName; MMEventManager.TriggerEvent(e); }
public static void Trigger(float duration, float targetAlpha) { e.Duration = duration; e.TargetAlpha = targetAlpha; MMEventManager.TriggerEvent(e); }
public static void Trigger(string ability) { e.Ability = ability; MMEventManager.TriggerEvent(e); }
public static void Trigger(AudioClip clipToPlay) { e.ClipToPlay = clipToPlay; MMEventManager.TriggerEvent(e); }
/// <summary> /// A method used from the inspector to test the system /// </summary> protected virtual void TestButtonToSlowDownTime() { MMEventManager.TriggerEvent(new MMTimeScaleEvent(MMTimeScaleMethods.For, 0.5f, 3f, true, 1f, false)); }
public static void Trigger(int id = 0) { e.ID = id; MMEventManager.TriggerEvent(e); }