コード例 #1
0
        public Position()
        {
            this.x = 0;
            this.y = 0;

            this.Directon = Enums.Directions.N;
        }
コード例 #2
0
ファイル: Rover.cs プロジェクト: bakcora/MarsExplorer
        public void Turn(Enums.Sides side)
        {
            switch (side)
            {
            case Enums.Sides.Left:
            {
                if (Direction.Equals(Enums.Directions.East))
                {
                    Direction = Enums.Directions.North;
                    break;
                }
                Direction = (Enums.Directions)Enum.ToObject(typeof(Enums.Directions), ((byte)Direction) + 1);
                break;
            }

            case Enums.Sides.Right:
            {
                if (Direction.Equals(Enums.Directions.North))
                {
                    Direction = Enums.Directions.East;
                    break;
                }
                Direction = Direction = (Enums.Directions)Enum.ToObject(typeof(Enums.Directions), ((byte)Direction) - 1);
                break;
            }
            }
        }
コード例 #3
0
 private void Spin90DegreesLeft()
 {
     Direction = Direction switch
     {
         Enums.Directions.N => Enums.Directions.W,
         Enums.Directions.S => Enums.Directions.E,
         Enums.Directions.E => Enums.Directions.N,
         Enums.Directions.W => Enums.Directions.S,
         _ => Direction
     };
 }
コード例 #4
0
        /// <summary>
        /// Rotates turtle.
        /// </summary>
        /// <param name="left">Boolean used for rotating the turtle left or right.</param>
        public void RotateTurtle(bool left)
        {
            if (left)
            {
                turtleDirection = GetPreviousDirection(turtleDirection);
            }
            else
            {
                turtleDirection = GetNextDirection(turtleDirection);
            }

            SetTurtleDirectionArrow();
            DrawGame();
        }
コード例 #5
0
        /// <summary>
        /// Gets previous direction.
        /// </summary>
        /// <param name="direction">Current direction.</param>
        private Enums.Directions GetPreviousDirection(Enums.Directions direction)
        {
            switch (direction)
            {
            case Enums.Directions.North:
                return(Enums.Directions.West);

            case Enums.Directions.East:
                return(Enums.Directions.North);

            case Enums.Directions.South:
                return(Enums.Directions.East);

            case Enums.Directions.West:
                return(Enums.Directions.South);

            default:
                throw new IndexOutOfRangeException();
            }
        }
コード例 #6
0
    public static void SetAxisTowards(Enums.Directions axis, Transform t, Vector2 direction)
    {
        switch (axis)
        {
        case Enums.Directions.Up:
            t.up = direction;
            break;

        case Enums.Directions.Down:
            t.up = -direction;
            break;

        case Enums.Directions.Right:
            t.right = direction;
            break;

        case Enums.Directions.Left:
            t.right = -direction;
            break;
        }
    }
コード例 #7
0
        private void SpinRight()  //Assuming 90 degree
        {
            switch (this.Directon)
            {
            case Enums.Directions.N:
                this.Directon = Enums.Directions.E;
                break;

            case Enums.Directions.S:
                this.Directon = Enums.Directions.W;
                break;

            case Enums.Directions.E:
                this.Directon = Enums.Directions.S;
                break;

            case Enums.Directions.W:
                this.Directon = Enums.Directions.N;
                break;

            default:
                break;
            }
        }
コード例 #8
0
 public RoverPosition()
 {
     X         = 0;
     Y         = 0;
     Direction = Enums.Directions.N;
 }