Lots of stuff

This commit is contained in:
2021-04-19 15:41:37 +02:00
parent 3d9ca3d590
commit 589124c5fc
10 changed files with 120 additions and 24 deletions
Binary file not shown.
Binary file not shown.
+21 -3
View File
@@ -12,14 +12,19 @@ namespace EvilSatellites.Objects
public class Debris : AbstractGameObject
{
private ISoundEffect3D Sound;
private Random rnd = new Random();
private Vector3 MovementVector;
public Debris(IScreen screen, Vector3 pos) : base(screen)
{
Type = ObjectType.Debris;
Sound = Screen.Manager.Sound.Load3D(@"sfx/debris/1/loop.wav");
Sound.Loop = true;
Sound.Pitch = 0.9 + (float)rnd.NextDouble()*2;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
MovementVector = new Vector3(-0.02f + (float)rnd.NextDouble() * 0.01f, -0.02f + (float)rnd.NextDouble() * 0.01f, -0.02f + (float) rnd.NextDouble() * 0.01f);
Rotation = Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), 0);
Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
Activate();
}
@@ -33,16 +38,29 @@ namespace EvilSatellites.Objects
public override void Destroy()
{
Sound.Destroy();
ShouldDestroy = true;
Active = false;
}
override public void Update(GameTime gameTime)
{
Sound.Position = new System.Numerics.Vector3(Position.X, Position.Y, Position.Z);
Move(MovementVector);
Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2);
}
public override void OnCollision(IGameObject obj)
{
Sound.Stop();
if (obj.Type == ObjectType.Projectile) return;
if (obj.Type == ObjectType.Player)
{
var player = (Player)obj;
if (player.Vacuuming)
{
return;
}
player.TakeDamage(25);
Destroy();
}
}
}
}
+2 -1
View File
@@ -9,6 +9,7 @@ namespace EvilSatellites.Objects
Generic,
Player,
Satellite,
Projectile
Projectile,
Debris
}
}
+38 -2
View File
@@ -12,7 +12,7 @@ namespace EvilSatellites.Objects
{
private Vector3 _PrevPos;
private Vector3 MaxSpeed = new Vector3(0.2f, 0.2f, 0.2f);
public Vector3 Acceleration = new Vector3(0.008f, 0.008f, 0.008f);
public Vector3 Acceleration = new Vector3(0.002wf, 0.004f, 0.004f);
private Vector3 Deceleration = new Vector3(0.0025f, 0.0025f, 0.0025f);
private ISoundEffect sfxEngine;
private ISoundEffect sfxWhine;
@@ -22,18 +22,24 @@ namespace EvilSatellites.Objects
public IWeapon CurrentWeapon;
private int Turning;
private int Elevating;
public bool Vacuuming;
public float Health;
private Random rnd = new Random();
public Player(IScreen screen): base(screen)
{
ShouldDestroy = false;
Active = true;
Type = ObjectType.Player;
Position = new Vector3(0, 0, 0);
Position = new Vector3(5000, 5000, 4990);
Dimensions = new Vector3(5, 5, 5);
Movement = new Vector3(0, 0, 0);
Rotation = Matrix.Identity;
Orientation = Rotation.Forward;
CurrentWeapon = new LaserMG(this, (GameScreen)Screen);
Turning = 0;
Elevating = 0;
Vacuuming = false;
Health = 100;
Activate();
}
@@ -144,5 +150,35 @@ namespace EvilSatellites.Objects
Elevating = 0;
sfxElevator.Stop();
}
public void StartVacuuming(GameTime time)
{
Vacuuming = true;
sfxVacuum.Start(time);
}
public void StopVacuuming()
{
Vacuuming = false;
sfxVacuum.Stop();
}
public void TakeDamage(float dmg)
{
Health -= dmg;
string dmgSound = @"sfx/physics/collisions/";
if (dmg > 60)
{
dmgSound += "heavy";
} else if (dmg > 30)
{
dmgSound += "medium";
} else
{
dmgSound += "light";
}
dmgSound += "/int/" + (rnd.Next(2)+1).ToString()+".wav";
Screen.Manager.Sound.PlayOneshot(dmgSound);
}
}
}
+10 -3
View File
@@ -32,9 +32,16 @@ namespace EvilSatellites.Objects
{
ShouldDestroy = false;
Active = true;
Sound = Screen.Manager.Sound.Load3D(@"sfx/bullets/1.wav");
Sound.Loop = true;
Sound.Play();
Sound.Pitch = 0.9 + rnd.NextDouble()*0.3;
Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2);
}
public override void Destroy()
{
Sound.Stop();
Sound.Destroy();
ShouldDestroy = true;
Active = false;
}
@@ -46,13 +53,13 @@ namespace EvilSatellites.Objects
{
Destroy();
}
Sound.Position = new System.Numerics.Vector3(Position.X + Dimensions.X / 2, Position.Y + Dimensions.Y / 2, Position.Z + Dimensions.Z / 2);
}
public override void OnCollision(IGameObject obj)
{
if (obj.Type == ObjectType.Projectile) return;
if (obj.Type == ObjectType.Player) return;
Screen.Manager.Sound.PlayOneshot(@"sfx/physics/impacts/bullet/"+(rnd.Next(5)+1)+".wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z), Screen.Manager.EnvironmentEffect);
if (obj.Type == ObjectType.Projectile || obj.Type == ObjectType.Player || obj.Type == ObjectType.Debris) return;
Screen.Manager.Sound.PlayOneshot(@"sfx/physics/impacts/bullet/"+(rnd.Next(5)+1)+".wav", new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2), Screen.Manager.EnvironmentEffect);
Destroy();
}
}
+12 -1
View File
@@ -15,16 +15,20 @@ namespace EvilSatellites.Objects
private int Health;
private int SatelliteID;
private Random rnd = new Random();
private Matrix FlightPath;
public Satellite(IScreen screen, Vector3 pos, int satelliteID = 1) : base(screen)
{
Type = ObjectType.Satellite;
SatelliteID = satelliteID;
Sound = Screen.Manager.Sound.Load3D(@"sfx/satellite/"+SatelliteID.ToString()+"/loop.wav");
Sound.Loop = true;
Sound.Pitch = 0.9 + rnd.NextDouble()*0.5;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
FlightPath = Matrix.CreateFromAxisAngle(Rotation.Right, (float)rnd.NextDouble()*0.1f);
Rotation = FlightPath;
Activate();
}
@@ -44,12 +48,19 @@ namespace EvilSatellites.Objects
override public void Update(GameTime gameTime)
{
Sound.Position = new System.Numerics.Vector3(Position.X, Position.Y, Position.Z);
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);
}
public override void OnCollision(IGameObject obj)
{
Health -= 10;
if (obj.Type == ObjectType.Player)
{
var player = (Player)obj;
player.TakeDamage(66);
Destroy();
}
if (Health <= 0)
{
Screen.Manager.Sound.PlayOneshot(@"sfx/satellite/"+SatelliteID.ToString()+"/explode.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z));
+14 -2
View File
@@ -17,15 +17,22 @@ namespace EvilSatellites
public IGameObject Target;
public IScreen Screen;
public ISoundEffect RadarNoise;
public ObjectType Filter;
public Radar(IGameObject owner, IScreen screen)
{
Owner = owner;
Screen = screen;
RadarNoise = Screen.Manager.Sound.Load(@"sfx/ui/radar/pingEnemy.wav", false);
RadarNoise.Loop = true;
Filter = ObjectType.Satellite;
Active = false;
}
public void SetObjectType(ObjectType type)
{
Filter = type;
}
public void Start()
{
RadarNoise.Reset();
@@ -43,9 +50,10 @@ namespace EvilSatellites
{
if (objects.Count < 1) return;
float minDistance = 1000;
Target = null;
foreach (var obj in objects)
{
if (obj.Type != ObjectType.Satellite) continue;
if (obj.Type != Filter) continue;
float distance = Vector3.Distance(obj.Position, Owner.Position);
if (distance < minDistance)
{
@@ -53,7 +61,11 @@ namespace EvilSatellites
Target = obj;
}
}
if (Target == null) return;
if (Target == null)
{
RadarNoise.Pitch = 0.1;
return;
}
Vector3 radarTarget = (Target.Position - Owner.Position);
radarTarget.Normalize();
RadarNoise.Pitch = MathHelper.Clamp(0.1f / Vector3.Distance(Owner.Rotation.Forward, radarTarget) * 3f, 0, 1);
+20 -12
View File
@@ -29,7 +29,7 @@ namespace EvilSatellites.Screens
Player player = new Player(this);
Objects.Add(player);
_player = player;
Satellite prop = new Satellite(this, new Vector3(15, 0, 15));
Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000));
Objects.Add(prop);
ObjectRadar = new Radar(_player, this);
return;
@@ -63,7 +63,7 @@ namespace EvilSatellites.Screens
objtree.Add(obj);
if (obj.Type == ObjectType.Player)
{
Manager.Sound.ListenerPosition = new System.Numerics.Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z);
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;
@@ -130,6 +130,14 @@ namespace EvilSatellites.Screens
{
_player.StopElevating();
}
if (Input.IsJustPressed(Keys.V))
{
_player.StartVacuuming(gameTime);
}
if (Input.IsJustReleased(Keys.V))
{
_player.StopVacuuming();
}
_player.Accelerate(move);
if (Input.IsJustPressed(Keys.Space))
{
@@ -139,14 +147,6 @@ namespace EvilSatellites.Screens
{
_player.CurrentWeapon.Stop();
}
if (Input.IsJustPressed(Keys.V))
{
Tolk.Speak(_player.Movement.Length().ToString(), true);
}
if (Input.IsJustPressed(Keys.C))
{
Tolk.Speak(_player.Position.ToString());
}
if (Input.IsJustPressed(Keys.R))
{
if (ObjectRadar.Active)
@@ -157,9 +157,17 @@ namespace EvilSatellites.Screens
ObjectRadar.Start();
}
}
if (Input.IsJustPressed(Keys.O))
if (Input.IsJustPressed(Keys.T))
{
Tolk.Speak(Objects.Count.ToString());
if (ObjectRadar.Filter == ObjectType.Satellite)
{
ObjectRadar.SetObjectType(ObjectType.Debris);
Tolk.Output("Debris");
} else
{
ObjectRadar.SetObjectType(ObjectType.Satellite);
Tolk.Output("Satellites");
}
}
}
+3
View File
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:81c7340107f82cee2d8f968a94f40be9c326b820d87c1216368979216bbc2ab6
size 269864