private void Attack(AITankController controller, Int32 dt) { //Look at situation when direction not updates controller.UpdateTargetDirection(new Vector(0, 0), dt); Vector direction = GameProcess.Current_Game.Player.AbsoluteCenter - controller.Target.Gun.AbsoluteCenter; direction.Normalize(); controller.UpdateGunDirection(direction, dt); if (Math.Abs(controller.Target.Gun.AbsoluteAngle - Controller.DirectionToAngle(direction)) < 5) controller.Target.Fire(); }
private void MoveObject(AITankController controller, List<Vector> path, Int32 dt) { Vector direction = GameProcess.Current_Game.Player.AbsoluteCenter - controller.Target.Gun.AbsoluteCenter; direction.Normalize(); controller.UpdateGunDirection(direction, dt); Vector moveCommand = new Vector(0, 0); foreach (Vector pathNode in path) { Vector nearDistance = pathNode - controller.Target.AbsoluteCenter; if (nearDistance.LengthSquared > controller.Target.Engine.translateSpeed.LengthSquared) { int delta_angle = (int)(controller.Target.AbsoluteAngle - Controller.DirectionToAngle(nearDistance)); if (Math.Abs(delta_angle) > 5) { moveCommand.X = Controller.CalculateRotateSign(delta_angle); } else { moveCommand.Y = 1; } controller.UpdateTargetDirection(moveCommand, dt); return; } else { continue; } } }