Initial main menu impl
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -32,13 +32,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="CppSharp.Runtime">
|
<Reference Include="CppSharp.Runtime">
|
||||||
<HintPath>..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll</HintPath>
|
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Synthizer.Net">
|
<Reference Include="Synthizer.Net">
|
||||||
<HintPath>..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll</HintPath>
|
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Synthy">
|
<Reference Include="Synthy">
|
||||||
<HintPath>..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\Synthy.dll</HintPath>
|
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthy.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -23,7 +23,8 @@ namespace EvilSatellites
|
|||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
// TODO: Add your initialization logic here
|
// TODO: Add your initialization logic here
|
||||||
_manager.AddScreen(new EvilSatellites.Screens.GameScreen());
|
// _manager.AddScreen(new EvilSatellites.Screens.GameScreen());
|
||||||
|
_manager.AddScreen(new EvilSatellites.Screens.MainMenuScreen());
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ namespace EvilSatellites.Objects
|
|||||||
{
|
{
|
||||||
Move(new Vector3(0, 0, -0.05f));
|
Move(new Vector3(0, 0, -0.05f));
|
||||||
Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2);
|
Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2);
|
||||||
if (rnd.Next(512) == 250)
|
if (rnd.Next(1024) == 512)
|
||||||
{
|
{
|
||||||
var scr = (GameScreen)Screen;
|
var scr = (GameScreen)Screen;
|
||||||
var player = scr.GetPlayer();
|
var player = scr.GetPlayer();
|
||||||
var orient = Matrix.Invert(Matrix.CreateTranslation(Position) * Matrix.CreateLookAt(Position, scr.GetPlayer().Position, Rotation.Up));
|
var orient = Matrix.Invert(Matrix.CreateTranslation(Position) * Matrix.CreateLookAt(Position, scr.GetPlayer().Position, Rotation.Up));
|
||||||
var dir = Position - player.Position;
|
var dir = Position - player.Position;
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
|
Screen.Manager.Sound.PlayOneshot(@"sfx/weapons/LaserCannon/fire/" + (rnd.Next(2) + 1).ToString() + ".wav", new System.Numerics.Vector3(Position.X + Dimensions.X / 2, Position.Y + Dimensions.Y / 2, Position.Z / Dimensions.Z / 2), Screen.Manager.EnvironmentEffect);
|
||||||
var proj = new Projectile(Screen, Position, orient, this);
|
var proj = new Projectile(Screen, Position, orient, this);
|
||||||
// proj.Direction = dir;
|
// proj.Direction = dir;
|
||||||
scr.AddObject(proj);
|
scr.AddObject(proj);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using System.Text;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using SynthySound;
|
using SynthySound;
|
||||||
using Synthizer;
|
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using Microsoft.Xna.Framework.Audio;
|
||||||
using EvilSatellites.Screens;
|
using EvilSatellites.Screens;
|
||||||
|
|
||||||
@@ -14,6 +13,8 @@ namespace EvilSatellites
|
|||||||
public class ScreenManager : DrawableGameComponent
|
public class ScreenManager : DrawableGameComponent
|
||||||
{
|
{
|
||||||
private List<IScreen> _Screens;
|
private List<IScreen> _Screens;
|
||||||
|
private List<IScreen> _ToRemove;
|
||||||
|
private List<IScreen> _ToAdd;
|
||||||
private IScreen _CurrentScreen;
|
private IScreen _CurrentScreen;
|
||||||
private Game _Game;
|
private Game _Game;
|
||||||
private bool _Running = false;
|
private bool _Running = false;
|
||||||
@@ -29,9 +30,11 @@ namespace EvilSatellites
|
|||||||
EnvironmentEffect.T60 = 1;
|
EnvironmentEffect.T60 = 1;
|
||||||
EnvironmentEffect.Defusion = 1f;
|
EnvironmentEffect.Defusion = 1f;
|
||||||
EnvironmentEffect.FreePath = 0.02;
|
EnvironmentEffect.FreePath = 0.02;
|
||||||
|
Sound.SetMaxDistance(150);
|
||||||
_Game = instance;
|
_Game = instance;
|
||||||
_Screens = new List<IScreen>();
|
_Screens = new List<IScreen>();
|
||||||
|
_ToRemove = new List<IScreen>();
|
||||||
|
_ToAdd = new List<IScreen>();
|
||||||
_CurrentScreen = null;
|
_CurrentScreen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +51,7 @@ namespace EvilSatellites
|
|||||||
public void AddScreen(IScreen screen)
|
public void AddScreen(IScreen screen)
|
||||||
{
|
{
|
||||||
screen.Manager = this;
|
screen.Manager = this;
|
||||||
if (_Running) screen.Activate();
|
_ToAdd.Add(screen);
|
||||||
_Screens.Add(screen);
|
|
||||||
}
|
}
|
||||||
public void RemoveScreen(IScreen screen)
|
public void RemoveScreen(IScreen screen)
|
||||||
{
|
{
|
||||||
@@ -57,12 +59,29 @@ namespace EvilSatellites
|
|||||||
{
|
{
|
||||||
throw new Exception("Cannot remove a screen that isn't added to manager");
|
throw new Exception("Cannot remove a screen that isn't added to manager");
|
||||||
}
|
}
|
||||||
screen.Deactivate();
|
_ToRemove.Add(screen);
|
||||||
_Screens.Remove(screen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
if (_ToAdd.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var screen in _ToAdd)
|
||||||
|
{
|
||||||
|
screen.Activate();
|
||||||
|
_Screens.Add(screen);
|
||||||
|
}
|
||||||
|
_ToAdd.Clear();
|
||||||
|
}
|
||||||
|
if (_ToRemove.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var screen in _ToRemove)
|
||||||
|
{
|
||||||
|
screen.Deactivate();
|
||||||
|
_Screens.Remove(screen);
|
||||||
|
}
|
||||||
|
_ToRemove.Clear();
|
||||||
|
}
|
||||||
Sound.Update();
|
Sound.Update();
|
||||||
var input = Keyboard.GetState();
|
var input = Keyboard.GetState();
|
||||||
foreach (var screen in _Screens)
|
foreach (var screen in _Screens)
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ namespace EvilSatellites.Screens
|
|||||||
Player player = new Player(this);
|
Player player = new Player(this);
|
||||||
Objects.Add(player);
|
Objects.Add(player);
|
||||||
_player = player;
|
_player = player;
|
||||||
// Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000));
|
|
||||||
// Objects.Add(prop);
|
|
||||||
ObjectRadar = new Radar(_player, this);
|
ObjectRadar = new Radar(_player, this);
|
||||||
Spawner = new SatelliteSpawner(this);
|
Spawner = new SatelliteSpawner(this);
|
||||||
Spawner.Spawn();
|
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 ScreenManager _Manager;
|
||||||
public ScreenState _State;
|
public ScreenState _State;
|
||||||
public InputManager Inputs = new InputManager();
|
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;
|
CursorPosition = 0;
|
||||||
Tolk.Output(MenuOptions.Title, true);
|
Tolk.Output(MenuOptions.Title, true);
|
||||||
Tolk.Output(MenuOptions.Description, false);
|
Tolk.Output(MenuOptions.Description, false);
|
||||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||||||
|
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IScreen.Deactivate()
|
public virtual void Deactivate()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IScreen.HandleInput(GameTime gameTime, KeyboardState inputs)
|
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||||
{
|
{
|
||||||
Inputs.Update();
|
Inputs.Update();
|
||||||
if (Inputs.IsJustPressed(Keys.Down))
|
if (Inputs.IsJustPressed(Keys.Down))
|
||||||
{
|
{
|
||||||
NextItem();
|
NextItem();
|
||||||
}
|
}
|
||||||
if (Inputs.IsJustPressed(Keys.Down))
|
if (Inputs.IsJustPressed(Keys.Up))
|
||||||
{
|
{
|
||||||
PreviousItem();
|
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()
|
public void PreviousItem()
|
||||||
{
|
{
|
||||||
CursorPosition--;
|
CursorPosition -= 1;
|
||||||
CheckMenuBounds();
|
CheckMenuBounds();
|
||||||
ReadMenuItem();
|
ReadMenuItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NextItem()
|
public void NextItem()
|
||||||
{
|
{
|
||||||
CursorPosition++;
|
CursorPosition += 1;
|
||||||
CheckMenuBounds();
|
CheckMenuBounds();
|
||||||
ReadMenuItem();
|
ReadMenuItem();
|
||||||
}
|
}
|
||||||
@@ -80,19 +78,22 @@ namespace EvilSatellites.Screens
|
|||||||
if (CursorPosition > MenuOptions.Entries.Count-1)
|
if (CursorPosition > MenuOptions.Entries.Count-1)
|
||||||
{
|
{
|
||||||
CursorPosition = 0;
|
CursorPosition = 0;
|
||||||
|
Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav");
|
||||||
}
|
}
|
||||||
if (CursorPosition < 0)
|
if (CursorPosition < 0)
|
||||||
{
|
{
|
||||||
CursorPosition = MenuOptions.Entries.Count-1;
|
CursorPosition = MenuOptions.Entries.Count-1;
|
||||||
|
Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadMenuItem()
|
public void ReadMenuItem()
|
||||||
{
|
{
|
||||||
|
Manager.Sound.PlayOneshot(@"sfx/ui/menuMove.wav");
|
||||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true);
|
Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectItem()
|
public virtual void SelectItem()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace EvilSatellites.Weapons
|
|||||||
State = WeaponState.Starting;
|
State = WeaponState.Starting;
|
||||||
sfxSpinup.Reset();
|
sfxSpinup.Reset();
|
||||||
sfxSpinup.Play();
|
sfxSpinup.Play();
|
||||||
TimerStart = time.TotalGameTime.TotalMilliseconds;
|
TimerStart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Stop()
|
public override void Stop()
|
||||||
@@ -73,19 +73,19 @@ namespace EvilSatellites.Weapons
|
|||||||
|
|
||||||
public override void Update(GameTime time)
|
public override void Update(GameTime time)
|
||||||
{
|
{
|
||||||
TimerEnd += time.ElapsedGameTime.TotalMilliseconds;
|
TimerStart += time.ElapsedGameTime.TotalMilliseconds;
|
||||||
if (State == WeaponState.Starting)
|
if (State == WeaponState.Starting)
|
||||||
{
|
{
|
||||||
if (TimerEnd - TimerStart > 800)
|
if (TimerStart > 800)
|
||||||
{
|
{
|
||||||
State = WeaponState.Firing;
|
State = WeaponState.Firing;
|
||||||
sfxSpinning.Play();
|
sfxSpinning.Play();
|
||||||
TimerStart = TimerEnd;
|
TimerStart = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (State == WeaponState.Firing)
|
if (State == WeaponState.Firing)
|
||||||
{
|
{
|
||||||
if (TimerEnd - TimerStart > FireRate)
|
if (TimerStart > FireRate)
|
||||||
{
|
{
|
||||||
if (RemainingAmmo > 0)
|
if (RemainingAmmo > 0)
|
||||||
{
|
{
|
||||||
@@ -104,10 +104,10 @@ namespace EvilSatellites.Weapons
|
|||||||
}
|
}
|
||||||
if (State == WeaponState.Stopping)
|
if (State == WeaponState.Stopping)
|
||||||
{
|
{
|
||||||
if (TimerEnd - TimerStart > 500)
|
if (TimerStart > 500)
|
||||||
{
|
{
|
||||||
State = WeaponState.Stopped;
|
State = WeaponState.Stopped;
|
||||||
TimerStart = TimerEnd;
|
TimerStart = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.Update(time);
|
base.Update(time);
|
||||||
|
|||||||
Reference in New Issue
Block a user