Example #1
0
        /// <summary>
        /// Move the camera in the given direction.
        /// </summary>
        /// <param name="dir">
        /// The direction to move the camera. One of:
        /// <list type="bullet">
        ///     <item>
        ///     <description><see cref="TM_Direction.UP"/></description>
        ///     </item>
        ///     <item>
        ///     <description><see cref="TM_Direction.DOWN"/></description>
        ///     </item>
        ///     <item>
        ///     <description><see cref="TM_Direction.LEFT"/></description>
        ///     </item>
        ///     <item>
        ///     <description><see cref="TM_Direction.RIGHT"/></description>
        ///     </item>
        /// </list>
        /// </param>
        public void MoveInDirection(TM_Direction dir)
        {
            float moveDistance = CAMERA_SPEED * gameObject.GetComponent <Camera>().orthographicSize *Time.deltaTime;

            switch (dir)
            {
            case TM_Direction.UP:
                gameObject.transform.Translate(Vector3.up * moveDistance);
                break;

            case TM_Direction.LEFT:
                gameObject.transform.Translate(Vector3.left * moveDistance);
                break;

            case TM_Direction.DOWN:
                gameObject.transform.Translate(Vector3.down * moveDistance);
                break;

            case TM_Direction.RIGHT:
                gameObject.transform.Translate(Vector3.right * moveDistance);
                break;

            case TM_Direction.STAY:
                gameObject.transform.Translate(Vector3.zero);
                break;
            }
        }
Example #2
0
        /// <summary>
        /// Moves the Turing machine head 1 unit in the given direction.
        /// </summary>
        /// <param name="dir">The direction in which to move.</param>
        public void MoveHeadInDirection(TM_Direction dir)
        {
            Vector3 move_vector = Vector3.zero;

            switch (dir)
            {
            case TM_Direction.UP:
                move_vector = new Vector3(0, 1);
                break;

            case TM_Direction.DOWN:
                move_vector = new Vector3(0, -1);
                break;

            case TM_Direction.LEFT:
                move_vector = new Vector3(-1, 0);
                break;

            case TM_Direction.RIGHT:
                move_vector = new Vector3(1, 0);
                break;

            case TM_Direction.STAY:
                move_vector = Vector3.zero;
                break;
            }

            gameObject.transform.Translate(move_vector);
        }
Example #3
0
 /**
  * <summary>
  * Create a Turing machine transition to be placed in the transition table.
  * </summary>
  * <param name="nextState">The ID of the state to transition to. <see cref="NextState"/></param>
  * <param name="direction">The direction code for the head to move. <see cref="Direction"/></param>
  * <param name="writeSymbol">The symbol to write to the grid. <see cref="WriteSymbol"/></param>
  */
 public Transition(int nextState, TM_Direction direction, TM_Symbol writeSymbol)
 {
     NextState = nextState;
     Direction = direction;
     WriteSymbol = writeSymbol;
 }