More shooting goodness

This commit is contained in:
2021-04-19 21:33:56 +02:00
parent c49db61494
commit 671ed50a33
8 changed files with 32 additions and 9 deletions
+7
View File
@@ -68,6 +68,13 @@ namespace EvilSatellites.Objects
public override void Destroy()
{
sfxEngine.Destroy();
sfxWhine.Destroy();
sfxVacuum.Destroy();
sfxTurn.Destroy();
sfxTaps.Destroy();
sfxElevator.Destroy();
sfxDamage.Destroy();
return;
}
override public void Update(GameTime gameTime)
+7 -8
View File
@@ -50,18 +50,17 @@ 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)
if (rnd.Next(512) == 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);
var orient = Matrix.Invert(Matrix.CreateTranslation(Position) * Matrix.CreateLookAt(Position, scr.GetPlayer().Position, Rotation.Up));
var dir = Position - player.Position;
dir.Normalize();
var proj = new Projectile(Screen, Position, orient, this);
// proj.Direction = dir;
scr.AddObject(proj);
DavyKager.Tolk.Output("Shoot!");
}
}