IOnitial attempt to shoot player
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user