// Use this for initialization void Start() { state = RotationState.stay; controller = new Controller(); controller.EnableGesture(Gesture.GestureType.TYPESWIPE); controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP); controller.Config.SetFloat("Gesture.Swipe.MinVelocity", 750f); controller.Config.Save(); cooldown = 0; }
public MoveRotate(MovementState movement, RotationState rotation, List<RoomItem> items, int delay, Room room, WiredHandler handler, uint itemID) { this.movement = movement; this.rotation = rotation; this.items = items; this.delay = delay; this.room = room; this.handler = handler; this.cycles = 0; this.itemID = itemID; this.isDisposed = false; }
public void AddFirstTile(Vector2 entPos, MapGenerator.TrackTile tile, Vector2 direct, RotationState rotState, bool isCurve) { direction = direct; originalInfo = tile; index = tile.index; entrancePos = entPos; size = new Vector2(tile.SizeX, tile.SizeY); step = new Vector2(tile.StepX, tile.StepY); rotation = rotState; outPutRot = RotationState.Left; isCurved = tile.isCurve; ExitPos(); }
public void AddTile(MapGenerator.TrackTile tile, Tile LastTile) { entrancePos = LastTile.exitPos; rotAnterior = LastTile.outPutRot; isTheLastACurve = LastTile.isCurved; index = tile.index; isCurved = tile.isCurve; size = new Vector2(tile.SizeX, tile.SizeY); step = new Vector2(tile.StepX, tile.StepY); originalInfo = tile; AjustRotation(); }
public void ActivateFlipper() { if ((_rotState == RotationState.None) && ((Time.time - _timeSinceLastActivation) >= CooldownTime)) { _timeSinceLastActivation = Time.time; _rotSpeedUp = new Vector3(VelocityUp, 0.0f, 0.0f); _rotSpeedDown = new Vector3(VelocityDown, 0.0f, 0.0f); _rotTotal = 0.0f; _rotState = RotationState.Up; } }
private void BroadcastRotationStateChange(bool right, RotationState current, RotationState previous) { if (current == previous) { return; } if (right) { RightRotationStateChanged?.Invoke(current, previous); } else { LeftRotationStateChanged?.Invoke(current, previous); } }
//-------------------------------------------------------------------------------------------- void Update() { if (Input.GetMouseButtonDown(0)) { m_currAxis = 0.0f; Rotation = RotationState.MANUAL; } else if (Input.GetMouseButton(0)) { m_currAxis = Mathf.Abs(Input.GetAxis("Mouse X")); if (m_prevAxis < Input.GetAxis("Mouse X")) { m_direction = -1; } if (m_prevAxis > Input.GetAxis("Mouse X")) { m_direction = 1; } transform.Rotate(Vector3.up, -Input.GetAxis("Mouse X")); m_prevAxis = -Input.GetAxis("Mouse X"); } if (Input.GetMouseButtonUp(0)) { Rotation = RotationState.AUTO; } if (m_rotationState == RotationState.AUTO) { if (m_currAxis > AutoRotationSpeed) { m_currAxis -= 0.05f; } if (m_rotationState == RotationState.STOP) { return; } if (m_currAxis < AutoRotationSpeed) { m_currAxis += 0.05f; } } transform.Rotate(Vector3.up, m_currAxis * m_direction); }
private IEnumerator AnimateHide() { if (m_VisibilityCoroutine != null) { yield break; } m_VisibilityState = VisibilityState.TransitioningOut; foreach (var face in m_MenuFaces) { face.Hide(); } if (m_FrameRevealCoroutine != null) { StopCoroutine(m_FrameRevealCoroutine); } m_FrameRevealCoroutine = StartCoroutine(AnimateFrameReveal(m_VisibilityState)); const float kTargetScale = 0f; const float kSmoothTime = 0.06875f; var scale = transform.localScale.x; var smoothVelocity = 0f; var currentDuration = 0f; while (currentDuration < kSmoothTime) { scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.unscaledDeltaTime); currentDuration += Time.unscaledDeltaTime; transform.localScale = Vector3.one * scale; m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; yield return(null); } gameObject.SetActive(false); m_VisibilityState = VisibilityState.Hidden; float snapRotation = GetRotationForFaceIndex(GetClosestFaceIndexForRotation(currentRotation)); m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, snapRotation, 0)); // set intended target rotation m_RotationState = RotationState.AtRest; m_VisibilityCoroutine = null; }
public void Start() { try { if (State == RotationState.Stopped) { Log.Write("Starting PixelBuddy...", Color.Green); pause.Set(); State = RotationState.Running; } } catch (Exception ex) { Log.Write("Error Starting Combat Routine", Color.Red); Log.Write(ex.Message, Color.Red); } }
public override void RotateTetromino(RotationState currentRotationState) { Point oldLocation = new Point(Shape[0].Left, Shape[0].Top); if (currentRotationState == RotationState.Default) { if (Shape[0].Left >= TetrisConfig.BlockSize) { for (int i = 0; i < Shape.Length; i++) { Shape[i].Top = oldLocation.Y + (i - 1) * TetrisConfig.BlockSize; if (i >= 2) { Shape[i].Top = oldLocation.Y + (i - 2) * TetrisConfig.BlockSize; } Shape[i].Left = oldLocation.X; if (i >= 2) { Shape[i].Left = oldLocation.X - TetrisConfig.BlockSize; } } this.RotationState = RotationState.Left; } } else { if (Shape[0].Left + TetrisConfig.BlockSize * 2 <= TetrisConfig.getFieldWidth()) { for (int i = 0; i < Shape.Length; i++) { Shape[i].Left = oldLocation.X - i * TetrisConfig.BlockSize; if (i >= 2) { Shape[i].Left = oldLocation.X + (i - 2) * TetrisConfig.BlockSize; } Shape[i].Top = oldLocation.Y + TetrisConfig.BlockSize; if (i >= 2) { Shape[i].Top = oldLocation.Y + 2 * TetrisConfig.BlockSize; } } this.RotationState = RotationState.Default; } } }
public void Pause() { try { if (State == RotationState.Running) { Log.Write("PixelBuddy has stopped.", Color.Red); Stop(); pause.Reset(); State = RotationState.Stopped; } } catch (Exception ex) { Log.Write("Error Stopping PixelBuddy", Color.Red); Log.Write(ex.Message, Color.Red); } }
private static RotationState Invalidate(RotationState state) { if (state is Reversing reversing) { return(new Reversing(reversing.Ok - 1, reversing.F, reversing.Fp, reversing.R, reversing.Rp)); } if (state is Appending appending) { if (appending.Ok == 0) { return(new Done(List <T> .Tail(appending.Rp))); } return(new Appending(appending.Ok - 1, appending.Fp, appending.Rp)); } return(state); }
void AjustStep(RotationState CurrRotation) { if (originalInfo.changeAxis) { if (CurrRotation == RotationState.Up) { step = new Vector2(-originalInfo.StepX, originalInfo.StepY); } if (CurrRotation == RotationState.Right) { step = new Vector2(originalInfo.StepY, originalInfo.StepX); } if (CurrRotation == RotationState.Down) { step = new Vector2(originalInfo.StepX, -originalInfo.StepY); } if (CurrRotation == RotationState.Left) { step = new Vector2(-originalInfo.StepY, -originalInfo.StepX); } } else { if (CurrRotation == RotationState.Up) { step = new Vector2(originalInfo.StepY, originalInfo.StepX); } if (CurrRotation == RotationState.Right) { step = new Vector2(-originalInfo.StepX, -originalInfo.StepY); } if (CurrRotation == RotationState.Down) { step = new Vector2(originalInfo.StepY, -originalInfo.StepX); } if (CurrRotation == RotationState.Left) { step = new Vector2(originalInfo.StepX, originalInfo.StepY); } } //Debug.Log("Rotation: " + CurrRotation); //Debug.Log("Step: " + step); stepBack = step; }
public void MapKurzor(string Input) { LastInput = Input; if (Input == "w") { if (Kurzor.PosY > 1) { Kurzor.PosY--; } } else if (Input == "d") { if (Kurzor.PosX < MapSize) { Kurzor.PosX++; } } else if (Input == "s") { if (Kurzor.PosY < MapSize) { Kurzor.PosY++; } } else if (Input == "a") { if (Kurzor.PosX > 1) { Kurzor.PosX--; } } else if (Input == "e") { Rotate = RotationState.Right; } else if (Input == "q") { Rotate = RotationState.Doleva; } else if (Input == " ") { Place = true; } }
private IEnumerator AnimateFrameRotationShapeChange(RotationState rotationState) { float smoothTime = rotationState == RotationState.Rotating ? 0.5f : 0.0375f; // slower when rotating, faster when snapping float currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(0); float targetWeight = rotationState == RotationState.Rotating ? 100f : 0f; float smoothVelocity = 0f; while (m_RotationState == rotationState && !Mathf.Approximately(currentBlendShapeWeight, targetWeight)) { currentBlendShapeWeight = Mathf.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.unscaledDeltaTime); m_MenuFrameRenderer.SetBlendShapeWeight(0, currentBlendShapeWeight); yield return(null); } if (m_RotationState == rotationState) { m_MenuFrameRenderer.SetBlendShapeWeight(0, targetWeight); } }
public bool CheckRotation(int afterMoveX = 0, int afterMoveY = 0) { Vector3 start = transform.position - playfieldStart + new Vector3(afterMoveX, afterMoveY); int startX = (int)(start.x + 0.5f); int startY = (int)(start.y - 0.5f); switch (rotationState) { case RotationState.FirstQuarter: startX -= rotationSpaceSize; break; case RotationState.Reverse: startX -= rotationSpaceSize; startY += rotationSpaceSize; break; case RotationState.ThirdQuarter: startY += rotationSpaceSize; break; } if (startX < 0 || startX + rotationSpaceSize > 10 || startY - rotationSpaceSize < -1) { return(false); } for (int x = startX; x < startX + rotationSpaceSize; x++) { for (int y = startY; y < startY - rotationSpaceSize; y++) { if (playGrid[y][x]) { return(false); } } } int number = ((int)rotationState + 1) % 4; rotationState = (RotationState)number; return(true); }
private void Awake() { anim = GetComponent <Animator>(); anim.SetBool("State1", true); rotationState = GetComponentInParent <RotationState>(); if (state1) { rightState = true; } if (state2) { rightState = true; } if (state3) { rightState = true; } }
public void GetNextRotationStateAndPositionOffSets(out List <Vector3> positionOffsets, out Vector3 rotation) { if (rotationList == null || rotationList.Count == 0) { rotation = Vector3.zero; positionOffsets = new List <Vector3>() { Vector3.zero }; } else { // Loops back to 0 if it's the same length of array currentRotationIndex = ((currentRotationIndex + 1) % rotationList.Count); rotation = rotationList[currentRotationIndex]; rotationState = rotationStateList[currentRotationIndex]; positionOffsets = offSetList[currentRotationIndex].offsets; } }
// Update is called once per frame void Update() { if (TranslationLayer.instance.GetButtonDown(activeButton)) { state = RotationState.Up; } if (state == RotationState.Up) { float a = 990 * Time.deltaTime; currentRotationAmount += a; Quaternion q = Quaternion.AngleAxis(a * (dir == Direction.Clockwise ? 1 : -1), rotationAxis); rigidBody.MoveRotation(q * rigidBody.transform.rotation); rigidBody.MovePosition(q * (rigidBody.transform.position - target.transform.position) + target.transform.position); // transform.RotateAround(target.transform.position, rotationAxis, a * (dir == Direction.Clockwise ? 1 : -1)); if (currentRotationAmount >= 90) { state = RotationState.Down; } } else if (state == RotationState.Down) { float a = 630 * Time.deltaTime * -1; currentRotationAmount += a; if (currentRotationAmount <= 0) { a -= currentRotationAmount; currentRotationAmount = 0; state = RotationState.Rest; // reset position and rotation rigidBody.MoveRotation(initialRot); rigidBody.MovePosition(initialPos); } else { Quaternion q = Quaternion.AngleAxis(a * (dir == Direction.Clockwise ? 1 : -1), rotationAxis); rigidBody.MoveRotation(q * rigidBody.transform.rotation); rigidBody.MovePosition(q * (rigidBody.transform.position - target.transform.position) + target.transform.position); } // transform.RotateAround(target.transform.position, rotationAxis, a * (dir == Direction.Clockwise ? 1 : -1)); } }
public void Normalize() { if (state != RotationState.NON_NORMALIZED) { return; } double module = q.Module(); if (module < MathConstant.EPSYLON) { Reset(); return; } q.DivideAt(module); state = RotationState.TURN; CheckIdentity(); }
public void SetTurn(double heading, double elevation, double bank) { double cosHeading = Math.Cos(0.5 * heading); double sinHeading = Math.Sin(0.5 * heading); double cosElevation = Math.Cos(0.5 * elevation); double sinElevation = Math.Sin(0.5 * elevation); double cosBank = Math.Cos(0.5 * bank); double sinBank = Math.Sin(0.5 * bank); q.w = cosHeading * cosElevation * cosBank + sinHeading * sinElevation * sinBank; q.x = cosHeading * cosElevation * sinBank - sinHeading * sinElevation * cosBank; q.y = sinHeading * cosElevation * sinBank + cosHeading * sinElevation * cosBank; q.z = sinHeading * cosElevation * cosBank - cosHeading * sinElevation * sinBank; state = RotationState.TURN; CheckIdentity(); }
public void ShipRotate(RotationState rotate) //rotace lodi { if (rotate == RotationState.Right) { if (ShipRotationState == RotationState.Doleva) { ShipRotationState = RotationState.Up; } else { ShipRotationState++; } } else if (rotate == RotationState.Doleva) { if (ShipRotationState == RotationState.Up) { ShipRotationState = RotationState.Doleva; } else { ShipRotationState--; } } if (ShipRotationState == RotationState.Up) { ShipTiles = LodStav1; } else if (ShipRotationState == RotationState.Right) { ShipTiles = LodStav2; } else if (ShipRotationState == RotationState.Down) { ShipTiles = LodStav3; } else if (ShipRotationState == RotationState.Doleva) { ShipTiles = LodStav4; } }
private void _CalculateRotationState() { var angle = _getAngleRelatedCircularFloor(); if (angle < 90) { rotationState = RotationState.UpperRight; } else if (angle < 180) { rotationState = RotationState.LowerRight; } else if (angle < 270) { rotationState = RotationState.LowerLeft; } else { rotationState = RotationState.UpperLeft; } }
IEnumerator AnimateFrameRotationShapeChange(RotationState rotationState) { const float smoothTime = 0.0375f; const float targetWeight = 0f; var currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(0); var smoothVelocity = 0f; var currentDuration = 0f; while (m_RotationState == rotationState && currentDuration < smoothTime) { currentBlendShapeWeight = MathUtilsExt.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); currentDuration += Time.deltaTime; m_MenuFrameRenderer.SetBlendShapeWeight(0, currentBlendShapeWeight); yield return(null); } if (m_RotationState == rotationState) { m_MenuFrameRenderer.SetBlendShapeWeight(0, targetWeight); } }
private void Awake() { rightHandState = new TouchStates(); leftHandState = new TouchStates(); currentRightHandGestureState = HandGestureState.Neutral; currentLeftHandGestureState = HandGestureState.Neutral; currentRightRotationState = RotationState.lowerCase; currentLeftRotationState = RotationState.lowerCase; // track whether a currently held finger has passed the hold action threshold // index values match the order of the TouchStates enum rightHeldLong = new bool[3] { false, false, false }; leftHeldLong = new bool[3] { false, false, false }; _selectionRightStartingMarker = new GameObject("RightStartMarker"); _selectionLeftStartingMarker = new GameObject("LeftStartMarker"); }
private IEnumerator AnimateHide() { if (m_VisibilityCoroutine != null) { yield break; } m_VisibilityState = VisibilityState.TransitioningOut; foreach (var face in m_MenuFaces) { face.Hide(); } StartCoroutine(AnimateFrameReveal(m_VisibilityState)); const float kTargetScale = 0f; float scale = menuOrigin.localScale.x; float smoothVelocity = 0f; while (!Mathf.Approximately(scale, kTargetScale)) { menuOrigin.localScale = Vector3.one * scale; alternateMenuOrigin.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; scale = Mathf.SmoothDamp(scale, kTargetScale, ref smoothVelocity, 0.06875f, Mathf.Infinity, Time.unscaledDeltaTime); yield return(null); } m_VisibilityState = VisibilityState.Hidden; menuOrigin.localScale = Vector3.zero; alternateMenuOrigin.localScale = Vector3.zero; float snapRotation = GetRotationForFaceIndex(GetClosestFaceIndexForRotation(currentRotation)); m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, snapRotation, 0)); // set intended target rotation m_RotationState = RotationState.AtRest; m_VisibilityCoroutine = null; }
private static RotationState Exec(RotationState state) { if (state is Reversing reversing) { if (!List <T> .IsEmpty(reversing.F)) // && !List<T>.IsEmpty(reversing.R)) { var x = List <T> .Head(reversing.F); var f = List <T> .Tail(reversing.F); var y = List <T> .Head(reversing.R); var r = List <T> .Tail(reversing.R); return(new Reversing(reversing.Ok + 1, f, List <T> .Cons(x, reversing.Fp), r, List <T> .Cons(y, reversing.Rp))); } var y2 = List <T> .Head(reversing.R); return(new Appending(reversing.Ok, reversing.Fp, List <T> .Cons(y2, reversing.Rp))); } if (state is Appending appending) { if (appending.Ok == 0) { return(new Done(appending.Rp)); } var x = List <T> .Head(appending.Fp); var fp = List <T> .Tail(appending.Fp); return(new Appending(appending.Ok - 1, fp, List <T> .Cons(x, appending.Rp))); } return(state); }
private void SetCanonAngle() { switch (_rotationState) { case RotationState.Idle: if (Input.GetButtonDown("Fire1")) { _rotationState = RotationState.Horizontal; } break; case RotationState.Horizontal: if (Input.GetButton("Fire1")) { transform.Rotate(new Vector3(0, horizontalRotateSpeed * Time.deltaTime, 0)); } else if (Input.GetButtonUp("Fire1")) { _rotationState = RotationState.Vertical; } break; case RotationState.Vertical: if (Input.GetButton("Fire1")) { transform.Rotate(new Vector3(-vertialRotateSpeed * Time.deltaTime, 0, 0)); } else if (Input.GetButtonUp("Fire1")) { _rotationState = RotationState.Ready; BallShooter.enabled = true; } break; case RotationState.Ready: break; } }
public void ContinuousNext() { if (selectedEntryIdx + CONTINUOUS_COUNT <= pickerEntries.Count - 1) { destEntryIdx = selectedEntryIdx + CONTINUOUS_COUNT; } else { destEntryIdx = pickerEntries.Count - 1; } int nextEntryIdx = -1; if (selectedEntryIdx == pickerEntries.Count - 1) { return; } else { nextEntryIdx = selectedEntryIdx + 1; } if (pickerEntries[nextEntryIdx].Puzzle.IsLocked) { AudioManager.PlayCue("locked"); rotState = RotationState.LockedNext; lockedState = LockedState.Clear1; } else { AudioManager.PlayCue("puzzlePickerShuffle"); rotState = RotationState.ContinuousNext; unselectedEntryIdx = nextEntryIdx; UnselectedPickerEntry.Rotation = ANCHOR_ROTATE_HALF; } }
// Update is called once per frame void Update() { if (cooldown > 0) { cooldown -= Time.deltaTime; if (state == RotationState.right) foreach (Transform child in transform) child.RotateAround(Vector3.zero, Vector3.up, 288 * Time.deltaTime); else if (state == RotationState.left) foreach (Transform child in transform) child.RotateAround(Vector3.zero, Vector3.up, -288 * Time.deltaTime); } else { state = RotationState.stay; Frame frame = controller.Frame(); GestureList gestures = frame.Gestures(); for (int i = 0; i < gestures.Count; i++) { Gesture gesture = gestures[i]; if (gesture.Type == Gesture.GestureType.TYPESWIPE) { SwipeGesture swipe = new SwipeGesture(gesture); Vector dir = swipe.Direction; if (dir.y < -Mathf.Abs(dir.x) && !Selection.inSelection) Selection.Select(); else if (dir.y > Mathf.Abs(dir.x)) Selection.Unselect(); else if (dir.x < 0 && !Selection.inSelection) state = RotationState.right; else if (!Selection.inSelection) state = RotationState.left; cooldown = 15 * Time.deltaTime; } } } }
IEnumerator AnimateHide() { m_VisibilityState = VisibilityState.TransitioningOut; foreach (var kvp in m_Faces) { var face = kvp.Value; face.visible = false; face.ClearSubmenus(); } this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); const float kTargetScale = 0f; const float kSmoothTime = 0.06875f; var scale = transform.localScale.x; var smoothVelocity = 0f; var currentDuration = 0f; while (currentDuration < kSmoothTime) { scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); currentDuration += Time.deltaTime; transform.localScale = Vector3.one * scale; m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; yield return(null); } gameObject.SetActive(false); m_VisibilityState = VisibilityState.Hidden; var snapRotation = GetRotationForFaceIndex(GetClosestFaceIndexForRotation(currentRotation)); m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, snapRotation, 0)); // set intended target rotation m_RotationState = RotationState.AtRest; }
private IEnumerator SnapToFace(int faceIndex, float snapSpeed) { if (m_RotationState == RotationState.Snapping) { yield break; } m_RotationState = RotationState.Snapping; // When the user releases their input while rotating the menu, snap to the nearest face StartCoroutine(AnimateFrameRotationShapeChange(m_RotationState)); foreach (var face in m_MenuFaces) { face.EndVisuals(); } float rotation = currentRotation; float faceTargetRotation = GetRotationForFaceIndex(faceIndex); float smoothVelocity = 0f; float smoothSnapSpeed = 0.5f; while (Mathf.Abs(Mathf.DeltaAngle(rotation, faceTargetRotation)) > kRotationEpsilon) { smoothSnapSpeed = Mathf.SmoothDamp(smoothSnapSpeed, snapSpeed, ref smoothVelocity, 0.0625f, Mathf.Infinity, Time.unscaledDeltaTime); rotation = Mathf.LerpAngle(rotation, faceTargetRotation, Time.unscaledDeltaTime * smoothSnapSpeed); m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, rotation, 0)); yield return(null); } m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, faceTargetRotation, 0)); // Target face index and rotation can be set separately, so both, must be kept in sync targetRotation = faceTargetRotation; m_RotationState = RotationState.AtRest; }
public void LoadFromDatabase(IQueryAdapter dbClient, Room insideRoom) { dbClient.setQuery("SELECT trigger_data FROM trigger_item WHERE trigger_id = @id "); dbClient.addParameter("id", (int)this.itemID); this.delay = dbClient.getInteger(); dbClient.setQuery("SELECT rotation_status, movement_status FROM trigger_rotation WHERE item_id = @id"); dbClient.addParameter("id", (int)this.itemID); DataRow dRow = dbClient.getRow(); if (dRow != null) { this.rotation = (RotationState)Convert.ToInt32(dRow[0]); this.movement = (MovementState)Convert.ToInt32(dRow[1]); } else { rotation = RotationState.none; movement = MovementState.none; } dbClient.setQuery("SELECT triggers_item FROM trigger_in_place WHERE original_trigger = " + this.itemID); DataTable dTable = dbClient.getTable(); RoomItem targetItem; foreach (DataRow dRows in dTable.Rows) { targetItem = insideRoom.GetRoomItemHandler().GetItem(Convert.ToUInt32(dRows[0])); if (targetItem == null || this.items.Contains(targetItem)) { continue; } this.items.Add(targetItem); } }
public void rotateMe() { switch (currentState) { case RotationState.state1: iTween.RotateTo (gameObject, iTween.Hash ("rotation", new Vector3 (0, 0,(float)RotationState.state2 ))); currentState=RotationState.state2; break; case RotationState.state2: iTween.RotateTo (gameObject, iTween.Hash ("rotation", new Vector3 (0, 0,(float)RotationState.state3 ))); currentState=RotationState.state3; break; case RotationState.state3: iTween.RotateTo (gameObject, iTween.Hash ("rotation", new Vector3 (0, 0,(float)RotationState.state4 ))); currentState=RotationState.state4; break; case RotationState.state4: iTween.RotateTo (gameObject, iTween.Hash ("rotation", new Vector3 (0, 0,(float)RotationState.state1 ))); currentState=RotationState.state1; break; } }
private void ToTopLeft() { iTween.RotateTo(gameObject, iTween.Hash("z", -135, "time", tweenTime, "ignoretimescale", true)); if (rotation == RotationState.TOP) PlayerObject.setPos (-14f, 34.5f); else if (rotation == RotationState.LEFT) PlayerObject.setPos (-34.5f, 14f); rotation = RotationState.TOP_LEFT; iTween.RotateTo(PlayerObject.gameObject, iTween.Hash("time", rotateTime, "z", -135, "ignoretimescale", true)); }
protected virtual void RotateWest() { RotationState = RotationState.West; }
protected virtual void RotateSouth() { RotationState = RotationState.South; }
protected virtual void RotateNorth() { RotationState = RotationState.North; }
protected virtual void RotateEast() { RotationState = RotationState.East; }
// Use this for initialization void Start () { currentState = RotationState.state1; }
private void ToBottomRight() { iTween.RotateTo(gameObject, iTween.Hash("z", 45, "time", tweenTime, "ignoretimescale", true)); if (rotation == RotationState.BOTTOM) PlayerObject.setPos (14f, -34.5f); else if (rotation == RotationState.RIGHT) PlayerObject.setPos (34.5f, -14f); rotation = RotationState.BOTTOM_RIGHT; iTween.RotateTo(PlayerObject.gameObject, iTween.Hash("time", rotateTime, "z", 45, "ignoretimescale", true)); }
public void Start() { PlayerPos = new Vector2(); rotation = RotationState.BOTTOM; }
public RoverState(AccelerationState accState, RotationState rotState) { this.accState = accState; this.rotState = rotState; }
protected int HandleRotation(int oldRotation, RotationState state) { int rotation = oldRotation; switch (state) { case RotationState.clocwise: { HandleClockwiseRotation(ref rotation); return rotation; } case RotationState.counterClockwise: { HandleCounterClockwiseRotation(ref rotation); return rotation; } case RotationState.random: { if (rnd.Next(0, 3) == 1) { HandleClockwiseRotation(ref rotation); } else { HandleCounterClockwiseRotation(ref rotation); } return rotation; } } return rotation; }
private void ToTopRight() { iTween.RotateTo(gameObject, iTween.Hash("z", 135, "time", tweenTime, "ignoretimescale", true)); if (rotation == RotationState.RIGHT) PlayerObject.setPos (34.5f, 14f); else if (rotation == RotationState.TOP) PlayerObject.setPos (14f, 34.5f); rotation = RotationState.TOP_RIGHT; iTween.RotateTo(PlayerObject.gameObject, iTween.Hash("time", rotateTime, "z", 135, "ignoretimescale", true)); }
public void LoadFromWiredObject(WiredLoader.WiredLoaderObject loadedData) { this.rotation = (RotationState)loadedData.GetIntWithIndex(0, 0); this.movement = (MovementState)loadedData.GetIntWithIndex(1, 0); this.delay = loadedData.GetIntWithIndex(3); this.items = loadedData.items; AttatchListenersToItems(); }
public static RoverState Parse(String initString) { Char accStateChar = initString[0]; Char turnStateChar = initString[1]; AccelerationState accState; RotationState rotState; switch(accStateChar) { case 'a': accState = AccelerationState.Accelerating; break; case 'b': accState = AccelerationState.Braking; break; case '-': accState = AccelerationState.Rolling; break; default: throw new ArgumentOutOfRangeException("Can't parse acceleration state: " + accStateChar); } switch (turnStateChar) { case 'L': rotState = RotationState.HardLeft; break; case 'l': rotState = RotationState.Left; break; case '-': rotState = RotationState.Straight; break; case 'r': rotState = RotationState.Right; break; case 'R': rotState = RotationState.HardRight; break; default: throw new ArgumentOutOfRangeException("Can't parse rotation state: " + turnStateChar); } return new RoverState(accState, rotState); }
private void checkRotateValid(Piece piece) { if (isValid(piece)) { this.blocks = piece.blocks; } else { bool kicked = kick(piece); if (!kicked) { StackTrace stackTrace = new StackTrace(); if (stackTrace.GetFrame(2).GetMethod().Name == "rotateRight") rotationState = (RotationState)((mod((int)rotationState - 1, 4))); else rotationState = (RotationState)((mod((int)rotationState + 1, 4))); } } }
public void rotateRight() { clearOldPosition(); //Increase the RotationState by one, making sure to keep it in the bounds rotationState = (RotationState)((mod((int)rotationState + 1, 4))); switch(pieceType) { case BlockType.I: rotateI(); break; case BlockType.J: rotateJ(); break; case BlockType.L: rotateL(); break; case BlockType.O: return; case BlockType.S: rotateS(); break; case BlockType.T: rotateT(); break; case BlockType.Z: rotateZ(); break; } }
public static int HandleRotation(int oldRotation, RotationState state) { var rotation = oldRotation; switch (state) { case RotationState.ClocWise: { HandleClockwiseRotation(ref rotation); return rotation; } case RotationState.CounterClockWise: { HandleCounterClockwiseRotation(ref rotation); return rotation; } case RotationState.Random: { if (Azure.GetRandomNumber(0, 3) == 1) HandleClockwiseRotation(ref rotation); else HandleCounterClockwiseRotation(ref rotation); return rotation; } } return rotation; }