public static Point2D FindTargetPosition(this Hartho_DuelBot robot, ScannedRobotEvent e)
        {
            var angle = robot.HeadingRadians + e.BearingRadians;

            //TODO this takes a lot of negatives. Find out what's going on.
            return(new Point2D(robot.PositionVector - Vector2DHelpers.VectorFromAngle(-angle - Math.PI / 2, e.Distance)));
        }
 private void InitializeStates(Hartho_DuelBot robot)
 {
     _states = FindStatesByReflection();
     foreach (var state in _states)
     {
         state.Initialize(robot);
     }
 }
Exemple #3
0
        /// <summary>
        /// Method to draw the battlefield bounds (i.e. the battlefield bounds - robot radius/2).
        /// </summary>
        public static void DrawBattlefieldEffectiveBounds(this Hartho_DuelBot robot, Color drawColor)
        {
            // Set color to a semi-transparent one.
            var halfTransparent = Color.FromArgb(160, drawColor);

            // Draw outlines of the field.
            robot.Graphics.DrawLine(new Pen(halfTransparent), (int)robot.Battlefield.TopLeft.X, (int)robot.Battlefield.TopLeft.Y, (int)robot.Battlefield.TopRight.X, (int)robot.Battlefield.TopRight.Y);
            robot.Graphics.DrawLine(new Pen(halfTransparent), (int)robot.Battlefield.TopLeft.X, (int)robot.Battlefield.TopLeft.Y, (int)robot.Battlefield.BottomLeft.X, (int)robot.Battlefield.BottomLeft.Y);
            robot.Graphics.DrawLine(new Pen(halfTransparent), (int)robot.Battlefield.BottomLeft.X, (int)robot.Battlefield.BottomLeft.Y, (int)robot.Battlefield.BottomRight.X, (int)robot.Battlefield.BottomRight.Y);
            robot.Graphics.DrawLine(new Pen(halfTransparent), (int)robot.Battlefield.BottomRight.X, (int)robot.Battlefield.BottomRight.Y, (int)robot.Battlefield.TopRight.X, (int)robot.Battlefield.TopRight.Y);
        }
 public StateManager(Hartho_DuelBot robot)
 {
     InitializeStates(robot);
     _stateQueue = new Queue <State>();
 }
 public WallAvoidance(Hartho_DuelBot robot)
 {
     Robot       = robot;
     Battlefield = Robot.Battlefield;
 }
Exemple #6
0
        public static Vector2D ForwardVector(this Hartho_DuelBot robot, double offset = 0, double length = 1)
        {
            var angle = -robot.HeadingRadians + offset;

            return(DirectionVector(robot, angle, robot.MoveDirection, length));
        }
Exemple #7
0
 /// <summary>
 /// Returns a vector in the desired direction, or straight forward if unspecified. The use of nullable types
 /// is for simplicity and being able to set default values.
 /// </summary>
 /// <param name="angle">The angle to turn. Defaults to null, which is converted to robot's ahead.</param>
 /// <param name="direction">Whether to cast the vector forwards or backwards. Default is the robot's direction</param>
 /// <param name="length">How long the vector should be</param>
 /// <returns>The vector</returns>
 public static Vector2D DirectionVector(this Hartho_DuelBot robot, double angle, Direction?direction = null, double length = 1)
 {
     direction = direction ?? robot.MoveDirection;
     return(robot.PositionVector + Vector2DHelpers.VectorFromAngle(angle + HalfPi) * length *
            (int)direction.Value);
 }
Exemple #8
0
 public void Initialize(Hartho_DuelBot robot)
 {
     Robot = robot;
     InitializeFields();
     SpinRadar();
 }