private bool EvitarParedes() { if ((MyRobot.X >= MyRobot.BattleFieldWidth - (margin + MyRobot.Height))) { MyRobot.TurnRight(Utils.NormalRelativeAngleDegrees(-MyRobot.Heading - 90)); MyRobot.Ahead(dist - 20); return(true); } else if (MyRobot.Y >= MyRobot.BattleFieldHeight - (margin + MyRobot.Height)) { MyRobot.TurnRight(Utils.NormalRelativeAngleDegrees(-MyRobot.Heading - 180)); MyRobot.Ahead(dist - 20); return(true); } else if (MyRobot.Y <= (margin + MyRobot.Height)) { MyRobot.TurnRight(Utils.NormalRelativeAngleDegrees(-MyRobot.Heading)); MyRobot.Ahead(dist - 20); return(true); } else if (MyRobot.X <= (margin + MyRobot.Height)) { MyRobot.TurnRight(Utils.NormalRelativeAngleDegrees(-MyRobot.Heading + 90)); MyRobot.Ahead(dist - 20); return(true); } return(false); }
public override void ActionMove() { MyRobot.IsAdjustGunForRobotTurn = true; MyRobot.IsAdjustRadarForGunTurn = true; MyRobot.IsAdjustRadarForRobotTurn = true; MyRobot.SetTurnRadarRight(double.PositiveInfinity); if (MyRobot.Heading % 90 > 0) { MyRobot.TurnRight(-MyRobot.Heading); } if (Utils.IsNear(MyRobot.HeadingRadians, 5D) || Utils.IsNear(MyRobot.HeadingRadians, Math.PI)) { MyRobot.Ahead((Math.Max(MyRobot.BattleFieldHeight - MyRobot.Y, MyRobot.Y) - margin) * dir); } else { MyRobot.Ahead((Math.Max(MyRobot.BattleFieldWidth - MyRobot.X, MyRobot.X) - margin) * dir); } MyRobot.TurnRight(90 * dir); //if (!EvitarParedes()) //{ // dir *= -1; // MyRobot.SetTurnRight(ang * dir); // MyRobot.SetAhead(dist); //} }
public override void ActionMove() { MyRobot.IsAdjustGunForRobotTurn = true; MyRobot.IsAdjustRadarForGunTurn = true; MyRobot.IsAdjustRadarForRobotTurn = true; if (EvitarParedes()) { return; } if (Math.Abs(currentHeading - MyRobot.Heading) < 10 && Math.Abs(currentHeading - MyRobot.Heading) > 1) { dir = -dir; currentHeading = MyRobot.Heading; MyRobot.TurnRight(ang * dir); } MyRobot.SetTurnRight(ang * dir); MyRobot.SetAhead(desplazar); MyRobot.Execute(); }