Initial main menu impl
This commit is contained in:
@@ -30,8 +30,6 @@ namespace EvilSatellites.Screens
|
||||
Player player = new Player(this);
|
||||
Objects.Add(player);
|
||||
_player = player;
|
||||
// Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000));
|
||||
// Objects.Add(prop);
|
||||
ObjectRadar = new Radar(_player, this);
|
||||
Spawner = new SatelliteSpawner(this);
|
||||
Spawner.Spawn();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EvilSatellites.Menu;
|
||||
using EvilSatellites.Screens;
|
||||
|
||||
namespace EvilSatellites.Screens
|
||||
{
|
||||
public class MainMenuScreen : MenuScreen
|
||||
{
|
||||
public override void Activate()
|
||||
{
|
||||
|
||||
MenuOptions = new MenuContainer("Main Menu", "Navigate with up and down arrows,, and enter to select.");
|
||||
MenuOptions.Add(new MenuEntry("Start", "Start the game"))
|
||||
.Add(new MenuEntry("Exit", "Exit the game"))
|
||||
.Add(new MenuEntry("Something Else", "Do something else"));
|
||||
base.Activate();
|
||||
}
|
||||
|
||||
public override void SelectItem()
|
||||
{
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav");
|
||||
if (CursorPosition == 0)
|
||||
{
|
||||
Manager.AddScreen(new GameScreen());
|
||||
Manager.RemoveScreen(this);
|
||||
Manager.Game.ResetElapsedTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,36 +17,33 @@ namespace EvilSatellites.Screens
|
||||
public ScreenManager _Manager;
|
||||
public ScreenState _State;
|
||||
public InputManager Inputs = new InputManager();
|
||||
public MenuScreen(ScreenManager manager, MenuContainer options)
|
||||
{
|
||||
_Manager = manager;
|
||||
MenuOptions = options;
|
||||
}
|
||||
|
||||
ScreenManager IScreen.Manager { get => _Manager; set => _Manager = value; }
|
||||
ScreenState IScreen.State { get => _State; set => _State = value; }
|
||||
|
||||
void IScreen.Activate()
|
||||
public ScreenManager Manager { get => _Manager; set => _Manager = value; }
|
||||
public ScreenState State { get => _State; set => _State = value; }
|
||||
|
||||
public virtual void Activate()
|
||||
{
|
||||
CursorPosition = 0;
|
||||
Tolk.Output(MenuOptions.Title, true);
|
||||
Tolk.Output(MenuOptions.Description, false);
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
|
||||
}
|
||||
|
||||
void IScreen.Deactivate()
|
||||
public virtual void Deactivate()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void IScreen.HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||
{
|
||||
Inputs.Update();
|
||||
if (Inputs.IsJustPressed(Keys.Down))
|
||||
{
|
||||
NextItem();
|
||||
}
|
||||
if (Inputs.IsJustPressed(Keys.Down))
|
||||
if (Inputs.IsJustPressed(Keys.Up))
|
||||
{
|
||||
PreviousItem();
|
||||
}
|
||||
@@ -56,21 +53,22 @@ namespace EvilSatellites.Screens
|
||||
}
|
||||
}
|
||||
|
||||
void IScreen.Update(GameTime gameTime)
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
return;
|
||||
Manager.Sound.Update();
|
||||
|
||||
}
|
||||
|
||||
public void PreviousItem()
|
||||
{
|
||||
CursorPosition--;
|
||||
CursorPosition -= 1;
|
||||
CheckMenuBounds();
|
||||
ReadMenuItem();
|
||||
}
|
||||
|
||||
public void NextItem()
|
||||
{
|
||||
CursorPosition++;
|
||||
CursorPosition += 1;
|
||||
CheckMenuBounds();
|
||||
ReadMenuItem();
|
||||
}
|
||||
@@ -80,19 +78,22 @@ namespace EvilSatellites.Screens
|
||||
if (CursorPosition > MenuOptions.Entries.Count-1)
|
||||
{
|
||||
CursorPosition = 0;
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav");
|
||||
}
|
||||
if (CursorPosition < 0)
|
||||
{
|
||||
CursorPosition = MenuOptions.Entries.Count - 1;
|
||||
CursorPosition = MenuOptions.Entries.Count-1;
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav");
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadMenuItem()
|
||||
{
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuMove.wav");
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true);
|
||||
}
|
||||
|
||||
public void SelectItem()
|
||||
public virtual void SelectItem()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user