IOnitial attempt to shoot player
This commit is contained in:
Binary file not shown.
@@ -13,11 +13,13 @@ namespace EvilSatellites.Objects
|
|||||||
{
|
{
|
||||||
private ISoundEffect3D Sound;
|
private ISoundEffect3D Sound;
|
||||||
private Random rnd = new Random();
|
private Random rnd = new Random();
|
||||||
private Vector3 Direction;
|
public Vector3 Direction;
|
||||||
private Vector3 StartPos;
|
private Vector3 StartPos;
|
||||||
private float Range;
|
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;
|
StartPos = pos;
|
||||||
Position = pos;
|
Position = pos;
|
||||||
Dimensions = new Vector3(5, 5, 5);
|
Dimensions = new Vector3(5, 5, 5);
|
||||||
@@ -58,7 +60,8 @@ namespace EvilSatellites.Objects
|
|||||||
|
|
||||||
public override void OnCollision(IGameObject obj)
|
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);
|
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();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,28 @@ namespace EvilSatellites.Objects
|
|||||||
{
|
{
|
||||||
Move(new Vector3(0, 0, -0.05f));
|
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);
|
Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2);
|
||||||
|
if (rnd.Next(500) == 250)
|
||||||
|
{
|
||||||
|
var scr = (GameScreen)Screen;
|
||||||
|
var player = scr.GetPlayer();
|
||||||
|
var view = player.Position - Position;
|
||||||
|
var rotationAxis = Vector3.Cross(Rotation.Forward, view);
|
||||||
|
var rotationAngle = (float)Math.Acos(Vector3.Dot(Rotation.Forward, view) / Rotation.Forward.Length() / view.Length());
|
||||||
|
var rotationMatrix = Matrix.CreateFromAxisAngle(rotationAxis, rotationAngle);
|
||||||
|
var proj = new Projectile(Screen, Position, rotationMatrix, this);
|
||||||
|
proj.Direction = new Vector3(0, 0, 1);
|
||||||
|
scr.AddObject(proj);
|
||||||
|
DavyKager.Tolk.Output("Shoot!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnCollision(IGameObject obj)
|
public override void OnCollision(IGameObject obj)
|
||||||
{
|
{
|
||||||
|
if (obj.Type == ObjectType.Projectile)
|
||||||
|
{
|
||||||
|
var proj = (Projectile)obj;
|
||||||
|
if (proj.Owner == this) return;
|
||||||
|
}
|
||||||
Health -= 10;
|
Health -= 10;
|
||||||
if (obj.Type == ObjectType.Player)
|
if (obj.Type == ObjectType.Player)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace EvilSatellites
|
|||||||
|
|
||||||
public void Spawn()
|
public void Spawn()
|
||||||
{
|
{
|
||||||
for (var i = 0; i < Level*20; i++)
|
for (var i = 0; i < Level*1; i++)
|
||||||
{
|
{
|
||||||
var player = Screen.Objects.Where((x) => x.Type == ObjectType.Player).FirstOrDefault();
|
var player = Screen.Objects.Where((x) => x.Type == ObjectType.Player).FirstOrDefault();
|
||||||
var x = player.Position.X-250f + (float)rnd.NextDouble() * 500;
|
var x = player.Position.X-250f + (float)rnd.NextDouble() * 500;
|
||||||
|
|||||||
@@ -213,5 +213,10 @@ namespace EvilSatellites.Screens
|
|||||||
{
|
{
|
||||||
Addable.Add(obj);
|
Addable.Add(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player GetPlayer()
|
||||||
|
{
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace EvilSatellites.Weapons
|
|||||||
{
|
{
|
||||||
sfxShoot.Play();
|
sfxShoot.Play();
|
||||||
TimerStart = TimerEnd;
|
TimerStart = TimerEnd;
|
||||||
Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation);
|
Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder);
|
||||||
Screen.AddObject(proj);
|
Screen.AddObject(proj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user