diff --git a/.vs/EvilSatellites/v16/.suo b/.vs/EvilSatellites/v16/.suo index 76ca567..7e839a0 100644 Binary files a/.vs/EvilSatellites/v16/.suo and b/.vs/EvilSatellites/v16/.suo differ diff --git a/EvilSatellites/Objects/Projectile.cs b/EvilSatellites/Objects/Projectile.cs index 7ee95e8..709799c 100644 --- a/EvilSatellites/Objects/Projectile.cs +++ b/EvilSatellites/Objects/Projectile.cs @@ -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(); } diff --git a/EvilSatellites/Objects/Satellite.cs b/EvilSatellites/Objects/Satellite.cs index 5e390ae..c28b578 100644 --- a/EvilSatellites/Objects/Satellite.cs +++ b/EvilSatellites/Objects/Satellite.cs @@ -50,10 +50,28 @@ namespace EvilSatellites.Objects { 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); + 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) { + if (obj.Type == ObjectType.Projectile) + { + var proj = (Projectile)obj; + if (proj.Owner == this) return; + } Health -= 10; if (obj.Type == ObjectType.Player) { diff --git a/EvilSatellites/SatelliteSpawner.cs b/EvilSatellites/SatelliteSpawner.cs index d8fd901..584e9fd 100644 --- a/EvilSatellites/SatelliteSpawner.cs +++ b/EvilSatellites/SatelliteSpawner.cs @@ -22,7 +22,7 @@ namespace EvilSatellites 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 x = player.Position.X-250f + (float)rnd.NextDouble() * 500; diff --git a/EvilSatellites/Screens/GameScreen.cs b/EvilSatellites/Screens/GameScreen.cs index f62db19..54cec5a 100644 --- a/EvilSatellites/Screens/GameScreen.cs +++ b/EvilSatellites/Screens/GameScreen.cs @@ -213,5 +213,10 @@ namespace EvilSatellites.Screens { Addable.Add(obj); } + + public Player GetPlayer() + { + return _player; + } } } diff --git a/EvilSatellites/Weapons/LaserMG.cs b/EvilSatellites/Weapons/LaserMG.cs index 6096f64..48a63ee 100644 --- a/EvilSatellites/Weapons/LaserMG.cs +++ b/EvilSatellites/Weapons/LaserMG.cs @@ -86,7 +86,7 @@ namespace EvilSatellites.Weapons { sfxShoot.Play(); TimerStart = TimerEnd; - Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation); + Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder); Screen.AddObject(proj); } }