FlashbackPickup AddFlashbackPickupToLevel(TiledObject flashData)
        {
            string objUniqueName = flashData.Name.Trim();

            flashData.Name = flashData.Name.Replace("Pickup ", "").Trim().ToLower();

            int counter = 0;

            while (_flashPickupsMap.ContainsKey(objUniqueName.ToLower()))
            {
                objUniqueName = flashData.Name.Trim().ToLower() + "_" + counter;
                counter++;
            }

            int flashNum = int.TryParse(flashData.Name.Replace("flashback ", ""), out flashNum) ? flashNum : 6;

            var flashPickup = new FlashbackPickup($"data/flashback_pick_up_{flashNum}.png", flashData, 1, 1)
            {
                name = objUniqueName
            };

            _level.AddChild(flashPickup);
            flashPickup.Enabled = false;
            flashPickup.width   = Mathf.Round(flashData.Width);
            flashPickup.height  = Mathf.Round(flashData.Height);
            flashPickup.SetOrigin(0, flashPickup.texture.height); //Tmx use origin left,bottom :/
            flashPickup.rotation = flashData.rotation;
            flashPickup.SetXY(flashData.X, flashData.Y);

            return(flashPickup);
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        private IEnumerator CheckPickupsCollectedOrderSquence(FlashbackPickup flashbackPickup)
        {
            _level.Player.InputEnabled = false;

            yield return(new WaitForMilliSeconds(Settings.Default_AlphaTween_Duration + 200));

            //Get the original list in lowercase
            var correctOrder =
                FlashbackPickupsManager.Instance.FlashPickupsMap.Values.OrderBy(s => s.FlashbackData.Name)
                .Select(s => s.FlashbackData.Name.ToLower());
            var collectOrder = _collectedFlashPickupsNames.Select(s => s.ToLower());

            if (correctOrder.SequenceEqual(collectOrder))
            {
                //Correct!
                Utils.print(this, " order correct ", string.Join(", ", collectOrder));

                flashbackPickup.Enabled = false;

                yield return(CorrectFlashPickupsOrderSequence(flashbackPickup));
            }
            else
            {
                //Incorrect order
                Utils.print(this, " order incorrect ", string.Join(", ", collectOrder));
                yield return(IncorrectFlashPickupsOrderSequence(flashbackPickup));

                GameHud.Instance.ResetFlashbackButton.SetActive(true);
            }
        }
Exemple #4
0
        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;
                });
            });
        }
        public FlashbackPickupsManager(MapGameObject pMap, BaseLevel pLevel) : base(false)
        {
            Instance = this;

            _flashPickupsMap = new Dictionary <string, FlashbackPickup>();
            _level           = pLevel;
            _map             = pMap;

            var flashesData = _map.ObjectGroups.SelectMany(og => og.Objects)
                              .Where(tileObj => tileObj?.Type.ToLower() == "flashbackpickup");

            //Get from settings to skip some flashbacks
            _flashesPickupsToSkip = new List <string>();
            if (Settings.Flashback_Pickups_Collected != "0")
            {
                var flashesStr = Settings.Flashback_Pickups_Collected.Trim().Split(' ');
                for (int i = 0; i < flashesStr.Length; i++)
                {
                    string valStr = flashesStr[i].Trim();
                    if (int.TryParse(valStr, out var val))
                    {
                        _flashesPickupsToSkip.Add($"Flashback {val}".ToLower());
                    }
                }
            }

            foreach (var flashData in flashesData)
            {
                var flashPickup = AddFlashbackPickupToLevel(flashData);
                _flashPickupsMap.Add(flashData.Name.ToLower(), flashPickup);
            }

            //Final trigger flashback
            var finalFlashData = _map.ObjectGroups
                                 .SelectMany(og => og.Objects)
                                 .FirstOrDefault(tileObj => tileObj?.Type.ToLower() == "finalflashbackpickup");

            if (finalFlashData != null)
            {
                _finalPickup = AddFlashbackPickupToLevel(finalFlashData);
            }
        }
Exemple #7
0
        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;
        }
Exemple #8
0
 public void PlayerPickedupFlashblack(FlashbackPickup flashbackPickup, bool showPanel = true)
 {
     CoroutineManager.StartCoroutine(PlayerPickedupFlashblackRoutine(flashbackPickup, showPanel), this);
 }