Esempio n. 1
0
        private void SpawnButtons()
        {
            TextButton btnStart = new TextButton(new Rectangle(), font, "Start", texPixel);
            btnStart.Click += () => {
                TheWitnessPuzzles.Puzzle currentPanel = FileStorageManager.LoadCurrentPanel();
                if (currentPanel == null)
                {
                    currentPanel = DI.Get<PanelGenerator>().GeneratePanel();
                    FileStorageManager.SaveCurrentPanel(currentPanel);
                }

                ScreenManager.Instance.AddScreen<PanelGameScreen>(false, true, currentPanel);
                SoundManager.PlayOnce(Sound.MenuEnter);
            };

            TextButton btnHistory = new TextButton(new Rectangle(), font, "Library", texPixel);
            btnHistory.Click += () => {
                ScreenManager.Instance.AddScreen<HistoryGameScreen>(false, true);
                SoundManager.PlayOnce(Sound.MenuEnter);
            };

            TextButton btnSettings = new TextButton(new Rectangle(), font, "Settings", texPixel);
            btnSettings.Click += () => {
                ScreenManager.Instance.AddScreen<SettingsGameScreen>(false, true);
                SoundManager.PlayOnce(Sound.MenuEnter);
            };

            TextButton btnAbout = new TextButton(new Rectangle(), font, "About", texPixel);
            btnAbout.Click += () => {
                ScreenManager.Instance.AddScreen<AboutGameScreen>(false, true);
                SoundManager.PlayOnce(Sound.MenuEnter);
            };

            buttons.Add(btnStart);
            buttons.Add(btnHistory);
            buttons.Add(btnSettings);
            buttons.Add(btnAbout);

            UpdateButtonsPosition();
        }
Esempio n. 2
0
        private void SpawnButtons()
        {
            TouchButton btnClose = new TouchButton(new Rectangle(), texClose, null);

            btnClose.Click += () => {
                AbortTracing();
                SoundManager.PlayOnce(Sound.MenuOpen);
                ScreenManager.Instance.GoBack();
            };
            buttons.Add(btnClose);

            ToggleButton btnLike = new ToggleButton(new Rectangle(), texLike[1], texLike[0], null, FileStorageManager.IsPanelInFavourites(panel));

            btnLike.Click += () =>
            {
                // Add panel the list of favourite panels (or remove from it)
                if (btnLike.IsActivated)
                {
                    FileStorageManager.AddPanelToFavourites(panel);
                }
                else
                {
                    FileStorageManager.DeletePanelFromFavourites(panel);
                }

                SoundManager.PlayOnce(btnLike.IsActivated ? Sound.ButtonLike : Sound.ButtonUnlike);
            };
            buttons.Add(btnLike);

            // When panel is standalone, it cannot have Next button
            if (!IsStandalonePanel)
            {
                TwoStateButton btnNext = new TwoStateButton(new Rectangle(), texDelete, texNext, null, null, null, false);
                btnNext.Click += () =>
                {
                    Action callback = null;
                    callback = () =>
                    {
                        AbortTracing();
                        Puzzle nextPanel = DI.Get <PanelGenerator>().GeneratePanel();
                        FileStorageManager.SaveCurrentPanel(nextPanel);
                        LoadNewPanel(nextPanel);
                        btnNext.StateActive = false;
                        btnLike.Deactivate();
                        fade.FadeOutComplete -= callback;
                    };

                    // Add panel to the list of last 10 discarded panels
                    if (!btnNext.StateActive)
                    {
                        FileStorageManager.AddPanelToDiscardedList(panel);
                    }

                    SoundManager.PlayOnce(btnNext.StateActive ? Sound.ButtonNextSuccess : Sound.ButtonNext);
                    fade.FadeOutComplete += callback;
                    fade.Restart();
                };
                buttons.Add(btnNext);
            }

            UpdateButtonsPosition();
        }