private void SwitchTurningDirection() { if (_turningDirection == TurningDirection.Right) _turningDirection = TurningDirection.Left; else _turningDirection = TurningDirection.Right; }
public static void StopFollowingWaypoints() { if (m_FollowingWaypoints) { m_FollowingWaypoints = false; m_StopWaypointEventWaitHandle.WaitOne(); m_TurningDirection = TurningDirection.None; } }
public void Shuffle(int numberOfTurns = 100) { Random rnd = new Random(); for (int i = 0; i < numberOfTurns; i++) { int faceInt = rnd.Next(6); RubiksDirection face = default(RubiksDirection); if (faceInt == 0) { face = RubiksDirection.Back; } else if (faceInt == 1) { face = RubiksDirection.Down; } else if (faceInt == 2) { face = RubiksDirection.Front; } else if (faceInt == 3) { face = RubiksDirection.Left; } else if (faceInt == 4) { face = RubiksDirection.Right; } else if (faceInt == 5) { face = RubiksDirection.Up; } int turningDirectionInt = rnd.Next(3); TurningDirection turningDirection = default(TurningDirection); if (turningDirectionInt == 0) { turningDirection = TurningDirection.ThreeoClock; } else if (turningDirectionInt == 1) { turningDirection = TurningDirection.SixoClock; } else if (turningDirectionInt == 2) { turningDirection = TurningDirection.NineoClock; } int numberOfLayersDeep = rnd.Next(CubeSize - 1); Turn(face, turningDirection, numberOfLayersDeep); } }
public void ManuallyTurn(int rotNum, TurningDirection direction) { switch (direction) { case TurningDirection.Forward: workingRotors[rotNum].ForwardTurn(); break; case TurningDirection.Reverse: workingRotors[rotNum].ReverseTurn(); break; } }
public bool canRotate(Transform transform, TurningDirection direction) { var angle = transform.eulerAngles.y; Debug.Log("rotating " + Mathf.DeltaAngle(angle, 0)); if (Math.Abs(Mathf.DeltaAngle(angle, 0)) < 2) { //FORWARD switch (direction) { case TurningDirection.LEFT: return(LeftOpen); case TurningDirection.RIGHT: return(RightOpen); } } if (Math.Abs(Mathf.DeltaAngle(angle, 270)) < 2) { //LEFT switch (direction) { case TurningDirection.LEFT: return(BackOpen); case TurningDirection.RIGHT: return(FrontOpen); } } if (Math.Abs(Mathf.DeltaAngle(angle, 90)) < 2) { //RIGHT switch (direction) { case TurningDirection.LEFT: return(FrontOpen); case TurningDirection.RIGHT: return(BackOpen); } } if (Math.Abs(Mathf.DeltaAngle(angle, 180)) < 2) { //BACK switch (direction) { case TurningDirection.LEFT: return(RightOpen); case TurningDirection.RIGHT: return(LeftOpen); } } return(false); }
public override void Move() { base.Move(); if (currentAngle >= MAX_TURN_DEGREES) { direction = TurningDirection.right; } else if (currentAngle <= -MAX_TURN_DEGREES) { direction = TurningDirection.left; } currentAngle += Time.deltaTime * SPEED * (float)direction; }
public void Turn(TurningDirection turningDirection) { ITurn turning = _mapDirection[CurrentDirection]; if (turningDirection == TurningDirection.R) { CurrentDirection = turning.TurnRight(); } if (turningDirection == TurningDirection.L) { CurrentDirection = turning.TurnLeft(); } }
public void TurnRotor(int rotorNum, TurningDirection direction) { Rotor rot = enigma.GetRotor(rotorNum); switch (direction) { case TurningDirection.Forward: rot.ForwardTurn(); break; case TurningDirection.Reverse: rot.ReverseTurn(); break; } UpdateWindows(); }
public void Turn(RubiksDirection side, TurningDirection direction = TurningDirection.ThreeoClock, int numberOfLayersDeep = 0) { TurningDirection modifiedDirection = direction; if (side == RubiksDirection.Back || side == RubiksDirection.Left || side == RubiksDirection.Down) { modifiedDirection = direction.InvertTurningDirection(); } IDictionary <Position, Position> oldNewPositions = _faces[side].Move(modifiedDirection, numberOfLayersDeep); IEnumerable <KeyValuePair <Cubie, Position> > cubieToNewPositionPairs = oldNewPositions.Select (pair => new KeyValuePair <Cubie, Position>(this[pair.Key], pair.Value)).ToList(); foreach (KeyValuePair <Cubie, Position> cubieToNewPositionPair in cubieToNewPositionPairs) { Cubie cubieToMove = cubieToNewPositionPair.Key; switch (side) { case RubiksDirection.Front: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.Y, modifiedDirection); break; case RubiksDirection.Back: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.Y, modifiedDirection); break; case RubiksDirection.Up: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.Z, modifiedDirection); break; case RubiksDirection.Down: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.Z, modifiedDirection); break; case RubiksDirection.Left: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.X, modifiedDirection); break; case RubiksDirection.Right: cubieToMove.Move(cubieToNewPositionPair.Value, Axes.X, modifiedDirection); break; default: break; } } OnCubeTurned(side, direction, numberOfLayersDeep); }
public TurningDirection turningDirection = TurningDirection.touchpad; // setting: the way by which to determine the turning direction // methods // // methods for: determining turning direction // // method: determine the sign factor for the given turning direction // public float signFactorForTurningDirection(TurningDirection turningDirection) { if (turningDirection == TurningDirection.touchpad) { return((controller.touchpadX >= 0f) ? 1f : -1f); } else if (turningDirection == TurningDirection.left) { return(-1f); } else // (if the turning direction is right) { return(1f); } }
public static TurningDirection InvertTurningDirection(this TurningDirection direction) { switch (direction) { case TurningDirection.ThreeoClock: return(TurningDirection.NineoClock); case TurningDirection.SixoClock: return(TurningDirection.SixoClock); case TurningDirection.NineoClock: return(TurningDirection.ThreeoClock); default: return(default(TurningDirection)); } }
/// <summary> /// Konstruktor /// </summary> /// <param name="numberOfElements"> ilośc elementów z którch ma się składać pojedyncza helisa</param> /// <param name="totalAngle"> kąt o jaki ma się obrócić ostatni element</param> /// <param name="radius"> odległośc elementów od osi tunelu</param> /// <param name="Length"> dłogość helisy</param> /// <param name="turningDirection"> kierunek skrętu helisy</param> /// <param name="multiplicity"> krotność helisy</param> public Helix( uint numberOfElements, float totalAngle, float radius, float Length, TurningDirection turningDirection = TurningDirection.Right, uint multiplicity = 1 ) : base() { this.numberOfElements = numberOfElements; this.radius = radius; this.totalAngle = defaultAngle = totalAngle; this.Length = defaultLength = Length; this.turningDirection = turningDirection; this.multiplicity = defaultMulticiplity = multiplicity; this.angleOffset = totalAngle / numberOfElements; this.positionOffset = Length / numberOfElements; }
public void TurnRotor(int rotNum, TurningDirection direction) { Rotor rot = this.machine.Rotors[rotNum]; if (rot == null) { return; } rot.Turn(direction); this.PartInfo.UpdateRotorWindows(); }
public void Move(Position newPosition, Axes axisOfRotation, TurningDirection direction) { Position = newPosition; if (axisOfRotation == Axes.X) { RubiksColor?newFront = null; RubiksColor?newUp = null; RubiksColor?newBack = null; RubiksColor?newDown = null; if (direction == TurningDirection.ThreeoClock) { newFront = DownSide; newUp = FrontSide; newBack = UpSide; newDown = BackSide; } else if (direction == TurningDirection.SixoClock) { newFront = BackSide; newUp = DownSide; newBack = FrontSide; newDown = UpSide; } else { newFront = UpSide; newUp = BackSide; newBack = DownSide; newDown = FrontSide; } FrontSide = newFront; UpSide = newUp; BackSide = newBack; DownSide = newDown; } else if (axisOfRotation == Axes.Y) { RubiksColor?newUp = null; RubiksColor?newLeft = null; RubiksColor?newDown = null; RubiksColor?newRight = null; if (direction == TurningDirection.ThreeoClock) { newUp = LeftSide; newLeft = DownSide; newDown = RightSide; newRight = UpSide; } else if (direction == TurningDirection.SixoClock) { newUp = DownSide; newLeft = RightSide; newDown = UpSide; newRight = LeftSide; } else { newUp = RightSide; newLeft = UpSide; newDown = LeftSide; newRight = DownSide; } UpSide = newUp; LeftSide = newLeft; DownSide = newDown; RightSide = newRight; } else { RubiksColor?newFront = null; RubiksColor?newLeft = null; RubiksColor?newBack = null; RubiksColor?newRight = null; if (direction == TurningDirection.ThreeoClock) { newFront = RightSide; newLeft = FrontSide; newBack = LeftSide; newRight = BackSide; } else if (direction == TurningDirection.SixoClock) { newFront = BackSide; newLeft = RightSide; newBack = FrontSide; newRight = LeftSide; } else { newFront = LeftSide; newLeft = BackSide; newBack = RightSide; newRight = FrontSide; } FrontSide = newFront; LeftSide = newLeft; BackSide = newBack; RightSide = newRight; } }
public void TurnRight(TurningDirection direction = TurningDirection.ThreeoClock, int layersDeep = 0) { Turn(RubiksDirection.Right, direction, layersDeep); }
public void TurnBack(TurningDirection direction = TurningDirection.ThreeoClock, int layersDeep = 0) { Turn(RubiksDirection.Back, direction, layersDeep); }
internal void Turn(TurningDirection direction) { switch (direction) { case TurningDirection.Forward: this.CurrentPosition++; this.CurrentPosition %= 26; break; case TurningDirection.Reverse: this.CurrentPosition--; if (this.CurrentPosition < 0) { this.CurrentPosition += 26; } break; } }
public WallFollowerSolver(TurningDirection turningDirection) { this.turningDirection = turningDirection; visited = new List <CellPosition>(); }
public override void SetHighPriorityTarget(Transform target) { base.SetHighPriorityTarget(target); direction = TurningDirection.pause; currentAngle = 0; }
public static void FollowWaypoints(bool loop) { if (!m_FollowingWaypoints) { if (m_XCoordinates.Count == 0 || m_YCoordinates.Count == 0) { return; } m_FollowingWaypoints = true; Helper.WaitSeconds(1); Input.KeyDown(VirtualKeyCode.VK_W); Task.Run(() => { while (m_FollowingWaypoints) { WowApi.Sync.WaitOne(); double distanceToWaypoint = Math.Sqrt(Math.Pow(m_XCoordinates[m_WaypointIndex] - WowApi.PlayerData.PlayerXPosition, 2) + Math.Pow(m_YCoordinates[m_WaypointIndex] - WowApi.PlayerData.PlayerYPosition, 2)); if (distanceToWaypoint > ClosestPointDistance) { FindClosestWaypoint(); } double actualHeading_x = (WowApi.PlayerData.PlayerXPosition - Math.Sin(WowApi.PlayerData.PlayerHeading)) - WowApi.PlayerData.PlayerXPosition; double actualHeading_y = (WowApi.PlayerData.PlayerYPosition - Math.Cos(WowApi.PlayerData.PlayerHeading)) - WowApi.PlayerData.PlayerYPosition; double desiredHeading_x = m_XCoordinates[m_WaypointIndex] - WowApi.PlayerData.PlayerXPosition; double desiredHeading_y = m_YCoordinates[m_WaypointIndex] - WowApi.PlayerData.PlayerYPosition; double requriedTurn = Math.Atan2(actualHeading_x * desiredHeading_y - actualHeading_y * desiredHeading_x, actualHeading_x * desiredHeading_x + actualHeading_y * desiredHeading_y); if (Math.Abs(requriedTurn) < TurnToleranceRad) { if (m_TurningDirection != TurningDirection.None) { Input.KeyUp(VirtualKeyCode.VK_D); Input.KeyUp(VirtualKeyCode.VK_A); } m_TurningDirection = TurningDirection.None; } else if (requriedTurn > 0) { if (m_TurningDirection != TurningDirection.Right) { Input.KeyUp(VirtualKeyCode.VK_A); Input.KeyDown(VirtualKeyCode.VK_D); } m_TurningDirection = TurningDirection.Right; } else if (requriedTurn < 0) { if (m_TurningDirection != TurningDirection.Left) { Input.KeyUp(VirtualKeyCode.VK_D); Input.KeyDown(VirtualKeyCode.VK_A); } m_TurningDirection = TurningDirection.Left; } Jitterizer.RandomJitter(); bool xReached = Math.Abs(WowApi.PlayerData.PlayerXPosition - m_XCoordinates[m_WaypointIndex]) < PositionTolerance; bool yReached = Math.Abs(WowApi.PlayerData.PlayerYPosition - m_YCoordinates[m_WaypointIndex]) < PositionTolerance; if (xReached && yReached) { if (m_WaypointIndex == (m_XCoordinates.Count - 1)) { if (!loop) { break; } m_XCoordinates.Reverse(); m_YCoordinates.Reverse(); m_WaypointIndex = 0; } m_WaypointIndex++; } } Input.KeyUp(VirtualKeyCode.VK_W); Input.KeyUp(VirtualKeyCode.VK_A); Input.KeyUp(VirtualKeyCode.VK_D); m_StopWaypointEventWaitHandle.Set(); }); } }
public CubeTurnedEvent(RubiksDirection faceTurned, TurningDirection directionOfTurn, int numberOfLayersDeep) { FaceTurned = faceTurned; DirectionOfTurn = directionOfTurn; NumberOfLayersDeep = numberOfLayersDeep; }