示例#1
0
        private void SpawnPanelButtons()
        {
            int fileIndex = currentPage * panelsOnPage;

            for (int j = 0; j < pageHeight; j++)
            {
                for (int i = 0; i < pageWidth; i++, fileIndex++)
                {
                    if (fileIndex >= fileNames.Length)
                    {
                        break;
                    }

                    Puzzle panel = FileStorageManager.LoadPanelFromFile(fileNames[fileIndex]);
                    renderer.SetPanel(panel);
                    RenderTarget2D texture = new RenderTarget2D(GraphicsDevice, renderWidth, renderHeight);
                    renderer.RenderPanelToTexture(texture);

                    Point size   = new Point((int)(panelSize.X * 0.9f), (int)(panelSize.Y * 0.9f));
                    Point margin = (panelSize - size).Divide(2);
                    Point pos    = new Point(panelsPosition.X + panelSize.X * i + margin.X, panelsPosition.Y + panelSize.Y * j + margin.Y);

                    TouchButton btnPanel = new TouchButton(new Rectangle(pos, size), texture);
                    btnPanel.Click += () =>
                    {
                        ScreenManager.Instance.AddScreen <PanelGameScreen>(false, true, panel, true);
                        SoundManager.PlayOnce(Sound.MenuEnter);
                    };
                    panels.Add(btnPanel);
                }
            }
        }
示例#2
0
        public override void Activate()
        {
            switch (currentTab)
            {
            case HistoryTab.Solved:     fileNames = FileStorageManager.GetSolvedPanelsNames();    break;

            case HistoryTab.Discarded:  fileNames = FileStorageManager.GetDiscardedPanelsNames(); break;

            case HistoryTab.Favourites: fileNames = FileStorageManager.GetFavouritePanelsNames(); break;
            }

            UpdatePageSize();
            RespawnPanelButtons();
        }
示例#3
0
        private void SetPanelSuccess()
        {
            panelState.SetSuccess();
            SoundManager.PlayOnce(Sound.Success);
            if (!IsStandalonePanel)
            {
                (buttons[2] as TwoStateButton).StateActive = true;
            }

            // Add panel to the list of last 10 solved panels
            FileStorageManager.AddPanelToSolvedList(panel);
            // Delete current panel save file so it won't be loaded again next time
            FileStorageManager.DeleteCurrentPanel();
        }
        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();
        }
示例#5
0
        private void SpawnButtons()
        {
            // Tabs
            TabButton btnSolved = new TabButton(new Rectangle(), texPixel, texSolved, null, Color.DarkGray, new Color(14, 14, 14));

            btnSolved.Click += () =>
            {
                currentTab  = HistoryTab.Solved;
                currentPage = 0;
                fileNames   = FileStorageManager.GetSolvedPanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnSolved);

            TabButton btnDiscarded = new TabButton(new Rectangle(), texPixel, texDiscarded, null, Color.DarkGray, new Color(14, 14, 14));

            btnDiscarded.Click += () =>
            {
                currentTab  = HistoryTab.Discarded;
                currentPage = 0;
                fileNames   = FileStorageManager.GetDiscardedPanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnDiscarded);

            TabButton btnFavs = new TabButton(new Rectangle(), texPixel, texFavourite, null, Color.DarkGray, new Color(14, 14, 14));

            btnFavs.Click += () =>
            {
                currentTab  = HistoryTab.Favourites;
                currentPage = 0;
                fileNames   = FileStorageManager.GetFavouritePanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnFavs);

            // Other buttons
            foreach (TabButton tab in tabs)
            {
                foreach (TabButton otherTab in tabs.Where(x => x != tab))
                {
                    tab.ConnectTab(otherTab);
                }
            }
            btnSolved.Activate();

            btnBack        = new TextButton(new Rectangle(), font, "Back", texPixel);
            btnBack.Click += () =>
            {
                ScreenManager.Instance.GoBack();
                SoundManager.PlayOnce(Sound.MenuEscape);
            };

            btnPrevPage        = new TouchButton(new Rectangle(), texLeft);
            btnPrevPage.Click += () =>
            {
                if (currentPage > 0)
                {
                    currentPage--;
                    RespawnPanelButtons();
                }
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };

            btnNextPage        = new TouchButton(new Rectangle(), texRight);
            btnNextPage.Click += () =>
            {
                if (currentPage < maxPage)
                {
                    currentPage++;
                    RespawnPanelButtons();
                }
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };

            UpdateButtonsPositions();
        }
示例#6
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();
        }