Esempio n. 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ı.");
            }
        }
Esempio n. 2
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);
        }