More weapon and movement updates

This commit is contained in:
2021-04-11 20:43:29 +02:00
parent c989202d93
commit 15bfc8685f
8 changed files with 19 additions and 12 deletions
+7 -4
View File
@@ -12,15 +12,17 @@ namespace EvilSatellites.Objects
public class Projectile : AbstractGameObject
{
private ISoundEffect3D Sound;
private Random rnd = new Random();
private Vector3 Direction;
private Vector3 StartPos;
private float Range;
public Projectile(IScreen screen, Vector3 pos, Vector3 direction) : base(screen)
public Projectile(IScreen screen, Vector3 pos, Matrix rotation) : base(screen)
{
StartPos = pos;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
Direction = direction;
Direction = new Vector3(0, 0, -1);
Rotation = rotation;
Range = 500;
Type = ObjectType.Projectile;
Activate();
@@ -39,7 +41,7 @@ namespace EvilSatellites.Objects
override public void Update(GameTime gameTime)
{
Position += Direction;
Move(Direction);
if (Vector3.Distance(StartPos, Position) > Range)
{
Destroy();
@@ -48,8 +50,9 @@ namespace EvilSatellites.Objects
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/1.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z), Screen.Manager.EnvironmentEffect);
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);
Destroy();
}
}