103 lines
2.7 KiB
C#
103 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using EvilSatellites.Menu;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Input;
|
|
using DavyKager;
|
|
|
|
namespace EvilSatellites.Screens
|
|
{
|
|
public class MenuScreen : IScreen
|
|
{
|
|
public MenuContainer MenuOptions;
|
|
public int CursorPosition;
|
|
public ScreenManager _Manager;
|
|
public ScreenState _State;
|
|
public InputManager Inputs = new InputManager();
|
|
|
|
|
|
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");
|
|
Manager.Music.Play("menu1");
|
|
}
|
|
|
|
public virtual void Deactivate()
|
|
{
|
|
return;
|
|
}
|
|
|
|
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
|
{
|
|
Inputs.Update();
|
|
if (Inputs.IsJustPressed(Keys.Down))
|
|
{
|
|
NextItem();
|
|
}
|
|
if (Inputs.IsJustPressed(Keys.Up))
|
|
{
|
|
PreviousItem();
|
|
}
|
|
if (Inputs.IsJustPressed(Keys.Enter))
|
|
{
|
|
SelectItem();
|
|
}
|
|
}
|
|
|
|
public virtual void Update(GameTime gameTime)
|
|
{
|
|
Manager.Sound.Update();
|
|
|
|
}
|
|
|
|
public void PreviousItem()
|
|
{
|
|
CursorPosition -= 1;
|
|
CheckMenuBounds();
|
|
ReadMenuItem();
|
|
}
|
|
|
|
public void NextItem()
|
|
{
|
|
CursorPosition += 1;
|
|
CheckMenuBounds();
|
|
ReadMenuItem();
|
|
}
|
|
|
|
public void CheckMenuBounds()
|
|
{
|
|
if (CursorPosition > MenuOptions.Entries.Count-1)
|
|
{
|
|
CursorPosition = 0;
|
|
Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav");
|
|
}
|
|
if (CursorPosition < 0)
|
|
{
|
|
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 virtual void SelectItem()
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|