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;
                    });
                }
            }
        }
示例#2
0
        private IEnumerator WaitForFlashPanelHudBeDestroyed(FlashBackHud01 flashHud, TiledObject flashbackData)
        {
            while (flashHud != null && flashHud.toDestroy == false)
            {
                yield return(null);
            }

            _level.Player.InputEnabled = true;

            //Fadein Music if has one and a property to closeit
            var closeMusicBool = flashbackData.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);
            }

            if (_collectedFlashBacksTriggersNames.Count >= _totalFlashbacks)
            {
                //All found

                //Show message to user
                _level.Player.InputEnabled = false;

                yield return(new WaitForMilliSeconds(1000));

                var textBox = new TextBox(Settings.Message_To_Player_After_Collect_Flashbacks, game.width - 120, 30);
                textBox.CenterOnBottom();
                GameHud.Instance.AddChild(textBox);

                yield return(textBox.TweenTextRoutine(0, Settings.Flashbacks_TextBoxTweenSpeed, true));

                textBox.Destroy();

                //Change FlashbackPanel
                yield return(GameHud.Instance.ShowFlashbackDetectivePanel());

                //Show Flashbacks pickups
                FlashbackPickupsManager.Instance.EnableFlashbackPickups();

                _level.Player.InputEnabled = true;
            }
        }
        /// <summary>
        /// Create and Load the flashback panel using data of the tiledObject
        /// </summary>
        /// <param name="tileData"></param>
        public FlashBackHud01 LoadFlashbackHud(TiledObject tileData, bool speedUp = false, bool pAllowSkipByKey = true)
        {
            if (tileData.propertyList?.properties == null)
            {
                Console.WriteLine($"ERROR: {tileData.Name} Flashback without properties in Tiled");
                return(null);
            }

            var allProps = tileData.propertyList.properties;

            var imageFiles = allProps.Where(p => p.Name.ToLower().StartsWith("image_")).ToArray();
            var texts      = allProps.Where(p => p.Name.ToLower().StartsWith("text_")).ToArray();

            if (imageFiles.Length == 0 || imageFiles.Length != texts.Length)
            {
                Console.WriteLine(
                    $"ERROR+: {this}: Images count differs from text count, check tmx objects properties");
                return(null);
            }

            //Texts: replace multiple linebreaks for one linebreak
            _currentFlashHud = new FlashBackHud01(tileData, game.width, game.height, speedUp, pAllowSkipByKey)
            {
                ImagesFiles = imageFiles.Select(im => im.Value).ToArray(),
                Texts       = texts.Select(t =>
                                           t.Type == "string"
                        ? string.Join(System.Environment.NewLine,
                                      t.Value.Split(System.Environment.NewLine.ToCharArray(),
                                                    StringSplitOptions.RemoveEmptyEntries))
                        : t.Value).ToArray(),
                Level = _level
            };

            HierarchyManager.Instance.LateAdd(this, _currentFlashHud);

            return(_currentFlashHud);
        }