public override void Draw(CanvasDrawingSession canvas) { if (LastFired < FIRE_COOLDOWN) { LastFired++; } Vector2 triangleTip = VMath.AddVectors(Position, VMath.ScalarMultiply(UnitDirectionVector, 12)); Vector2 triangleLeft = VMath.AddVectors( VMath.AddVectors(Position, VMath.ScalarMultiply(UnitDirectionVector, -12)) , VMath.ScalarMultiply(VMath.GetPerpendicularVector(UnitDirectionVector), -8)); Vector2 triangleRight = VMath.AddVectors( VMath.AddVectors(Position, VMath.ScalarMultiply(UnitDirectionVector, -12)) , VMath.ScalarMultiply(VMath.GetPerpendicularVector(UnitDirectionVector), 8)); Vector2[] trianglePoints = { triangleTip, triangleLeft, triangleRight }; CanvasGeometry triangle = CanvasGeometry.CreatePolygon(canvas, trianglePoints); canvas.FillGeometry(triangle, Colors.CadetBlue); }
public void Move(int canvasWidth, int canvasHeight) { Position = VMath.AddVectors(Position, VMath.ScalarMultiply(UnitDirectionVector, Speed)); if (!(this is Bullet)) { if (Position.X > canvasWidth) { Position = new Vector2(0, Position.Y); } if (Position.X < 0) { Position = new Vector2(canvasWidth, Position.Y); } if (Position.Y > canvasHeight) { Position = new Vector2(Position.X, 0); } if (Position.Y < 0) { Position = new Vector2(Position.X, canvasHeight); } } }
public Vector2 GetGunPosition() { return(VMath.AddVectors(Position, VMath.ScalarMultiply(UnitDirectionVector, 12))); }