Basic gamepad with force feedback impl

This commit is contained in:
2021-04-24 02:47:17 +02:00
parent db9c3cceea
commit 9f66f9d8fb
109 changed files with 205 additions and 196 deletions
+21 -24
View File
@@ -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();
}