private IEnumerator BlinkRoutine(int duration) { int interval = duration / 2; visible = true; while (visible) { _alpha = 0; DrawableTweener.TweenColorAlpha(this, 0, 255, interval, Easing.Equation.Linear); while (_alpha < 255) { UpdateAlpha(); yield return(null); } _alpha = 255; DrawableTweener.TweenColorAlpha(this, 255, 0, duration, Easing.Equation.Linear); while (_alpha > 0) { UpdateAlpha(); yield return(null); } } }
private IEnumerator IncorrectFlashPickupsOrderSequence(FlashbackPickup flashbackPickup) { //Message to player GameHud.Instance.ShowTextBox(Settings.Flashback_Pickups_Incorrect_Order_Message); //Disable all indicators GameHud.Instance.MemoriesHudPanel.DisableAllIndicators(); yield return(new WaitForMilliSeconds(1000)); _collectedFlashPickupsNames.Clear(); _level.Player.InputEnabled = true; //Wait for player get out of the last pickedup to reenable all while (flashbackPickup.HitTest(_level.Player)) { yield return(null); } yield return(new WaitForMilliSeconds(Settings.Default_AlphaTween_Duration)); flashbackPickup.visible = true; DrawableTweener.TweenSpriteAlpha(flashbackPickup, 0, 1, Settings.Default_AlphaTween_Duration); FlashbackPickupsManager.Instance.EnableFlashbackPickups(); }
private IEnumerator PlayCoinsExplosionRoutine(GameObject target, float offSetX, float offSetY) { int time = 0; int duration = 1200; yield return(null); _cartoonCoinsExplosion.SetActive(true); target.AddChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetXY(0 + offSetX, 0 + offSetY); _cartoonCoinsExplosion.alpha = 1f; DrawableTweener.TweenSpriteAlpha(_cartoonCoinsExplosion, 1, 0, duration - 500, Easing.Equation.QuadEaseOut, 500); while (time < duration) { float fFrame = Mathf.Map(time, 0, duration, 0, _cartoonCoinsExplosion.frameCount - 1); int frame = Mathf.Round(fFrame) % _cartoonCoinsExplosion.frameCount; _cartoonCoinsExplosion.SetFrame(frame); time += Time.deltaTime; yield return(null); } yield return(new WaitForMilliSeconds(200)); target.RemoveChild(_cartoonCoinsExplosion); _cartoonCoinsExplosion.SetActive(false); }
public HistoryPickUp(string pHistoryImageFileName, string filename, int cols, int rows, int frames = -1, bool keepInCache = false, bool addCollider = true) : base(filename, cols, rows, frames, keepInCache, addCollider) { _historyImageFileName = pHistoryImageFileName; _trigger = new TriggerBehavior(this); DrawableTweener.Blink(this, 1, 0.5f, 600); }
void IHasTrigger.OnEnterTrigger(GameObject other) { Console.WriteLine($"{this}: OnEnterTrigger -> {other}"); GameSoundManager.Instance.PlayFx(Settings.History_Pickedup_SFX, Settings.History_Pickedup_SFX_Volume); DrawableTweener.TweenSpriteAlpha(this, 1, 0, 200, Easing.Equation.QuadEaseOut, 0, () => { GameHud.Instance.ShowHistoricHud(_historyImageFileName); this.Destroy(); }); }
public OilPickUp(int newOilType, string poilImageFileName, string filename, int cols, int rows, int frames = -1, bool keepInCache = false, bool addCollider = true) : base(filename, cols, rows, frames, keepInCache, addCollider) { _oilImageFileName = poilImageFileName; DrawableTweener.Blink(this, 1, 0.5f, 600); max = 100; _oilType = newOilType; //RandomizeSpawn(_oilType); }
public void Show(GameObject target, Vector2 pos, Vector2 offset2) { _target = target; _offset = pos; _offset2 = offset2; this.SetScaleXY(1f, 1f); this.alpha = 1; DrawableTweener.TweenScale(this, Vector2.one, Vector2.one * 2, 400, () => { parent?.RemoveChild(this); _target = null; }); }
private IEnumerator CorrectFlashPickupsOrderSequence(FlashbackPickup flashbackPickup) { yield return(new WaitForMilliSeconds(1000)); var hiddenRoomCover = HiddenRoomCoverManager.Instance.HiddenRoomCover; var hiddenCollider = HiddenRoomCoverManager.Instance.HiddenRoomCoverCollider; DrawableTweener.TweenSpriteAlpha(hiddenRoomCover, 1, 0, 1000, Easing.Equation.QuadEaseOut); GameSoundManager.Instance.PlayFx(Settings.Hidden_Room_Revealed_SFX); yield return(new WaitForMilliSeconds(1400)); hiddenCollider.Enabled = false; _level.Player.InputEnabled = true; }
private void EnablePickup(FlashbackPickup pickup) { pickup.Enabled = true; DrawableTweener.TweenSpriteAlpha(pickup, 0, 1, Settings.Default_AlphaTween_Duration, () => { pickup.Blink(); }); DrawableTweener.TweenScale(pickup, Vector2.one, Vector2.one * 1.1f, Settings.Default_AlphaTween_Duration / 2, () => { DrawableTweener.TweenScale(pickup, Vector2.one * 1.1f, Vector2.one, Settings.Default_AlphaTween_Duration / 2, () => { pickup.collider.Enabled = true; }); }); }
private IEnumerator FadeInOutRoutine(int time, OnFinished onFinished) { instance.visible = true; //instance._alpha = 0; instance.alpha = 0; int interval = time / 2; DrawableTweener.TweenColorAlpha(instance, 0, 1, interval, Easing.Equation.CubicEaseOut); yield return(new WaitForMilliSeconds(interval)); DrawableTweener.TweenColorAlpha(instance, 1, 0, interval, Easing.Equation.CubicEaseOut); onFinished?.Invoke(); yield return(new WaitForMilliSeconds(interval)); Destroy(); }
private IEnumerator PlayerPickedupFlashblackRoutine(FlashbackPickup flashbackPickup, bool showPanel) { GameHud.Instance.ResetFlashbackButton.collider.Enabled = false; //Show FlashbackHud if (showPanel) { yield return(FlashbackHudRoutine(flashbackPickup.FlashbackData.Name)); GameHud.Instance.ResetFlashbackButton.SetActive(false); //Fadeout Music if has one and a property to close it if (FlashBackTriggersManager.Instance.FlashTriggersMap.TryGetValue(flashbackPickup.FlashbackData.Name, out var flashTrigger)) { var closeMusicBool = flashTrigger.FlashbackTriggerData.GetBoolProperty("close_music", false); if (closeMusicBool) { GameSoundManager.Instance.FadeOutCurrentMusic(Settings.Flashbacks_Music_Fadein_Duration); GameSoundManager.Instance.FadeInMusic(Settings.Base_Music, Settings.Background_Music_Volume, Settings.Flashbacks_Music_Fadein_Duration); } } } var flashName = flashbackPickup.FlashbackData.Name; bool alreadyInList = _collectedFlashPickupsNames.Contains(flashName); if (!alreadyInList) { _collectedFlashPickupsNames.Add(flashName); if (flashName == "final flashback") { CoroutineManager.StopAllCoroutines(flashbackPickup); DrawableTweener.TweenSpriteAlpha(flashbackPickup, flashbackPickup.alpha, 0, Settings.Default_AlphaTween_Duration, () => { flashbackPickup.Enabled = false; }); GameHud.Instance.ShowTextBox("Game Over"); Console.WriteLine($"{this} go to END"); } else { //Change Indicator if (int.TryParse(flashName.Replace("flashback ", ""), out var flashIndex)) { GameHud.Instance.MemoriesHudPanel.EnableIndicator(_collectedFlashPickupsNames.Count - 1); } //The last flashback pickedup is not disabled because we need to test the collision with player //to re-enable it only after player exit the trigger //So make it invisible if (_collectedFlashPickupsNames.Count >= _totalFlashbacks) { _lastPicked = flashbackPickup; CoroutineManager.StopAllCoroutines(flashbackPickup); DrawableTweener.TweenSpriteAlpha(flashbackPickup, flashbackPickup.alpha, 0, Settings.Default_AlphaTween_Duration); yield return(CheckPickupsCollectedOrderSquence(flashbackPickup)); } else { flashbackPickup.collider.Enabled = false; CoroutineManager.StopAllCoroutines(flashbackPickup); DrawableTweener.TweenSpriteAlpha(flashbackPickup, flashbackPickup.alpha, 0, Settings.Default_AlphaTween_Duration, () => { flashbackPickup.Enabled = false; }); GameHud.Instance.ResetFlashbackButton.SetActive(true); } } } _level.Player.InputEnabled = true; }
public void FadeOut(int duration = 1000) { DrawableTweener.TweenColorAlpha(this, 255, 0, duration, Easing.Equation.CubicEaseOut); CoroutineManager.StartCoroutine(UpdateFadeOut(), this); }
public void Blink() { DrawableTweener.Blink(this, 1, 0.5f, Settings.Default_AlphaTween_Duration); }
static void BlinkOut(Sprite s, float from, float to, int duration) { DrawableTweener.TweenSpriteAlpha(s, from, to, duration, Easing.Equation.QuadEaseIn, 0, () => { BlinkIn(s, to, from, duration); }); }