Ejemplo n.º 1
0
        public override void Draw()
        {
            SMH.Graphics.DrawSprite(Sprites.OptionsBackground, _windowX, _windowY);
            SMH.Graphics.DrawSprite(Sprites.OptionsPatch, _windowX + 344f, _windowY + 30f);

            //Draw smiley next to the selected game
            SMH.Graphics.DrawSprite(Sprites.SmileysFace, _smileyX, _smileyY);

            //Draw save boxes
            int i = 0;

            foreach (KeyValuePair <SaveSlot, SaveBox> kvp in _saveBoxes)
            {
                SaveBox  box  = kvp.Value;
                SaveSlot slot = kvp.Key;

                if (_selectedSlot == kvp.Key && _deletePromptActive)
                {
                    SMH.Graphics.DrawSprite(Sprites.MenuSpeechBubble, box.X + 30f, box.Y - 2f);
                    SMH.Graphics.DrawString(SmileyFont.AbilityTitle, "Delete this file?", box.X + 75f, box.Y + 5f, TextAlignment.Left, Color.Black, 0.9f);

                    SMH.Graphics.DrawString(SmileyFont.Segoe14, "Yes", box.X + 125f, box.Y + 65f, TextAlignment.Center, _mouseOverYes ? Color.Red : Color.White);
                    SMH.Graphics.DrawString(SmileyFont.Segoe14, "No", box.X + 205f, box.Y + 65f, TextAlignment.Center, _mouseOverNo ? Color.Red : Color.White);
                }
                else
                {
                    Color color = kvp.Key == _selectedSlot ? Color.LightBlue : Color.White;

                    //File Name
                    SMH.Graphics.DrawString(SmileyFont.AbilityTitle, SMH.SaveManager.Saves[slot].IsEmpty ? "- Empty -" : "Save " + (i + 1).ToString(), box.X + 70f, box.Y + 5f, TextAlignment.Left, color);

                    //Time Played
                    SMH.Graphics.DrawString(SmileyFont.Segoe14, "Time Played: ", box.X + 70f, box.Y + 50f, TextAlignment.Left, color);
                    SMH.Graphics.DrawString(SmileyFont.Segoe14, SMH.SaveManager.Saves[slot].IsEmpty ? "0:00:00" :
                                            SMH.SaveManager.Saves[slot].TimePlayed.ToString(), box.X + 250f, box.Y + 50f, TextAlignment.Right, color);

                    //Completion percentage
                    SMH.Graphics.DrawString(SmileyFont.Segoe14, "Complete: ", box.X + 70f, box.Y + 75f, TextAlignment.Left, color);
                    SMH.Graphics.DrawString(SmileyFont.Segoe14, SMH.SaveManager.Saves[slot].IsEmpty ? "0%" :
                                            SMH.SaveManager.Saves[slot].CalculateCompletionPercentage().ToString(), box.X + 250f, box.Y + 75f, TextAlignment.Right, color);
                }

                i++;
            }

            //Draw buttons
            foreach (Button button in _buttons.Values)
            {
                button.Draw();
            }

            if (_difficultyPrompt.IsVisible)
            {
                _difficultyPrompt.Draw();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a new SelectFileScreen.
        /// </summary>
        public SelectFileScreen(MainMenu mainMenu)
            : base(mainMenu)
        {
            _buttons[SelectFileButton.Back]   = new Button(0, 0, "Back");
            _buttons[SelectFileButton.Delete] = new Button(0, 0, "Delete");
            _buttons[SelectFileButton.Start]  = new Button(0, 0, "Start");

            foreach (SaveSlot saveSlot in Enum.GetValues(typeof(SaveSlot)))
            {
                _saveBoxes[saveSlot] = new SaveBox();
            }

            SetWindowPosition(182f, -512f);
        }
Ejemplo n.º 3
0
        public override void Update(float dt)
        {
            if (_difficultyPrompt.IsVisible)
            {
                Difficulty?result = _difficultyPrompt.Update(dt);
                if (result == null)
                {
                    return;
                }
                SMH.SaveManager.CurrentSave.Difficulty = result.Value;
            }

            if (State == MenuState.EnteringScreen)
            {
                SetWindowPosition(_windowX, _windowY + 1800f * dt);
                if (_windowY > 138f)
                {
                    EnterState(MenuState.InScreen);
                    SetWindowPosition(_windowX, 138f);
                }
            }
            else if (State == MenuState.ExitingScreen)
            {
                SetWindowPosition(_windowX, _windowY - 1800f * dt);
                if (_windowY <= -512f)
                {
                    //Done exiting screen - perform action based on what button was clicked.
                    switch (_clickedButton)
                    {
                    case SelectFileButton.Back:
                        MainMenu.ShowScreen <TitleScreen>();
                        break;

                    case SelectFileButton.Start:
                        if (SMH.SaveManager.CurrentSave.IsEmpty)
                        {
                            SMH.Environment.LoadLevelAsynch(Level.FOUNTAIN_AREA);
                            MainMenu.ShowScreen <CinematicScreen>();
                        }
                        else
                        {
                            SMH.StartGame(false);
                        }
                        break;
                    }
                }
            }

            //Set "start" button text based on whether or not an empty file is selected.
            _buttons[SelectFileButton.Start].Text = SMH.SaveManager.Saves[_selectedSlot].IsEmpty ? "Start" : "Continue";

            //Update buttons
            foreach (KeyValuePair <SelectFileButton, Button> kvp in _buttons)
            {
                kvp.Value.Update(dt);
                if (kvp.Value.IsClicked() && kvp.Key != SelectFileButton.Delete)
                {
                    _clickedButton = kvp.Key;
                    SMH.SaveManager.CurrentSave = SMH.SaveManager.Saves[_selectedSlot];
                    EnterState(MenuState.ExitingScreen);
                    if (kvp.Key == SelectFileButton.Start && SMH.SaveManager.Saves[_selectedSlot].IsEmpty)
                    {
                        _difficultyPrompt.IsVisible = true;
                    }
                }
            }

            //Click delete button
            if (_buttons[SelectFileButton.Delete].IsClicked())
            {
                if (!SMH.SaveManager.Saves[_selectedSlot].IsEmpty)
                {
                    _deletePromptActive = true;
                }
            }

            //Update save box selections
            if (!_deletePromptActive)
            {
                foreach (KeyValuePair <SaveSlot, SaveBox> kvp in _saveBoxes)
                {
                    if (SMH.Input.IsDown(Input.Attack) && kvp.Value.CollisionBox.Contains(SMH.Input.Cursor))
                    {
                        _selectedSlot = kvp.Key;
                    }
                }
            }

            //Listen for response to delete prompt
            if (_deletePromptActive)
            {
                SaveBox box = _saveBoxes[_selectedSlot];
                _yesDeleteBox = new Rect(box.X + 100f, box.Y + 60f, 50f, 35f);
                _noDeleteBox  = new Rect(box.X + 180f, box.Y + 60f, 50f, 35f);

                _mouseOverYes = _yesDeleteBox.Contains(SMH.Input.Cursor);
                _mouseOverNo  = _noDeleteBox.Contains(SMH.Input.Cursor);

                if (SMH.Input.IsDown(Input.Attack))
                {
                    if (_mouseOverYes)
                    {
                        SMH.SaveManager.Delete(_selectedSlot);
                        _deletePromptActive = false;
                    }
                    else if (_mouseOverNo)
                    {
                        _deletePromptActive = false;
                    }
                }
            }

            //Move the Smiley selector towards the selected file.
            if (_smileyY > _saveBoxes[_selectedSlot].Y + 45f)
            {
                _smileyY -= 750f * dt;
                if (_smileyY < _saveBoxes[_selectedSlot].Y + 45f)
                {
                    _smileyY = _saveBoxes[_selectedSlot].Y + 45f;
                }
            }
            else if (_smileyY < _saveBoxes[_selectedSlot].Y + 45f)
            {
                _smileyY += 750f * dt;
                if (_smileyY > _saveBoxes[_selectedSlot].Y + 45f)
                {
                    _smileyY = _saveBoxes[_selectedSlot].Y + 45f;
                }
            }
        }