void OnMouseOver(GameObject target, MouseEventType eventType) { _onHoverSprite.SetActive(true); DrawableTweener.TweenSpriteAlpha(_onHoverSprite, _onHoverSprite.alpha, 1, Settings.Default_AlphaTween_Duration); Console.WriteLine($"{this}: over"); }
IEnumerator ShowHistoricImageHudRoutine(string historyFileName) { var flashHud = new HistoricImageHud(historyFileName); AddChild(flashHud); flashHud.SetXY(0, 0); float alphaValue = 1f; //Fade In panel DrawableTweener.TweenSpriteAlpha(flashHud, 0, alphaValue, MyGame.AlphaTweenDuration, Easing.Equation.QuadEaseOut, 0, () => { //Disable player after fade in _level.Player.InputEnabled = false; }); yield return(new WaitForMilliSeconds(MyGame.AlphaTweenDuration)); //Hold execution until ESCAPE pressed while (!Input.GetKeyDown(Key.ESCAPE)) { yield return(null); } //Fadeout Panel DrawableTweener.TweenSpriteAlpha(flashHud, alphaValue, 0, MyGame.AlphaTweenDuration, Easing.Equation.QuadEaseOut, 0, () => { flashHud.Destroy(); }); yield return(new WaitForMilliSeconds(800)); _level.Player.InputEnabled = true; }
void Update() { if (Input.GetKeyDown(Key.ESCAPE)) { if (_currentFlashHud != null && _currentFlashHud.AllowSkipByKey) { CoroutineManager.StopAllCoroutines(_currentFlashHud); var allChilds = _currentFlashHud.GetChildrenRecursive(); foreach (var child in allChilds) { CoroutineManager.StopAllCoroutines(child); } _currentFlashHud.toDestroy = true; DrawableTweener.TweenSpriteAlpha(_currentFlashHud, _currentFlashHud.alpha, 0, Settings.Default_AlphaTween_Duration / 2, () => { HierarchyManager.Instance.LateDestroy(_currentFlashHud); _currentFlashHud = null; }); } } }
public HistoricImageHud(string historyFileName) : base("data/White Texture.png", true, false) { var bg = new EasyDraw(game.width, game.height, false); bg.Clear(Color.FromArgb(0, Color.Black)); AddChild(bg); _mainImage = new Sprite(historyFileName, true, false); AddChild(_mainImage); //_mainImage.scale = 0.5f; _mainImage.SetOriginToCenter(); _mainImage.SetXY(MyGame.HALF_SCREEN_WIDTH, MyGame.HALF_SCREEN_HEIGHT); DrawableTweener.TweenSpriteAlpha(_mainImage, 0, 1, 400, Easing.Equation.CubicEaseOut); var textBg = new EasyDraw(game.width, 30, false); textBg.Clear(Color.Black); AddChild(textBg); textBg.SetXY(0, game.height - 30); var pressToContinueText = new DebugTextBox("Press Esc to continue", game.width, 30, 0xffffff, 0x00010101, CenterMode.Center, CenterMode.Center); AddChild(pressToContinueText); pressToContinueText.SetXY(0, game.height - 30); DrawableTweener.Blink(pressToContinueText, 1, 0, 400); }
void FadeInAndFinish() { DrawableTweener.TweenSpriteAlpha(_fader, 0, 1, Settings.Default_AlphaTween_Duration, () => { Destroy(); _onFinished?.Invoke(); }); }
public void StartGame() { GameSoundManager.Instance.FadeOutCurrentMusic(Settings.Default_AlphaTween_Duration); DrawableTweener.TweenSpriteAlpha(_fader, 0, 1, Settings.Default_AlphaTween_Duration, () => { ((MyGame)game).LoadLevel(); this.Destroy(); }); }
public StartScreen() : base(Settings.StartScreen_Bg_Image, false, false) { GameSoundManager.Instance.PlayMusic(Settings.StartScreen_Music); _fader = new EasyDraw(game.width, game.height, false); _fader.Clear(Color.Black); AddChild(_fader); DrawableTweener.TweenSpriteAlpha(_fader, 1, 0, Settings.Default_AlphaTween_Duration, () => { _lockStart = false; }); }
void OnMouseClick(GameObject target, MouseEventType eventType) { DrawableTweener.TweenSpriteAlpha(_onHoverSprite, _onHoverSprite.alpha, 0, Settings.Default_AlphaTween_Duration / 3, () => { DrawableTweener.TweenSpriteAlpha(_onHoverSprite, _onHoverSprite.alpha, 1, Settings.Default_AlphaTween_Duration / 3); }); FlashbackManager.Instance.ResetMemorySequence(); Console.WriteLine($"{this}: clicked"); }
public PreGameStartScreen(string fileName, string musicFilename, OnFinished onFinished = null) : base(fileName, false, false) { if (!string.IsNullOrWhiteSpace(musicFilename)) { GameSoundManager.Instance.FadeOutCurrentMusic(); GameSoundManager.Instance.PlayMusic(musicFilename); } _fader = new EasyDraw(game.width, game.height, false); _fader.Clear(Color.Black); AddChild(_fader); _onFinished = onFinished; _lockKey = false; DrawableTweener.TweenSpriteAlpha(_fader, 1, 0, Settings.Default_AlphaTween_Duration, () => { //_lockKey = false; }); }
public IEnumerator ShowFlashbackDetectivePanel() { yield return(null); DrawableTweener.TweenSpriteAlpha(_flashbackCounterHudPanel, 1, 0, Settings.Default_AlphaTween_Duration, () => { _memoriesHudPanel.visible = true; AddChild(_memoriesHudPanel); DrawableTweener.TweenSpriteAlpha(_memoriesHudPanel, 0, 1, Settings.Default_AlphaTween_Duration); DrawableTweener.TweenScale(_memoriesHudPanel, Vector2.one, Vector2.one * 1.1f, Settings.Default_AlphaTween_Duration / 2, () => { DrawableTweener.TweenScale(_memoriesHudPanel, Vector2.one * 1.1f, Vector2.one * 1, Settings.Default_AlphaTween_Duration / 2, null); }); }); //Show Reset Button _resetFlashbackButton.SetActive(true); DrawableTweener.TweenSpriteAlpha(_resetFlashbackButton, 0, 1, Settings.Default_AlphaTween_Duration, () => { DrawableTweener.TweenScale(_resetFlashbackButton, Vector2.one, Vector2.one * 1.1f, Settings.Default_AlphaTween_Duration / 2, () => { DrawableTweener.TweenScale(_resetFlashbackButton, Vector2.one * 1.1f, Vector2.one * 1, Settings.Default_AlphaTween_Duration / 2, null); }); }); yield return(new WaitForMilliSeconds(Settings.Default_AlphaTween_Duration * 2)); }
public void DisableIndicator() { DrawableTweener.TweenSpriteAlpha(_onIndicatorSprite, 1, 0, MyGame.AlphaTweenDuration, Easing.Equation.QuadEaseOut, 0, () => { _onIndicatorSprite.visible = false; }); }
public void EnableIndicator() { _onIndicatorSprite.visible = true; DrawableTweener.TweenSpriteAlpha(_onIndicatorSprite, 0, 1, MyGame.AlphaTweenDuration, Easing.Equation.ElasticEaseOut, 0, () => { }); }
/// <summary> /// Sequence of events: /// -Disable Players Input /// -Load Image Sprites /// -Add First Sprite/Textbox /// -Navigate through all texts of the first sprite (when player presses AnyKey) /// -Go to next image (loop - when player presses AnyKey) /// -Enables Player input /// -Destroy itself /// </summary> /// <returns></returns> private IEnumerator Start() { //Wait for images and text, this is not supposed to happen but... while (_imagesFiles.Length == 0 || _texts.Length == 0 || _level == null) { yield return(null); } //Check for design error (images needs texts) if (_imagesFiles.Length != _texts.Length) { Console.WriteLine($"{this}: Images count differs from text count, check tmx objects properties"); yield break; } GameSoundManager.Instance.PauseFxLoopSound(Settings.Cave_Background_Ambient_Sound); _level.Player.InputEnabled = false; yield return(new WaitForMilliSeconds(_alphaTweenDuration)); //Create Sprites with the images _sprites = new Sprite[_imagesFiles.Length]; for (int i = 0; i < _imagesFiles.Length; i++) { string fileName = _imagesFiles[i]; if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName))) { Console.WriteLine($"{this}: File '{_imagesFiles[i]}' not exists"); fileName = "data/No Image.png"; } var s = new Sprite(fileName, true, false); s.alpha = 0; _sprites[i] = s; } //Load FirstImage AddChild(_sprites[0]); //Load textbox _textBox = new TextBox("", game.width - 120, 90); AddChild(_textBox); //Fade in panel and its children DrawableTweener.TweenSpriteAlpha(this, 0, 1, _alphaTweenDuration, Easing.Equation.QuadEaseOut); for (int i = 0; i < _sprites.Length; i++) { //Load first texts, split by NewLine string[] texts = _texts[i].Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _textBox.Text = texts.Length == 0 ? "" : texts[0]; _textBox.SetXY(120 / 2f, game.height - _textBox.Height - 30); //Check if has audio to play PlayAudioOrMusic(texts[0]); //Tween text, can be skipped by AnyKey yield return(_textBox.TweenTextRoutine(0, _textSpeed)); yield return(null); //Wait AnyKey to go to the next text while (!Input.GetAnyKeyDown(Key.ESCAPE)) { yield return(null); } yield return(null); //Loop through next texts for (int t = 1; t < texts.Length; t++) { _textBox.Text = texts[t]; _textBox.SetXY(120 / 2f, game.height - _textBox.Height - 30); //Check if has audio to play PlayAudioOrMusic(texts[t]); yield return(_textBox.TweenTextRoutine(0, _textSpeed)); yield return(null); //Wait AnyKey to go to the next text, if it is the last ont, goes to next image while (!Input.GetAnyKeyDown(Key.ESCAPE)) { yield return(null); } yield return(null); } //Loop to next Image/Texts if ((i + 1) < _sprites.Length) { //Fadeout current image var currentIndex = i; DrawableTweener.TweenSpriteAlpha(_sprites[i], 1, 0, _alphaTweenDuration, Easing.Equation.QuadEaseOut, 0, () => { _sprites[currentIndex].Destroy(); }); //Fadein next images AddChildAt(_sprites[i + 1], _textBox.Index); DrawableTweener.TweenSpriteAlpha(_sprites[i + 1], 0, 1, _alphaTweenDuration, Easing.Equation.QuadEaseOut); yield return(new WaitForMilliSeconds(_alphaTweenDuration)); } } //Fadeout panel, destroy itself, enables Player input DrawableTweener.TweenSpriteAlpha(this, 1, 0, MyGame.AlphaTweenDuration, Easing.Equation.QuadEaseOut, 0, () => { HierarchyManager.Instance.LateDestroy(this); toDestroy = true; GameSoundManager.Instance.PlayFxLoop(Settings.Cave_Background_Ambient_Sound, Settings.Cave_Background_Ambient_Sound_Volume); }); }
void OnMouseOff(GameObject target, MouseEventType eventType) { DrawableTweener.TweenSpriteAlpha(_onHoverSprite, _onHoverSprite.alpha, 0, Settings.Default_AlphaTween_Duration); Console.WriteLine($"{this}: off"); }
IEnumerator ShowTextBoxRoutine(TextBox textBox, int duration, int delay, bool lockPlayer, TextBox.OnFinished onFinished, bool fade) { bool lastPlayerLockState = false; if (lockPlayer && _level?.Player != null) { lastPlayerLockState = _level.Player.InputEnabled; _level.Player.InputEnabled = false; } if (delay > 0) { yield return(new WaitForMilliSeconds(delay)); } HierarchyManager.Instance.LateAdd(this, textBox); if (fade) { DrawableTweener.TweenSpriteAlpha(textBox, 0, 1, Settings.Default_AlphaTween_Duration); } yield return(textBox.TweenTextRoutine(0, Settings.Flashbacks_TextBoxTweenSpeed, duration == 0 ? true : false)); int time = 0; while (time < (duration + Settings.Default_AlphaTween_Duration)) { yield return(null); time += Time.deltaTime; } if (fade) { DrawableTweener.TweenSpriteAlpha(textBox, 1, 0, Settings.Default_AlphaTween_Duration, () => { HierarchyManager.Instance.LateDestroy(textBox); if (lockPlayer && _level?.Player != null) { _level.Player.InputEnabled = lastPlayerLockState; } onFinished?.Invoke(); }); } else { HierarchyManager.Instance.LateDestroy(textBox); if (_level?.Player != null) { _level.Player.InputEnabled = true; } onFinished?.Invoke(); } }