public static Rover CreateRover(string command, Plateau plateau) { string[] commands = command.Split(' '); Coordinate coordinate = GetCoordinate(commands); OrientationState orientation = OrientationFactory(commands[2]); return(new Rover(coordinate, orientation, plateau)); }
public Rover(Coordinate coordinate, OrientationState orientation, Plateau plateau) { Orientation = orientation; _plateau = plateau; _coordinate = coordinate; _coordinate.X = Math.Min(plateau.X1, Math.Max(coordinate.X, plateau.X0)); _coordinate.Y = Math.Min(plateau.Y1, Math.Max(coordinate.Y, plateau.Y0)); }
private Window.WindowOrientation ConvertOrientation(OrientationState state) { if (_screenOrientation == Window.WindowOrientation.Portrait) { if (state == OrientationState.Angle_90) { return(Window.WindowOrientation.Landscape); } else if (state == OrientationState.Angle_180) { return(Window.WindowOrientation.PortraitInverse); } else if (state == OrientationState.Angle_270) { return(Window.WindowOrientation.LandscapeInverse); } else { return(Window.WindowOrientation.Portrait); } } else { if (state == OrientationState.Angle_90) { return(Window.WindowOrientation.Portrait); } else if (state == OrientationState.Angle_180) { return(Window.WindowOrientation.LandscapeInverse); } else if (state == OrientationState.Angle_270) { return(Window.WindowOrientation.PortraitInverse); } else { return(Window.WindowOrientation.Landscape); } } }
void Update() { if( Input.GetKeyDown( KeyCode.Escape ) && !bGamePaused && !bLevelComplete ) { bGamePaused = true; if( onGamePaused != null ) onGamePaused(); } // Stop player from moving if they are currently falling or if the game is paused if( bCanMove && !bGamePaused ) { // MOVEMENT IF THE PLAYER PRESSES <LEFT>, <RIGHT>, <UP>, OR <DOWN> if( IsMovementKeyDown() ) { switch( orientationState ) { #region CASE: HORIZONTAL case OrientationState.HORIZONTAL: if( Input.GetKeyDown( KeyCode.RightArrow ) || Input.GetKeyDown( KeyCode.D ) ) { transform.RotateAround( transform.position + RIGHTHORZPIVOTOFFSET, Vector3.back, 90.0f ); orientationState = OrientationState.VERTICAL; SetLastKeyUsed( "R" ); } else if( Input.GetKeyDown( KeyCode.LeftArrow ) || Input.GetKeyDown( KeyCode.A ) ) { transform.RotateAround( transform.position + LEFTHORZPIVOTOFFSET, Vector3.forward, 90.0f ); orientationState = OrientationState.VERTICAL; SetLastKeyUsed( "L" ); } else if( Input.GetKeyDown( KeyCode.UpArrow ) || Input.GetKeyDown( KeyCode.W ) ) { transform.RotateAround( transform.position + UPHORZPIVOTOFFSET, Vector3.right, 90.0f ); SetLastKeyUsed( "U" ); } else if( Input.GetKeyDown( KeyCode.DownArrow ) || Input.GetKeyDown( KeyCode.S ) ) { transform.RotateAround( transform.position + DOWNHORZPIVOTOFFSET, Vector3.left, 90.0f ); SetLastKeyUsed( "D" ); } bTouchingATile = false; EventAggregatorManager.Publish(new PlaySoundMessage("hotdogStep", false)); break; #endregion #region CASE: VERTICAL case OrientationState.VERTICAL: if( Input.GetKeyDown( KeyCode.RightArrow ) || Input.GetKeyDown( KeyCode.D ) ) { transform.RotateAround( transform.position + RIGHTVERTPIVOTOFFSET, Vector3.back, 90.0f ); orientationState = OrientationState.HORIZONTAL; SetLastKeyUsed( "R" ); } else if( Input.GetKeyDown( KeyCode.LeftArrow ) || Input.GetKeyDown( KeyCode.A ) ) { transform.RotateAround( transform.position + LEFTVERTPIVOTOFFSET, Vector3.forward, 90.0f ); orientationState = OrientationState.HORIZONTAL; SetLastKeyUsed( "L" ); } else if( Input.GetKeyDown( KeyCode.UpArrow ) || Input.GetKeyDown( KeyCode.W ) ) { transform.RotateAround( transform.position + UPVERTPIVOTOFFSET, Vector3.right, 90.0f ); orientationState = OrientationState.VERTANDHORZ; SetLastKeyUsed( "U" ); } else if( Input.GetKeyDown( KeyCode.DownArrow ) || Input.GetKeyDown( KeyCode.S ) ) { transform.RotateAround( transform.position + DOWNVERTPIVOTOFFSET, Vector3.left, 90.0f ); orientationState = OrientationState.VERTANDHORZ; SetLastKeyUsed( "D" ); } bTouchingATile = false; EventAggregatorManager.Publish(new PlaySoundMessage("hotdogStep", false)); break; #endregion #region CASE: VERTICAL & HORIZONTAL case OrientationState.VERTANDHORZ: if( Input.GetKeyDown( KeyCode.RightArrow ) || Input.GetKeyDown( KeyCode.D ) ) { transform.RotateAround( transform.position + RIGHTVHPIVOTOFFSET, Vector3.back, 90.0f ); SetLastKeyUsed( "R" ); } else if( Input.GetKeyDown( KeyCode.LeftArrow ) || Input.GetKeyDown( KeyCode.A ) ) { transform.RotateAround( transform.position + LEFTVHPIVOTOFFSET, Vector3.forward, 90.0f ); SetLastKeyUsed( "L" ); } else if( Input.GetKeyDown( KeyCode.UpArrow ) || Input.GetKeyDown( KeyCode.W ) ) { transform.RotateAround( transform.position + UPVHPIVOTOFFSET, Vector3.right, 90.0f ); orientationState = OrientationState.VERTICAL; SetLastKeyUsed( "U" ); } else if( Input.GetKeyDown( KeyCode.DownArrow ) || Input.GetKeyDown( KeyCode.S ) ) { transform.RotateAround( transform.position + DOWNVHPIVOTOFFSET, Vector3.left, 90.0f ); orientationState = OrientationState.VERTICAL; SetLastKeyUsed( "D" ); } bTouchingATile = false; EventAggregatorManager.Publish(new PlaySoundMessage("hotdogStep", false)); break; #endregion } iConveyorDelay = -1; } } }
public void SetPlayerOriginalOrientationState( int orientation ) { oStateOriginal = orientationState = (OrientationState)orientation; }
public void ResetPlayer() { transform.rotation = Quaternion.Euler( v3OriginalRotation ); // Reset the player's rotation transform.position = v3OriginalPosition; // Reset the player's position orientationState = oStateOriginal; // Reset the player's orientation state bCanMove = true; // Allow the player to move again bFalling = false; }
public void Get_North_For_InvalidCommand() { OrientationState orientation = CommandHelper.OrientationFactory("X"); Assert.AreSame(typeof(North), orientation.GetType()); }
public void Get_West_For_W() { OrientationState orientation = CommandHelper.OrientationFactory("W"); Assert.AreSame(typeof(West), orientation.GetType()); }
public void TurnRight() { Orientation = Orientation.TurnRight(); }
public void TurnLeft() { Orientation = Orientation.TurnLeft(); }