Example #1
0
        private static void goStraight()
        {
            RobotEntity robotEntity = RobotEntity.getInstance();
            AreaEntity  areaEntity  = AreaEntity.getInstance();

            switch (robotEntity.Direction)
            {
            case Directions.E:
                robotEntity.X++;
                break;

            case Directions.N:
                robotEntity.Y++;
                break;

            case Directions.S:
                robotEntity.Y--;
                break;

            case Directions.W:
                robotEntity.X--;
                break;

            default:
                break;
            }

            if (robotEntity.X < 0 || robotEntity.Y < 0 || areaEntity.ySize < robotEntity.Y || areaEntity.xSize < robotEntity.X)
            {
                throw new Exception($"Alanın dışına çıkıldı.");
            }
        }
Example #2
0
        private static void turnRight(RotationKeys rotationKey)
        {
            RobotEntity robotEntity = RobotEntity.getInstance();

            switch (robotEntity.Direction)
            {
            case Directions.E:
                robotEntity.Direction = Directions.S;
                break;

            case Directions.N:
                robotEntity.Direction = Directions.E;
                break;

            case Directions.S:
                robotEntity.Direction = Directions.W;
                break;

            case Directions.W:
                robotEntity.Direction = Directions.N;
                break;

            default:
                break;
            }
        }
Example #3
0
        private static void turnRight(RotationKeys rotationKey)
        {
            RobotEntity robotEntity = RobotEntity.getInstance();

            switch (robotEntity.Direction)
            {
            case Directions.EAST:
                robotEntity.Direction = Directions.SOUTH;
                break;

            case Directions.NORTH:
                robotEntity.Direction = Directions.EAST;
                break;

            case Directions.SOUTH:
                robotEntity.Direction = Directions.WEST;
                break;

            case Directions.WEST:
                robotEntity.Direction = Directions.NORTH;
                break;

            default:
                break;
            }
        }
Example #4
0
        private static void goStraight()
        {
            RobotEntity robotEntity = RobotEntity.getInstance();
            AreaEntity  areaEntity  = AreaEntity.getInstance();

            areaEntity.buttons[robotEntity.X][robotEntity.Y].Text      = "";
            areaEntity.buttons[robotEntity.X][robotEntity.Y].BackColor = Color.White;
            areaEntity.buttons[robotEntity.X][robotEntity.Y].Update();
            switch (robotEntity.Direction)
            {
            case Directions.EAST:
                robotEntity.X++;
                break;

            case Directions.NORTH:
                robotEntity.Y--;
                break;

            case Directions.SOUTH:
                robotEntity.Y++;
                break;

            case Directions.WEST:
                robotEntity.X--;
                break;

            default:
                break;
            }

            if (robotEntity.X < 0 || robotEntity.Y < 0 || areaEntity.ySize < robotEntity.Y || areaEntity.xSize < robotEntity.X)
            {
                throw new Exception($"Alanın dışına çıkıldı.");
            }
            areaEntity.buttons[robotEntity.X][robotEntity.Y].Text      = robotEntity.Direction.ToString();
            areaEntity.buttons[robotEntity.X][robotEntity.Y].BackColor = Color.Red;
            areaEntity.buttons[robotEntity.X][robotEntity.Y].Update();
            System.Threading.Thread.Sleep(1000);
        }