// Update is called once per frame void FixedUpdate() { if (Keyboard.current.qKey.isPressed) { isRotate = true; SetRotateValue(); } if (isRotate) { float deg = rotateState == RotateState.NoRotate ? 180.0f : 0; //transform.Rotate(rotateValue * rotateSpeed * Time.deltaTime); float angleSpeed = rotateValue * rotateSpeed * Time.deltaTime; angles[(int)rotateAxis] += angleSpeed; transform.rotation = transform.rotation * Quaternion.AngleAxis(angleSpeed, GetAxis()); if (IsRotateComplete(angles[(int)rotateAxis], deg)) { angles[(int)rotateAxis] = deg; isRotate = false; if (rotateState == RotateState.NoRotate) { rotateState = RotateState.Rotated; } else { rotateState = RotateState.NoRotate; } Singleton <NavMeshBaker> .Instance.Bake(); } } }
private void OnRotationStateChangeCall(RotateState rotateState) { RotateStateMashineArgs args = new RotateStateMashineArgs(); args.rotateState = rotateState; OnRotationStateChange(args); }
// Use this for initialization void Start() { sceneMgr = GameObject.FindObjectOfType <SceneManager> (); allowScale = false; rs = RotateState.NO_ROT; allowRotate = false; }
// 回転ステート変更関数setter public void Set_State(RotateState newState) { State = newState; switch (State) { case RotateState.INSIDE: //内側回転用の処理 fRadius = 5.0f; /*if (fDegree < 360.0f) { * fDegree += 360.0f; * }*/ break; case RotateState.OUTSIDE: //外側回転用処理 fRadius = 9.0f; /*if (fDegree > 360.0f) { * fDegree -= 360.0f; * }*/ break; default: break; } }
public virtual void Update() { if (m_active) { m_timer -= Time.deltaTime; if (m_timer < 0.0f) { m_timer = m_timeUnit; if (m_state == RotateState.Pause) { m_state = RotateState.Rotate; } } switch (m_state) { case RotateState.Pause: break; case RotateState.Rotate: m_rotatetimer -= Time.deltaTime; Rotate(m_speed * Time.deltaTime); if (m_rotatetimer < 0) { m_rotatetimer = m_rotateTime; m_ob.transform.rotation = m_rotateIdentity; m_state = RotateState.Pause; } break; } } }
public override void RotateLogic(bool?rotation) { if (rotation != null) { rotations.Push(rotation); } if (!Active && rotations.Count > 0) { bool rotationToTest = (bool)rotations.Pop(); if (rotationToTest == true && rotateState == RotateState.Standing) { RotateEntity(true); rotateState = RotateState.Fallen; } else if (rotationToTest == true && rotateState == RotateState.Fallen) { RotateEntity(false); rotateState = RotateState.Standing; } else if (rotationToTest == false && rotateState == RotateState.Fallen) { RotateEntity(false); rotateState = RotateState.Standing; } else if (rotationToTest == false && rotateState == RotateState.Standing) { RotateEntity(true); rotateState = RotateState.Fallen; } } }
// ��]�X�e�[�g�ύX��setter public void Set_State(RotateState newState) { State = newState; switch (State) { case RotateState.INSIDE: //�����]�p�̏��� fRadius = 5.0f; fDegreeSub = 180; if (fDegree < 360.0f) { fDegree += 360.0f; } break; case RotateState.OUTSIDE: //�O����]�p���� fRadius = 9.0f; fDegreeSub = 0.0f; if (fDegree > 360.0f) { fDegree -= 360.0f; } break; default: break; } }
//--------------------------------------------------------------------------------------------------- /// <summary> /// 旋转立方体ing /// </summary> private void UpdateRotateCube() { //旋转的角度 Vector3 rotateAngles = Vector3.zero; //通过玩家滑动的方向来判断立方体往哪边旋转 switch (rotateDirectionList[GameData.currentOrder]) { case RotateDirection.Left: rotateAngles = new Vector3(0, 90 / rotateTime, 0); break; case RotateDirection.Right: rotateAngles = new Vector3(0, -90 / rotateTime, 0); break; case RotateDirection.Down: rotateAngles = new Vector3(-90 / rotateTime, 0, 0); break; case RotateDirection.Up: rotateAngles = new Vector3(90 / rotateTime, 0, 0); break; } //旋转ing,根据世界坐标系 mainCube.transform.Rotate(rotateAngles, Space.World); //旋转增量,用来计算当前旋转了多少度 deltaRotateCount += (90 / rotateTime); //如果旋转超过了90度,则停止旋转 if (deltaRotateCount >= 90) { deltaRotateCount = 0; rotateState = RotateState.End; return; } }
// 回転ステート変更関数setter // 外側が0~360度、内側が360~720度 public void Set_State(RotateState newState) { State = newState; switch (State) { case RotateState.INSIDE: //内側回転用の処理 fRadius = 5.0f; fDegreeSub = -180; if (fDegree <= 360.0f) { fDegree += 360.0f; } break; case RotateState.OUTSIDE: //外側回転用処理 fRadius = 9.0f; fDegreeSub = 0; if (fDegree >= 360.0f) { fDegree -= 360.0f; } break; default: break; } }
protected override void Init() { base.Init(); _type = TYPE.NONE; _cntTime = -1; switch (_state) { case State.MAE: _q2 = Quaternion.Euler(0f, 0f, -90f);; break; case State.USHIRO: _q2 = Quaternion.Euler(0f, 0f, 90f);; break; case State.ZENKEI: _q2 = Quaternion.Euler(0f, 0f, -_zenkeiKakduo);; break; } _rotateState = RotateState.NORMAL; _cntLinearTime = 0; }
//--------------------------------------------------------------------------------------------------- /// <summary> /// 当旋转立方体结束时 /// </summary> private void EndRotateCube() { rotateState = RotateState.Start; if (rotateDirectionList[GameData.currentOrder] == RotateDirection.Left && leftTarget.currentArrow.sprite != leftArrow) { GameData.gameState = GameState.End; return; } if (rotateDirectionList[GameData.currentOrder] == RotateDirection.Right && rightTarget.currentArrow.sprite != rightArrow) { GameData.gameState = GameState.End; return; } if (rotateDirectionList[GameData.currentOrder] == RotateDirection.Up && upTarget.currentArrow.sprite != upArrow) { GameData.gameState = GameState.End; return; } if (rotateDirectionList[GameData.currentOrder] == RotateDirection.Down && downTarget.currentArrow.sprite != downArrow) { GameData.gameState = GameState.End; return; } GameData.score++; //分数+1 GameData.currentOrder++; //滑动次数+1 if (GameData.currentOrder % 10 == 0) { GameData.countdownSpeed++; //逐渐增加倒计时的速度 } CanvasManager.scoreText.text = "" + GameData.score; }
// Start is called before the first frame update void Start() { if (OnRotate == null) { OnRotate = new OnRotateEvent(); } rotateState = CheckRotateWithScreenSize(); }
public void Rotate(float _angle) { if (CardPrefab) { CardPrefab.transform.Rotate(CardAxisX, _angle); CardState = RotateState.Rotate; } }
public cardH(GameObject _card, Vector3 _pos, float speed) { CardHY = Object.Instantiate(_card, _pos, Quaternion.identity); RotateSpeed = 40.0f; Timer = 1.0f; CurrentPos = new Vector3(0, 0, 0); CardHYState = RotateState.Pause; }
public CardA(GameObject _cardprefab, Vector3 _pos, Quaternion _CardQuaternion) { RotateSpeed = 60.0f; RotateTimer = 2.0f; CardAxisX = new Vector3(-1, 0, 0); CardPrefab = GameObject.Instantiate(_cardprefab, _pos, _CardQuaternion); CardQuaternion = _CardQuaternion; CardState = RotateState.Pause; }
public override void ResetAll() { rotateState = RotateState.Standing; rotations = new Stack <bool?>(); active = false; RotationValue = 0.0f; base.ResetAll(); }
// Update is called once per frame void Update() { switch (_state) { case RotateState.Start: { _timePassed += Time.deltaTime; if (_timePassed >= _startDuration) { _state = RotateState.Running; } var len = _srcY + (_speedUp * _timePassed * _timePassed) / 2.0f; // Debug.Log (_state + " - " + len); this.transform.localRotation = Quaternion.Euler(new Vector3(0, len, 0)); } break; case RotateState.Running: { _timePassed += Time.deltaTime; if (_timePassed >= _startDuration + _runDuration) { _state = RotateState.End; } float delta = _timePassed - _startDuration; float v = _startDuration * _speedUp; var len = _srcY + _startLen + (v * delta); // Debug.Log (_state + " - " + len); this.transform.localRotation = Quaternion.Euler(new Vector3(0, len, 0)); } break; case RotateState.End: { _timePassed += Time.deltaTime; if (_timePassed >= _duration) { _timePassed = _duration; this.transform.localRotation = Quaternion.Euler(new Vector3(0, _desY, 0)); _state = RotateState.Stop; } else { float delta = _timePassed - (_startDuration + _runDuration); float v = _startDuration * _speedUp; var len = _srcY + _startLen + _runLen + (v * delta) + (_speedDown * delta * delta / 2.0f); // Debug.Log (_state + " - " + len); this.transform.localRotation = Quaternion.Euler(new Vector3(0, len, 0)); } } break; default: break; } }
public void RotateTo(bool left) { if (mRotateState == RotateState.Left || mRotateState == RotateState.Right) { return; } mRotateState = left ? RotateState.Left:RotateState.Right; StartCoroutine("_Coro_Rotate", left); }
//--------------------------------------------------------------------------------------------------- /// <summary> /// 开始旋转立方体 /// </summary> private void StartRotateCube() { //旋转的状态变为Update rotateState = RotateState.Update; //随机生成下一个箭头方向 GenerateNext(); GameData.countdownTime = 5.0f; }
// Update is called once per frame void Update() { RotateState newState = CheckRotate(); if (newState != rotateState) { rotateState = newState; OnRotate?.Invoke(rotateState); } }
public CardBase(Vector3 _pos) { GameObject prefab = Resources.Load(m_path) as GameObject; m_ob = GameObject.Instantiate(prefab, _pos, Quaternion.identity); m_text = m_ob.transform.Find("ad_number").GetComponent <TextMesh>(); this.m_state = RotateState.Pause; m_rotateIdentity = Quaternion.identity; m_active = false; }
private void Start() { cam = Camera.main; gridManager = FindObjectOfType <GridManager>(); rotateState = FindObjectOfType <RotateState>(); hexFallSpeed = 1f / hexFallTime; hexCreatingSpeed = 1f / hexCreatingTime; Info = new SelectionInfo(); _input = inputObject as IInput; state = null; }
public void allowRotating(RotateState rs) { if (rs == this.rs || this.rs == RotateState.NO_ROT) { allowRotate = !allowRotate; } if (allowRotate) { this.rs = rs; } }
public void StopRotate() { StopCoroutine("_Coro_Rotate"); mRotateState = RotateState.Idle; //if (left && mRotateState == RotateState.Left) //{ // StopCoroutine("_Coro_Rotate"); // mRotateState = RotateState.Idle; //} //else if (!left && mRotateState == RotateState.Right) //{ // StopCoroutine("_Coro_Rotate"); // mRotateState = RotateState.Idle; //} }
public void RotateToTarget_RotationState_CorrectRotationState(RotateState state, float targetX, float targetY, float targetZ, RotateState newState) { Vector3 targetPosition = new Vector3(targetX, targetY, targetZ); ShipData shipData = new ShipData(); shipData.RotationAcceleration = 10; shipData.RotationAccelerationMax = 10; shipData.RotationTarget = new Vector3(1, 1, 1); RotateState activeState; Ship sut = new Ship(shipData); sut.NewTargetToMove = targetPosition; sut.CurrentRotateState = state; sut.Tick(); Assert.That(sut.CurrentRotateState, Is.EqualTo(newState)); }
public void ChangeRotateState_NewState_CorrectRotateState(RotateState state, RotateState newState, RotateState expectedState, float rotationAcceleration, float expectedRotationAcceleration) { ShipData shipData = new ShipData(); shipData.RotationAcceleration = rotationAcceleration; shipData.RotationAccelerationMax = 10; RotateState activeState; Ship sut = new Ship(shipData); sut.CurrentRotateState = state; sut.ChangeRotateState(newState); sut.RotationStateChanged += (s, args) => activeState = args.rotateState; Assert.That(sut.Data.RotationAcceleration, Is.EqualTo(expectedRotationAcceleration).Within(0.001), $"Rotate acceleration is wrong actual {sut.Data.RotationAcceleration} exprected {expectedRotationAcceleration} "); Assert.That(sut.CurrentRotateState, Is.EqualTo(expectedState), $"Wrong State after changin from {state} to {newState} expected {expectedState}"); }
public void ChangeRotateState(RotateState rotateState) { if (rotateState == CurrentRotateState) { return; } switch (rotateState) { case (RotateState.Starting): if (CurrentRotateState != RotateState.Stopped) { ChangeRotateState(RotateState.Stopped); } StartRotating(); CurrentRotateState = RotateState.Starting; OnRotationStateChangeCall(RotateState.Starting); break; case (RotateState.Rotating): if (CurrentRotateState != RotateState.Starting) { ChangeRotateState(RotateState.Starting); } break; case (RotateState.Stopping): if (CurrentRotateState == RotateState.Stopped) { return; } StopRotating(); CurrentRotateState = RotateState.Stopping; OnRotationStateChangeCall(RotateState.Stopping); break; case (RotateState.Stopped): if (CurrentRotateState != RotateState.Stopping) { ChangeRotateState(RotateState.Stopping); } break; } }
public BallShooter ballShooter; //볼슈터스크립트 가져와서 껐다 켰다 하기위해 private void Update() { switch (state) { case RotateState.Idle: if (Input.GetButtonDown("Fire1")) //누르는 그 한순간 { state = RotateState.Horizontal; } break; case RotateState.Vertical: if (Input.GetButton("Fire1")) //마우스를 꾹 누르고있는 동안 { //x축을 기준으로 회전 transform.Rotate(new Vector3(-verticalRotateSpeed * Time.deltaTime, 0, 0)); } else if (Input.GetButtonUp("Fire1")) { state = RotateState.Ready; ballShooter.enabled = true; } break; case RotateState.Horizontal: if (Input.GetButton("Fire1")) //누르고있는 동안 { transform.Rotate(new Vector3(0, horizontalRotateSpeed * Time.deltaTime, 0)); //수평방향으로 회전 } else if (Input.GetButtonUp("Fire1")) //마우스에서 손을 떼는 순간 '버티컬'로 스위치 { state = RotateState.Vertical; } break; case RotateState.Ready: break; } }
void RotateHintHandler() { switch (rotate_state) { case RotateState.roll: // Show roll hint. text.text = roll; // Goto pitch hint after rolling. if (is_rolling && Time.time - start_t > 3f) { start_t = Time.time; rotate_state = RotateState.pitch; } break; case RotateState.pitch: // Show pitch hint. text.text = pitch; // Goto yaw hint after pitching. if (is_pitching && Time.time - start_t > 3f) { start_t = Time.time; rotate_state = RotateState.yaw; } break; case RotateState.yaw: // Show yaw hint. text.text = yaw; // Go back to roll hint after yawing. if (is_yawing && Time.time - start_t > 3f) { start_t = Time.time; rotate_state = RotateState.roll; tutorial_state = TutorialState.speed_control; } break; default: Debug.Log("Rotate state Error!! Invalid rotate state: " + rotate_state.ToString()); break; } }
/// <summary> /// Creates the state of the base.创建一个基本的状态管理器 /// </summary> /// <returns>The base state.</returns> /// <param name="tra">Tra.管理的tansform对象</param> StateManager CreateBaseState(Transform tra) { StateManager stateMgr = new StateManager(tra); IdleState idle = new IdleState(); ScaleState scale = new ScaleState(); RotateState rotate = new RotateState(); DragState drag = new DragState(); StaticState staticState = new StaticState(); stateMgr.Add(idle); stateMgr.Add(scale); stateMgr.Add(rotate); stateMgr.Add(drag); stateMgr.Add(staticState); return(stateMgr); }
void OnMouseDown () { if (GameController.currentNumber == score) { rotateState = RotateState.TOUCH_TRUE; // 点数を追加 GameObject.Find ("Score").SendMessage ("AddScore", 10); if(score == 25) { GameObject gameController = GameObject.Find ("GameController"); gameController.SendMessage("ResetCube"); GameController.currentNumber = 1; } else { GameController.currentNumber += 1; } } else if(GameController.currentNumber < score) { // 番号が違う場合 rotateState = RotateState.TOUCH_FALSE_ROTATING; } else { // 番号が小さい場合は何もしない } }
// Use this for initialization void Start () { rotateState = RotateState.NONE; }
// Update is called once per frame void Update () { if (numberGUIText != null) { numberGUIText.text = number; } switch (rotateState) { case RotateState.TOUCH_TRUE: if (numberGUIText != null) { numberGUIText.text = number; numberGUIText.color = Color.yellow; } if (stopAngleY < 0) { if (transform.rotation.eulerAngles.y > 360 + stopAngleY || transform.rotation.eulerAngles.y == 0) { transform.Rotate (angle * Time.deltaTime); } else { // 指定した値でぴったり止める transform.eulerAngles = new Vector3 (0, 360 + stopAngleY, 0); rotateState = RotateState.NONE; } } else { if (transform.rotation.eulerAngles.y < stopAngleY) { transform.Rotate (angle * Time.deltaTime); } else { // 指定した値でぴったり止める transform.eulerAngles = new Vector3 (0, stopAngleY, 0); rotateState = RotateState.NONE; } } break; case RotateState.TOUCH_FALSE_ROTATING: if (numberGUIText != null) { numberGUIText.text = number; numberGUIText.color = Color.blue; } if (stopAngleY < 0) { if (transform.rotation.eulerAngles.y > 360 + stopAngleY || transform.rotation.eulerAngles.y == 0) { transform.Rotate (angle * Time.deltaTime); } else { // 指定した値でぴったり止める transform.eulerAngles = new Vector3 (0, 360 + stopAngleY, 0); rotateState = RotateState.TOUCH_FALSE_RETURN; } } else { if (transform.rotation.eulerAngles.y < stopAngleY) { transform.Rotate (angle * Time.deltaTime); } else { // 指定した値でぴったり止める transform.eulerAngles = new Vector3 (0, stopAngleY, 0); rotateState = RotateState.TOUCH_FALSE_RETURN; } } break; case RotateState.TOUCH_FALSE_RETURN: // 戻る case RotateState.TOUCH_ALL_RETURN: // 戻る if (stopAngleY < 0) { if (transform.rotation.eulerAngles.y >= 360 + stopAngleY && transform.rotation.eulerAngles.y < 360) { transform.Rotate (-angle * Time.deltaTime); } else { // 0でぴったり止める transform.eulerAngles = new Vector3 (0, 0, 0); rotateState = RotateState.NONE; if (numberGUIText != null) { numberGUIText.text = number; numberGUIText.color = Color.white; } } } else { if (transform.rotation.eulerAngles.y <= stopAngleY && transform.rotation.eulerAngles.y > 0 ) { transform.Rotate (-angle * Time.deltaTime); } else { // 0でぴったり止める transform.eulerAngles = new Vector3 (0, 0, 0); rotateState = RotateState.NONE; if (numberGUIText != null) { numberGUIText.text = number; numberGUIText.color = Color.white; } } } break; } }
void Update() { if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.T)) { _rotateState = _rotateState == RotateState.AutoAdjust ? RotateState.FreeAdjust : RotateState.AutoAdjust; } zoomAmount = -Input.GetAxis("Mouse ScrollWheel"); }
public void RotateTo(bool left) { if (mRotateState == RotateState.Left || mRotateState == RotateState.Right) return; mRotateState = left ? RotateState.Left:RotateState.Right; StartCoroutine("_Coro_Rotate", left); }
public void StopRotate() { StopCoroutine("_Coro_Rotate"); mRotateState = RotateState.Idle; //if (left && mRotateState == RotateState.Left) //{ // StopCoroutine("_Coro_Rotate"); // mRotateState = RotateState.Idle; //} //else if (!left && mRotateState == RotateState.Right) //{ // StopCoroutine("_Coro_Rotate"); // mRotateState = RotateState.Idle; //} }