Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
            //}
        }