Basic gamepad with force feedback impl
This commit is contained in:
@@ -19,7 +19,7 @@ namespace EvilSatellites.Screens
|
||||
public List<IGameObject> Objects = new List<IGameObject>();
|
||||
public List<IGameObject> Removable = new List<IGameObject>();
|
||||
public List<IGameObject> Addable = new List<IGameObject>();
|
||||
private Quadtree<IGameObject> objtree = new Quadtree<IGameObject>(new Vector3(10000, 10000, 10000), 10, 20);
|
||||
private Quadtree<IGameObject> objtree = new Quadtree<IGameObject>(new Vector3(50000, 50000, 50000), 10, 20);
|
||||
private float Theta = 0;
|
||||
private Player _player;
|
||||
private Radar ObjectRadar;
|
||||
@@ -83,9 +83,6 @@ namespace EvilSatellites.Screens
|
||||
Manager.Sound.ListenerPosition = new System.Numerics.Vector3(obj.Position.X+obj.Dimensions.X/2, obj.Position.Y+obj.Dimensions.Y/2, obj.Position.Z+obj.Dimensions.Z/2);
|
||||
Manager.Sound.ListenerOrientationForward = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Forward.X, obj.Rotation.Forward.Y, obj.Rotation.Forward.Z));
|
||||
Manager.Sound.ListenerOrientationUpwards = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Up.X, obj.Rotation.Up.Y, obj.Rotation.Up.Z));
|
||||
Manager.Listener.Position = obj.Position;
|
||||
Manager.Listener.Forward = obj.Rotation.Forward;
|
||||
Manager.Listener.Up = obj.Rotation.Up;
|
||||
}
|
||||
if (obj.ShouldDestroy)
|
||||
{
|
||||
@@ -108,19 +105,19 @@ namespace EvilSatellites.Screens
|
||||
{
|
||||
Input.Update();
|
||||
Vector3 move = new Vector3(0, 0, 0);
|
||||
if (Input.IsPressed(Keys.W))
|
||||
if (Input.IsPressed(Keys.W) || Input.IsPressed(Buttons.LeftThumbstickUp))
|
||||
{
|
||||
move.Z = -_player.Acceleration.Z;
|
||||
}
|
||||
if (Input.IsPressed(Keys.S))
|
||||
if (Input.IsPressed(Keys.S) || Input.IsPressed(Buttons.LeftThumbstickDown))
|
||||
{
|
||||
move.Z = _player.Acceleration.Z;
|
||||
}
|
||||
if (Input.IsPressed(Keys.A))
|
||||
if (Input.IsPressed(Keys.A) || Input.IsPressed(Buttons.LeftThumbstickLeft))
|
||||
{
|
||||
move.X = -_player.Acceleration.X;
|
||||
}
|
||||
if (Input.IsPressed(Keys.D))
|
||||
if (Input.IsPressed(Keys.D) || Input.IsPressed(Buttons.LeftThumbstickRight))
|
||||
{
|
||||
move.X = _player.Acceleration.X;
|
||||
}
|
||||
@@ -128,49 +125,49 @@ namespace EvilSatellites.Screens
|
||||
{
|
||||
_player.PlayTap();
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Left))
|
||||
if (Input.IsJustPressed(Keys.Left) || Input.IsJustPressed(Buttons.RightThumbstickLeft))
|
||||
{
|
||||
_player.StartTurning(-1, gameTime);
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Right))
|
||||
if (Input.IsJustPressed(Keys.Right) || Input.IsJustPressed(Buttons.RightThumbstickRight))
|
||||
{
|
||||
_player.StartTurning(1, gameTime);
|
||||
}
|
||||
if (Input.IsJustReleased(Keys.Left) || Input.IsJustReleased(Keys.Right))
|
||||
if (Input.IsJustReleased(Keys.Left) || Input.IsJustReleased(Keys.Right) || Input.IsJustReleased(Buttons.RightThumbstickLeft) || Input.IsJustReleased(Buttons.RightThumbstickRight))
|
||||
{
|
||||
_player.StopTurning();
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Up))
|
||||
if (Input.IsJustPressed(Keys.Up) || Input.IsJustPressed(Buttons.RightThumbstickUp))
|
||||
{
|
||||
_player.StartElevating(-1, gameTime);
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Down))
|
||||
if (Input.IsJustPressed(Keys.Down) || Input.IsJustPressed(Buttons.RightThumbstickDown))
|
||||
{
|
||||
_player.StartElevating(1, gameTime);
|
||||
}
|
||||
if (Input.IsJustReleased(Keys.Up) || Input.IsJustReleased(Keys.Down))
|
||||
if (Input.IsJustReleased(Keys.Up) || Input.IsJustReleased(Keys.Down) || Input.IsJustReleased(Buttons.RightThumbstickUp) || Input.IsJustReleased(Buttons.RightThumbstickDown))
|
||||
{
|
||||
_player.StopElevating();
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.V))
|
||||
if (Input.IsJustPressed(Keys.V) || Input.IsJustPressed(Buttons.LeftTrigger))
|
||||
{
|
||||
_player.StartVacuuming(gameTime);
|
||||
}
|
||||
if (Input.IsJustReleased(Keys.V))
|
||||
if (Input.IsJustReleased(Keys.V) || Input.IsJustReleased(Buttons.LeftTrigger))
|
||||
{
|
||||
_player.StopVacuuming();
|
||||
}
|
||||
_player.Accelerate(move);
|
||||
if (Input.IsJustPressed(Keys.Space))
|
||||
if (Input.IsJustPressed(Keys.Space) || Input.IsJustPressed(Buttons.RightTrigger))
|
||||
{
|
||||
_player.CurrentWeapon.Shoot(gameTime);
|
||||
_player.PlayTap();
|
||||
}
|
||||
if (Input.IsJustReleased(Keys.Space))
|
||||
if (Input.IsJustReleased(Keys.Space) || Input.IsJustReleased(Buttons.RightTrigger))
|
||||
{
|
||||
_player.CurrentWeapon.Stop();
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.R))
|
||||
if (Input.IsJustPressed(Keys.R) || Input.IsJustPressed(Buttons.LeftShoulder))
|
||||
{
|
||||
_player.PlayTap();
|
||||
if (ObjectRadar.Active)
|
||||
@@ -181,7 +178,7 @@ namespace EvilSatellites.Screens
|
||||
ObjectRadar.Start();
|
||||
}
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.T))
|
||||
if (Input.IsJustPressed(Keys.T) || Input.IsJustPressed(Buttons.RightShoulder))
|
||||
{
|
||||
_player.PlayTap();
|
||||
if (ObjectRadar.Filter == ObjectType.Satellite)
|
||||
@@ -194,17 +191,17 @@ namespace EvilSatellites.Screens
|
||||
Tolk.Output("Satellites");
|
||||
}
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.H))
|
||||
if (Input.IsJustPressed(Keys.H) || Input.IsJustPressed(Buttons.B))
|
||||
{
|
||||
_player.PlayTap();
|
||||
Tolk.Output(Math.Round(_player.Health).ToString() + " health", true);
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.X))
|
||||
if (Input.IsJustPressed(Keys.X) || Input.IsJustPressed(Buttons.A))
|
||||
{
|
||||
_player.PlayTap();
|
||||
Tolk.Output(_player.CurrentWeapon.RemainingAmmo.ToString() + " rounds", true);
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Y))
|
||||
if (Input.IsJustPressed(Keys.Y) || Input.IsJustPressed(Buttons.X))
|
||||
{
|
||||
_player.PlayTap();
|
||||
if (ObjectRadar.Target != null)
|
||||
@@ -231,7 +228,7 @@ namespace EvilSatellites.Screens
|
||||
{
|
||||
Manager.Music.Volume = Manager.Music.Volume - 0.05f;
|
||||
}
|
||||
if (Input.IsJustPressed(Keys.Escape))
|
||||
if (Input.IsJustPressed(Keys.Escape) || Input.IsJustPressed(Buttons.Start))
|
||||
{
|
||||
EndGame();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace EvilSatellites.Screens
|
||||
public ScreenManager _Manager;
|
||||
public ScreenState _State;
|
||||
public InputManager Inputs = new InputManager();
|
||||
|
||||
|
||||
private double DescWaitTime;
|
||||
private bool DescRead;
|
||||
public ScreenManager Manager { get => _Manager; set => _Manager = value; }
|
||||
public ScreenState State { get => _State; set => _State = value; }
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace EvilSatellites.Screens
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
|
||||
Manager.Music.Play("menu1");
|
||||
DescWaitTime = 0;
|
||||
DescRead = false;
|
||||
}
|
||||
|
||||
public virtual void Deactivate()
|
||||
@@ -40,15 +42,15 @@ namespace EvilSatellites.Screens
|
||||
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||
{
|
||||
Inputs.Update();
|
||||
if (Inputs.IsJustPressed(Keys.Down))
|
||||
if (Inputs.IsJustPressed(Keys.Down) || Inputs.IsJustPressed(Buttons.DPadDown))
|
||||
{
|
||||
NextItem();
|
||||
}
|
||||
if (Inputs.IsJustPressed(Keys.Up))
|
||||
if (Inputs.IsJustPressed(Keys.Up) || Inputs.IsJustPressed(Buttons.DPadUp))
|
||||
{
|
||||
PreviousItem();
|
||||
}
|
||||
if (Inputs.IsJustPressed(Keys.Enter))
|
||||
if (Inputs.IsJustPressed(Keys.Enter) || Inputs.IsJustPressed(Buttons.A))
|
||||
{
|
||||
SelectItem();
|
||||
}
|
||||
@@ -57,7 +59,12 @@ namespace EvilSatellites.Screens
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
Manager.Sound.Update();
|
||||
|
||||
DescWaitTime += gameTime.ElapsedGameTime.TotalMilliseconds;
|
||||
if (DescWaitTime > 2000 && DescRead == false)
|
||||
{
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Description, false);
|
||||
DescRead = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void PreviousItem()
|
||||
@@ -92,6 +99,8 @@ namespace EvilSatellites.Screens
|
||||
{
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuMove.wav");
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true);
|
||||
DescRead = false;
|
||||
DescWaitTime = 0;
|
||||
}
|
||||
|
||||
public virtual void SelectItem()
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace EvilSatellites.Screens
|
||||
.Add(new MenuEntry("Satellites shot: " + GameStats.SatellitesShot.ToString(), "Amount of satellites shot during this game."))
|
||||
.Add(new MenuEntry("Debris collected: " + GameStats.DebrisCollected.ToString(), "Amount of debris collected during this game."))
|
||||
.Add(new MenuEntry("Satellite collisions: " + GameStats.SatelliteCollisions.ToString(), "How many satellites you crashed into"))
|
||||
.Add(new MenuEntry("Total play time: " + GameStats.TotalPlayTime.ToString(), "How much time you spent on this run"))
|
||||
.Add(new MenuEntry("Total play time: " + TimeSpan.FromSeconds(GameStats.TotalPlayTime).ToString(), "How much time you spent on this run"))
|
||||
.Add(new MenuEntry("OK", "Go back to main menu"));
|
||||
base.Activate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user