// Update is called once per frame void Update() { if (IsPress == true && alpha < 1.0f) //押されていたら画像のalphaを上げて光っているように見せる { if ((Time.time - startTime) > easingTime) //イージングタイムオーバー { alpha = 1.0f; } else { alpha = EasingLerps.EasingLerp(EasingLerps.EasingLerpsType.Circ, EasingLerps.EasingInOutType.EaseOut, (Time.time - startTime) / easingTime, valueA, 1.0f); } GetComponent <Image> ().color = new Color(1, 1, 1, alpha); } if (IsPress == false && alpha > 0.0f) //押されていなかったらalphaを下げる { if ((Time.time - startTime) > easingTime) //イージングタイムオーバー { alpha = 0.0f; } else { alpha = EasingLerps.EasingLerp(EasingLerps.EasingLerpsType.Circ, EasingLerps.EasingInOutType.EaseIn, (Time.time - startTime) / easingTime, 0.0f, valueB); } GetComponent <Image> ().color = new Color(1, 1, 1, alpha); } }
private IEnumerator RunningRoutine() { yield return(new WaitForSeconds(_Settings._HideSeconds)); //ここで消し始める _Collider.enabled = false; for (float t = 0.0f; t < _Settings._Hide_Scale_EaseSettings._NeedSeconds; t += Time.deltaTime) { transform.localScale = Vector3.Lerp( _StartScale, Vector3.zero, EasingLerps.EasingLerp( _Settings._Hide_Scale_EaseSettings._Get_EasingType, _Settings._Hide_Scale_EaseSettings._Get_InOutType, t / _Settings._Hide_Scale_EaseSettings._NeedSeconds, 0.0f, 1.0f) ); yield return(null); } Hide(); }
// fromPosが移動元の座標、toPosが移動先の座標、durationが移動の秒数 IEnumerator MoveTo(Vector3 fromPos, Vector3 toPos, float duration) { float time = 0; while (true) { time += (Time.deltaTime / duration); if (time > 1) { time = 1; } float easingValue = EasingLerps.EasingLerp(EasingLerps.EasingLerpsType.Quint, EasingLerps.EasingInOutType.EaseIn, time, 0, 1); Vector3 lerpValue = Vector3.Lerp(fromPos, toPos, easingValue); this.transform.position = lerpValue; if (time == 1) { yield break; } yield return(new WaitForEndOfFrame()); } }
/// <summary> /// /// </summary> /// <param name="FromCenterVector">中心からの方向ベクトル(どう曲がるか)</param> /// <returns></returns> private IEnumerator GetRoutine(Vector3 FromCenterVector) { float e; Vector3 PlayerPos = InputManager.Instance.HandPosition;//Camera.main.transform.position + Vector3.down * 0.5f + Vector3.forward * 0.2f; Vector3 StartPos = transform.position; Vector3 StartScale = transform.localScale; Vector3 v = (StartPos - PlayerPos).normalized; Vector3 BezierPos = PlayerPos + v * ObjectSpawner.Instance.ToPlayerDistance * 0.5f + FromCenterVector * ObjectSpawner.Instance.ObjectGetCurveDistance; Vector3 bz1, bz2; for (float t = 0.0f; t < _Settings._Get_Pos_EaseSettings._NeedSeconds; t += Time.deltaTime) { e = EasingLerps.EasingLerp( _Settings._Get_Pos_EaseSettings._Get_EasingType, _Settings._Get_Pos_EaseSettings._Get_InOutType, t / _Settings._Get_Pos_EaseSettings._NeedSeconds, 0.0f, 1.0f); bz1 = Vector3.Lerp(StartPos, BezierPos, e); bz2 = Vector3.Lerp(BezierPos, InputManager.Instance.HandPosition, e); transform.position = Vector3.Lerp(bz1, bz2, e); transform.localScale = Vector3.Lerp(StartScale, Vector3.one * 0.03f, e); yield return(null); } Hide(); }
IEnumerator UpdateGraph() { // Gets the easing value from function float easingValue = EasingLerps.EasingLerp(lerpType, inOutType, time, startPoint, EndPoint); //Gets lerp Values to show time passing float lerpValue = Mathf.Lerp(-5, 5, time); // Move object across screen displayObject.transform.position = new Vector3(lerpValue, easingValue); time += Time.deltaTime;; // After time is complete if (time > 1) { time = 0; //delay time between lerping to display trail yield return(new WaitForSeconds(2)); // Get the current lerp value // Don't want user to be able to change it mid lerp so update after lerp has completed lerpType = (EasingLerps.EasingLerpsType)easingTypeDropdown.value; inOutType = (EasingLerps.EasingInOutType)inOrOutTypeDropdown.value; } yield return(new WaitForEndOfFrame()); // recursion yield return(UpdateGraph()); }
/// <summary> /// 手元に戻すコルーチン /// </summary> /// <returns></returns> private IEnumerator ReturnBullletCoroutine() { Debug.Log("Return"); _isSetBullet = false; //まだ手に戻ってない状態 //Vector3 v; //float d; //while (true) //{ // v = (transform.position - InputManager.Instance.HandPosition); // d = v.sqrMagnitude; // if (d < 0.01f) // { // ここで手元に戻ってることにする // break; // } // //ここで手元に戻ってる // yield return null; //} //移動 Vector3 StartPos = transform.position; for (float t = 0.0f, e = 0.0f; t < _ReturnNeedSeconds; t += Time.deltaTime) { e = EasingLerps.EasingLerp(_Return_EasingType, _Return_InOutType, _ShotNeedSeconds, t / _ReturnNeedSeconds, 0.0f, 1.0f); _Rigidbody.MovePosition(Vector3.Lerp(StartPos, InputManager.Instance.HandPosition, e)); yield return(null); } _Rigidbody.MovePosition(InputManager.Instance.HandPosition); _isSetBullet = true; }
IEnumerator StartRadiationBlur() { Debug.Log("test"); float duration = effectTime; while (duration > 0f) { duration = Mathf.Max(duration - Time.deltaTime, 0); var inOutType = EasingLerps.EasingInOutType.EaseOut; var type = EasingLerps.EasingLerpsType.Quad; radiationBlur.power = EasingLerps.EasingLerp( type, inOutType, duration, 0, 1) * maxRadiationBlurPower; yield return(null); } }
//プレイヤーの移動 private void PlayerMove() { for (int i = 0; i < joycons.Count; i++) { Joycon inProcJoycon = joycons[i]; //スティックの入力値をジョイコンの数分格納 Vector2 stickInput = (new Vector2(inProcJoycon.GetStick()[0], inProcJoycon.GetStick()[1]) * parameter.moveSpeed); parameter.moveVel += EasingLerps.OutQuad(parameter.oldVel, stickInput, parameter.accelSpeed * Time.fixedDeltaTime) / joycons.Count; } //格納された値を補間して速度に代入 rigidbody2D.velocity = parameter.moveVel; parameter.ResetVel(); }
private IEnumerator Spawn_Scale_Routine() { for (float t = 0.0f; t < _Settings._Spawn_Scale_EaseSettings._NeedSeconds; t += Time.deltaTime) { transform.localScale = Vector3.Lerp( Vector3.zero, _StartScale, EasingLerps.EasingLerp( _Settings._Spawn_Scale_EaseSettings._Get_EasingType, _Settings._Spawn_Scale_EaseSettings._Get_InOutType, t / _Settings._Spawn_Scale_EaseSettings._NeedSeconds, 0.0f, 1.0f) ); yield return(null); } }
private IEnumerator Spawn_Pos_Routine(Vector3 Position) { Vector3 SpawnPos = MainCharacter.Instance.SpawnObjectPos; for (float t = 0.0f; t < _Settings._Spawn_Pos_EaseSettings._NeedSeconds; t += Time.deltaTime) { transform.position = Vector3.Lerp( SpawnPos, Position, EasingLerps.EasingLerp( _Settings._Spawn_Pos_EaseSettings._Get_EasingType, _Settings._Spawn_Pos_EaseSettings._Get_InOutType, t / _Settings._Spawn_Pos_EaseSettings._NeedSeconds, 0.0f, 1.0f) ); yield return(null); } }
/// <summary> /// 発射されている状態 /// </summary> /// <returns></returns> private IEnumerator ShotBullletCoroutine() { Debug.Log("Shot"); _isSetBullet = true; _HandPosParticleSystem.Play(); _MovePositionList.Clear(); Vector3 StartPos = transform.position; for (float t = 0.0f, e = 0.0f; t < _ShotNeedSeconds; t += Time.deltaTime) { e = EasingLerps.EasingLerp(_Shot_EasingType, _Shot_InOutType, _ShotNeedSeconds, t / _ShotNeedSeconds, 0.0f, 1.0f); _Rigidbody.MovePosition(Vector3.Lerp(StartPos, _NextShotposition, e)); //ここでも座標保存 _MovePositionList.Add(InputManager.Instance.HandFieldPosition); yield return(null); } _Rigidbody.MovePosition(_NextShotposition); //ここで着弾した }
// fromPosが移動元の座標、toPosが移動先の座標、durationが移動の秒数 IEnumerator MoveTo(Vector3 fromPos, Vector3 toPos, float duration, bool drop) { float time = 0; while (true) { time += (Time.deltaTime / duration); if (time > 1) { time = 1; } if (drop) { //http://www.noisecrime.com/unity/demos/EasingLibraryVisualisationWebglDemo/index.html float easingValue = EasingLerps.EasingLerp(EasingLerps.EasingLerpsType.Bounce, EasingLerps.EasingInOutType.EaseOut, time, 0, 1); Vector3 lerpValue = Vector3.Lerp(fromPos, toPos, easingValue); this.transform.localPosition = lerpValue; } else { //float easingValue = EasingLerps.EasingLerp(EasingLerps.EasingLerpsType.Bounce, EasingLerps.EasingInOutType.EaseOut, time, 0, 1); Vector3 lerpValue = Vector3.Lerp(fromPos, toPos, time); this.transform.localPosition = lerpValue; } if (time == 1) { iMove = false; yield break; } yield return(new WaitForEndOfFrame()); } }