IOnitial attempt to shoot player

This commit is contained in:
2021-04-19 20:23:23 +02:00
parent 7b25154e8e
commit c49db61494
6 changed files with 31 additions and 5 deletions
+6 -3
View File
@@ -13,11 +13,13 @@ namespace EvilSatellites.Objects
{
private ISoundEffect3D Sound;
private Random rnd = new Random();
private Vector3 Direction;
public Vector3 Direction;
private Vector3 StartPos;
private float Range;
public Projectile(IScreen screen, Vector3 pos, Matrix rotation) : base(screen)
public IGameObject Owner;
public Projectile(IScreen screen, Vector3 pos, Matrix rotation, IGameObject owner) : base(screen)
{
Owner = owner;
StartPos = pos;
Position = pos;
Dimensions = new Vector3(5, 5, 5);
@@ -58,7 +60,8 @@ namespace EvilSatellites.Objects
public override void OnCollision(IGameObject obj)
{
if (obj.Type == ObjectType.Projectile || obj.Type == ObjectType.Player || obj.Type == ObjectType.Debris) return;
if (obj.Type == ObjectType.Projectile || obj.Type == ObjectType.Debris) return;
if (obj == Owner) 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();
}