private void Update() { //Debug.LogError(particles.system.isPlaying); if (Input.GetKeyDown(KeyCode.K)) { IsPause = false; } if (Input.GetKeyDown(KeyCode.J)) { IsPause = true; } //if (isPause) // particles.system.Pause(true); //else // particles.system.Play(true); Duration += Time.deltaTime; this.transform.position = Interpolate.Ease(Interpolate.Ease(Interpolate.EaseType.Linear), this.origin, _target, Duration, 3f); //if ( CCollision.CircleCollision(new InfoEntity() { Position = this.gameObject.transform.position, BodyBlock = Vector3.one / 2 }, // new InfoEntity() { Position = this.target.position, BodyBlock = Vector3.one / 2}) ) //{ // Debug.LogError("Collsion is detected"); //} if (IsPause) { return; } //if (sequence.MoveNext()) // this.transform.position = sequence.Current; }
IEnumerator FlashAnimation(int first, int middle, int last, float sprayTime, float wipeTime) { var t = 0f; while (t < sprayTime) { t += Time.deltaTime; Slices[first].transform.localScale = new Vector3(Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTime), Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTime)); Slices[middle].transform.localScale = new Vector3(Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(0, 1, t, sprayTime), Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(0, 1, t, sprayTime)); Slices[last].transform.localScale = new Vector3(Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTime), Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTime)); yield return(new WaitForEndOfFrame()); } t = 0f; while (t < wipeTime) { t += Time.deltaTime; Slices[first].fillAmount = Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(0.051f, -0.051f, t, wipeTime); Slices[middle].fillAmount = Interpolate.Ease(Interpolate.EaseType.EaseInSine)(0.051f, -0.051f, t, wipeTime); Slices[last].fillAmount = Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(0.051f, -0.051f, t, wipeTime); Slices[first].transform.rotation = Quaternion.Euler(0, 0, Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(-45 + 18 * first, 9, t, wipeTime)); Slices[middle].transform.rotation = Quaternion.Euler(0, 0, Interpolate.Ease(Interpolate.EaseType.EaseInSine)(-45 + 18 * middle, 9, t, wipeTime)); Slices[last].transform.rotation = Quaternion.Euler(0, 0, Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(-45 + 18 * last, 9, t, wipeTime)); yield return(new WaitForEndOfFrame()); } }
public void RotateTo(Vector3 destination, float duration, Interpolate.EaseType easingFunction, Action <GameObject> onComplete, bool world) { rotationWorld = world; rotationInitial = rotationWorld ? transform.rotation.eulerAngles : transform.localRotation.eulerAngles; rotationDisplacement = destination - rotationInitial; var rotX = rotationDisplacement.x; // check the other way around the circle var rotY = rotationDisplacement.y; // for each component var rotZ = rotationDisplacement.z; var rotX2 = (rotationDisplacement.x + 360) % 360; var rotY2 = (rotationDisplacement.y + 360) % 360; var rotZ2 = (rotationDisplacement.z + 360) % 360; if (Mathf.Abs(rotX2) < Mathf.Abs(rotX)) { rotX = rotX2; } if (Mathf.Abs(rotY2) < Mathf.Abs(rotY)) { rotY = rotY2; } if (Mathf.Abs(rotZ2) < Mathf.Abs(rotZ)) { rotZ = rotZ2; } rotationDisplacement = new Vector3(rotX, rotY, rotZ); rotationFunc = Interpolate.Ease(easingFunction); rotationOnComplete = onComplete; rotationDurationTotal = duration; rotationDuration = 0; }
//public void OnHandleEvent(IGameNormalEventSender sender, E_GameNormalEvent e, params object[] args) //{ // if (E_GameNormalEvent.Trigger_Camera_Stock == e) // { // CameraStock stock = (CameraStock)args[0]; // m_cameraImpl.UpdateStock(stock); // } // else if (E_GameNormalEvent.Trigger_Camera_Zoom == e) // { // float Distance = (float)args[0]; // float Time = (float)args[1]; // m_cameraImpl.StartCoroutine(ZoomBlendStart(Distance, Time)); // } // else if (E_GameNormalEvent.StartDarkChange == e) // StartDarkChange(); // else if (E_GameNormalEvent.EndDarkChange == e) // EndDarkChange(); //} IEnumerator ZoomBlendStart(float distance, float time) { CameraSetting setting = m_cameraImpl.Setting; float deltatime = 0.0f; float olddis = setting.CameraStock.Distance; bool outcheck = distance > 0.0f ? true : false; float newdis = Mathf.Abs(distance); var ease = Interpolate.Ease(Interpolate.EaseType.Linear); while (deltatime <= time) { deltatime += TimeManager.deltaTime; float deltadis = ease(0.0f, newdis, deltatime, time); if (outcheck) { setting.CameraStock.Distance = olddis + deltadis; } else { setting.CameraStock.Distance = olddis - deltadis; } m_cameraImpl.UpdateStock(setting.CameraStock); yield return(new WaitForEndOfFrame()); } setting.CameraStock.Distance = distance; }
public float GetPotential(Vector3 samplePos, Vector3 sourcePos, float sourcePotential) { if (sourcePotential == 0f) { return(0f); } if (maxDistance == 0f) { return(sourcePotential); } if (easeFunc == null) { easeFunc = Interpolate.Ease(this.easeType); } // start, distance, elapsed, duration. var potential = easeFunc( 0f, Mathf.Abs(sourcePotential), maxDistance - Mathf.Min(Vector3.Distance(sourcePos, samplePos), maxDistance), maxDistance); return(potential * Mathf.Sign(sourcePotential)); }
/// <summary> /// 페이드 인, 아웃 효과 프로세스 /// </summary> public void DoFade(float time, AudioSource audio) { //fadeTime1 : 축적되는 현재 재생시간 //fadeTime2 : 끝나는 시간을 체크하는 끝 시간 if (this.isFadeIn == true) { this.fadeTime1 += time; audio.volume = Interpolate.Ease(this.interpolate_Func, 0, maxVolume, fadeTime1, fadeTime2); if (this.fadeTime1 > this.fadeTime2) { this.isFadeIn = false; } } else if (this.isFadeOut == true) { this.fadeTime1 += time; audio.volume = Interpolate.Ease(this.interpolate_Func, maxVolume, 0 - maxVolume, fadeTime1, fadeTime2); if (this.fadeTime1 >= this.fadeTime2) { this.isFadeOut = false; audio.Stop(); } } }
void CheckGround() { Vector3 center = transform.TransformPoint(circleCollider.offset); RaycastHit2D hit = Physics2D.CircleCast( center, circleCollider.radius, -transform.up, groundCheckDist, environmentLayers ); if (hit.collider != null && Vector2.Angle(hit.normal, transform.up) < maxIncline) { _isGrounded = true; if (hugGround && rigidbody2D.velocity.magnitude > minHugSpeed) { _groundNormal = hit.normal; float t = Interpolate.Ease(loopEase, 0.5f + Vector2.Dot(hit.normal, -Vector2.up) * 0.5f); Vector2 centrifugalForce = -rigidbody2D.velocity.magnitude * hit.normal; Vector2 tangentialForce = rigidbody2D.velocity * loopBoost; rigidbody2D.AddForce(Vector2.Lerp(centrifugalForce, tangentialForce, t), ForceMode.Acceleration); } } else { _isGrounded = false; } }
public void FadeOut(float _time, Interpolate.EaseType _easyType) { isFadeOut = true; isFadeIn = false; fadeTime1 = 0.0f; fadeTime2 = _time; interPolateFunction = Interpolate.Ease(_easyType); }
public void FadeIn(float time, Interpolate.EaseType easeType) { isFadeOut = false; fadeTime1 = 0.0f; fadeTime2 = time; interpolate_Func = Interpolate.Ease(easeType); isFadeIn = true; }
//fadfeOut 기능 public void FadeOut(float time, Interpolate.EaseType easeType) { this.IsFadeOut = true; this.IsFadeIn = false; this.FadeTime1 = 0.0f; this.FadeTime2 = time; this.InterpolateFunction = Interpolate.Ease(easeType); }
void Awake() { climbing = Interpolate.Ease(easeClimbing); falling = Interpolate.Ease(easeFalling); teleporting = Interpolate.Ease(easeTeleporting); bumping = Interpolate.Ease(easeBumping); fade = Interpolate.Ease(easefade); }
/// <summary> /// 페이드 아웃. /// </summary> public void FadeOut(float time, Interpolate.EaseType easeType) { this.isFadeIn = false; this.fadeTime1 = 0.0f; this.fadeTime2 = time; this.interpolate_Func = Interpolate.Ease(easeType); this.isFadeOut = true; }
public void ScaleTo(Vector3 destination, float duration, Interpolate.EaseType easingFunction, Action <GameObject> onComplete) { scaleInitial = transform.localScale; scaleDisplacement = destination - scaleInitial; scaleFunc = Interpolate.Ease(easingFunction); scaleOnComplete = onComplete; scaleDurationTotal = duration; scaleDuration = 0; }
public void ColorTo(Color destination, float duration, Interpolate.EaseType easingFunction, Action <GameObject> onComplete) { colorInitial = graphic ? graphic.color : spriteRenderer ? spriteRenderer.color : renderer.material.color; colorDisplacement = destination - colorInitial; colorFunc = Interpolate.Ease(easingFunction); colorOnComplete = onComplete; colorDurationTotal = duration; colorDuration = 0; }
public void MoveTo(Vector3 destination, float duration, Interpolate.EaseType easingFunction, Action <GameObject> onComplete, bool world) { positionWorld = world; positionInitial = positionWorld ? transform.position : transform.localPosition; positionDisplacement = destination - positionInitial; positionFunc = Interpolate.Ease(easingFunction); positionOnComplete = onComplete; positionDurationTotal = duration; positionDuration = 0; }
IEnumerator RadialColors(float sprayMaxTime, float rotateTime, float wipeMaxTime, bool red, float hueSpeed) { var sprayTimes = new float[Slices.Length]; for (int i = 0; i < sprayTimes.Length; i++) { sprayTimes[i] = Mathf.Lerp(sprayMaxTime / 4, sprayMaxTime, Random.value); } var wipeTimes = new float[Slices.Length]; for (int i = 0; i < wipeTimes.Length; i++) { wipeTimes[i] = Mathf.Lerp(wipeMaxTime / 4, wipeMaxTime, Random.value); } var overallTime = 0f; while (overallTime < (sprayMaxTime + rotateTime + wipeMaxTime)) { overallTime += Time.deltaTime; if (overallTime > 0 && overallTime < sprayMaxTime) { var t = overallTime - 0; for (int i = 0; i < Slices.Length; i++) { Slices[i].transform.localScale = new Vector3(Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTimes[i]), Interpolate.Ease(Interpolate.EaseType.Linear)(0, 1, t, sprayTimes[i])); } } else if (overallTime >= sprayMaxTime && overallTime < (sprayMaxTime + rotateTime)) { var t = overallTime - sprayMaxTime; } else if (overallTime >= (sprayMaxTime + rotateTime) && overallTime < (sprayMaxTime + rotateTime + wipeMaxTime)) { var t = overallTime - (sprayMaxTime + rotateTime); for (int i = 0; i < Slices.Length; i++) { Slices[i].fillAmount = Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(0.051f, -0.051f, t, wipeTimes[i]); Slices[i].transform.rotation = Quaternion.Euler(0, 0, Interpolate.Ease(Interpolate.EaseType.EaseOutSine)(-45 + 18 * i, 9, t, wipeTimes[i])); } } for (int i = 0; i < Slices.Length; i++) { var slice = Slices[i]; var lerp = ((float)i / Slices.Length + (overallTime * hueSpeed)) % 1; slice.color = new HSBColor(red ? (0.96f + Mathf.Sin(lerp * 6 * Mathf.PI) * 0.04f) % 1 : lerp, 1, 1, 1).ToColor(); } yield return(new WaitForEndOfFrame()); } for (int i = 0; i < Slices.Length; i++) { ResetSlice(i); } }
public float Evaluate(float time) { if (advancedMode) { return(Curve.Evaluate(time)); } else { return(Interpolate.Ease(easeType)(startValue, stopValue - startValue, time, stopTime - startTime)); } }
// Token: 0x0600044B RID: 1099 RVA: 0x00022B9D File Offset: 0x00020D9D private static IEnumerator NewEase(Interpolate.Function ease, Vector3 start, Vector3 end, float total, IEnumerable <float> driver) { Vector3 distance = end - start; foreach (float elapsedTime in driver) { yield return(Interpolate.Ease(ease, start, distance, elapsedTime, total)); } IEnumerator <float> enumerator = null; yield break; yield break; }
public static IEnumerator FadeAudio(AudioSource audio, float duration, Fade fadeType, Interpolate.EaseType easeType = Interpolate.EaseType.EaseOutExpo) { float start = fadeType == Fade.In ? 0.0f : 1.0f; float distance = fadeType == Fade.In ? 1.0f : -1.0f; float t = 0.0f; var easeFunction = Interpolate.Ease(easeType); while (t <= duration) { audio.volume = easeFunction(start, distance, t, duration); t += Time.deltaTime; yield return(null); } }
void ResetSequence() { // Extracts and prepares a list of vectors and angles to use on the tracks. List <Transform> transforms = new List <Transform>(); foreach (Transform trans in transformList.transform) { transforms.Add(trans); } if (catmullSlices <= 0) { Vector3[] positions = new Vector3[transforms.Count + 1]; Vector3[] angles = new Vector3[transforms.Count + 1]; int i = 0; foreach (Transform trans in transforms) { positions[i] = trans.position; angles[i] = trans.rotation.eulerAngles; i++; } positions[transforms.Count] = transforms[0].position; angles[transforms.Count] = transforms[0].rotation.eulerAngles; pos_sequence = Interpolate.NewBezier(Interpolate.Ease(Interpolate.EaseType.Linear), positions, duration).GetEnumerator(); ang_sequence = Interpolate.NewBezier(Interpolate.Ease(Interpolate.EaseType.Linear), angles, duration).GetEnumerator(); Invoke("ResetSequence", duration); } else { Vector3[] positions = new Vector3[transforms.Count]; Vector3[] angles = new Vector3[transforms.Count]; int i = 0; foreach (Transform trans in transforms) { positions[i] = trans.position; angles[i] = trans.rotation.eulerAngles; i++; } pos_sequence = Interpolate.NewCatmullRom(positions, catmullSlices, true).GetEnumerator(); ang_sequence = Interpolate.NewCatmullRom(angles, catmullSlices, true).GetEnumerator(); } }
IEnumerator AnimateWorldTransition(float scaleFactor, Vector3 camPosition, Vector3 playerPos) { // Effect here? playerRigidBody.gameObject.SetActive(false); Debug.Log($"Scaling world by {scaleFactor}"); var startScale = worldTransform.localScale; var endScale = worldTransform.localScale / scaleFactor; var cam = Camera.main.GetComponent <PortalCamera>(); Vector3 camStartPos = cam.transform.position; var camEndPos = camPosition / scaleFactor; float elapsedTime = 0; var f = Interpolate.Ease(Interpolate.EaseType.EaseInOutCirc); while (elapsedTime < transitionTime) { var percent = elapsedTime / transitionTime; Vector3 camPos; if (easeCamera) { camPos = Interpolate.Ease(f, camStartPos, camEndPos - camStartPos, elapsedTime, transitionTime); worldTransform.localScale = Interpolate.Ease(f, startScale, endScale - startScale, elapsedTime, transitionTime); } else { camPos = Vector3.Lerp(camStartPos, camEndPos, percent); worldTransform.localScale = Vector3.Lerp(startScale, endScale, percent); } cam?.MoveCamera(camPos); elapsedTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } worldTransform.localScale = endScale; cam?.MoveCamera(camEndPos); var endPlayerPos = playerPos / scaleFactor; playerRigidBody.gameObject.SetActive(true); Instantiate(cloudPrefab, endPlayerPos, Quaternion.identity); RespawnPlayer(endPlayerPos); }
public static WeightedItem WeightByInterpolation(this WeightedItem item, Vector3 origin, float maxDist, float scale, Interpolate.EaseType easeType) { var easeFunc = Interpolate.Ease(easeType); var start = 0f; var dist = scale; var duration = maxDist; var elapsed = Vector3.Distance(origin, item.Target.TargetPosition); var distWeight = scale - easeFunc(start, dist, elapsed, duration); var newItem = new WeightedItem(item); newItem.Weight += distWeight; return(newItem); }
public static IEnumerable <WeightedItem> WeightByInterpolation(this IEnumerable <WeightedItem> items, Vector3 origin, float maxDist, float scale, Interpolate.EaseType easeType) { var easeFunc = Interpolate.Ease(easeType); var start = 0f; var dist = scale; var duration = maxDist; foreach (var item in items) { var elapsed = Vector3.Distance(origin, item.Target.TargetPosition); var distWeight = scale - easeFunc(start, dist, elapsed, duration); var newItem = new WeightedItem(item); newItem.Weight += distWeight; yield return(newItem); } }
void Start() { sequence = Interpolate.NewEase(Interpolate.Ease(Interpolate.EaseType.Linear), this.transform.position, this.target.position, 5f); origin = this.transform.position; _target = target.transform.position - origin; //path = new LinearTrajectory(); var list = race.SplitToEnum <ERace>(); foreach (var r in list) { Debug.LogError(r); } Debug.LogError(list.Count); //path.Origin = this.transform.position; //path.Target = this.target.position; //path.TimeToFinish = 10f; //this.transform.position = Interpolate.Ease(Interpolate.Ease(Interpolate.EaseType.Linear), origin, _target, 5f, 10f); }
public void DoFade(float _time, AudioSource _audio) { if (isFadeIn == true) { fadeTime1 += _time; _audio.volume = Interpolate.Ease(interPolateFunction, 0, maxVolume, fadeTime1, fadeTime2); if (fadeTime1 >= fadeTime2) { isFadeIn = false; } else if (isFadeOut == true) { fadeTime1 += _time; _audio.volume = Interpolate.Ease(interPolateFunction, maxVolume, 0 - maxVolume, fadeTime1, fadeTime2); if (fadeTime1 >= fadeTime2) { isFadeOut = false; _audio.Stop(); } } } }
public void DoFade(float time, AudioSource audio) { if (this.IsFadeIn == true) { this.FadeTime1 += time; audio.volume = Interpolate.Ease(this.InterpolateFunction, 0, this.MaxVolume, this.FadeTime1, this.FadeTime2); if (this.FadeTime1 >= this.FadeTime2) { this.IsFadeIn = false; } } else if (this.IsFadeOut == true) { this.FadeTime1 += time; audio.volume = Interpolate.Ease(this.InterpolateFunction, this.MaxVolume, 0 - this.MaxVolume, this.FadeTime1, this.FadeTime2); if (this.FadeTime1 >= this.FadeTime2) { this.IsFadeOut = false; audio.Stop(); } } }
void Update() { // Movement if (accelerating) { currentSpeed = Interpolate.Ease(Interpolate.EaseType.EaseInQuad)(currentMinSpeed, currentMaxSpeed, endTimer, currentTimeToEnd / 2); } else { currentSpeed = Interpolate.Ease(Interpolate.EaseType.EaseInQuad)(currentMaxSpeed, -(currentMaxSpeed - minSpeed), endTimer, currentTimeToEnd / 2); } transform.Translate(new Vector3(0f, 0f, currentSpeed) * Time.deltaTime); endTimer += Time.deltaTime; // Reset parameters if (endTimer >= currentTimeToEnd / 2) { if (accelerating) { accelerating = false; currentMaxSpeed = currentSpeed; } else { currentMinSpeed = currentSpeed; currentMaxSpeed = Random.Range(minSpeed, maxSpeed); currentTimeToEnd = Random.Range(minTimeToEnd, maxTimeToEnd); accelerating = true; } endTimer = 0f; } // Destroy old corridors if (transform.position.z - lastPosition.z > 4f * generator.maxScale) { Destroy(corridors.GetChild(0).gameObject); lastPosition = transform.position; } }
/// <summary> /// 페이드인, 아웃 효과 프로세스. /// </summary> public void DoFade(float time, AudioSource audio) { if (this.isFadeIn == true) { this.fadeTime1 += time; audio.volume = Interpolate.Ease(this.interpolate_Func, 0, maxVolume, fadeTime1, fadeTime2); if (this.fadeTime1 >= this.fadeTime2) { this.isFadeIn = false; } } else if (this.isFadeOut == false) { this.fadeTime1 += time; audio.volume = Interpolate.Ease(this.interpolate_Func, maxVolume, 0 - this.maxVolume, fadeTime1, fadeTime2); if (this.fadeTime1 >= this.fadeTime2) { this.isFadeOut = false; audio.Stop(); } } }
public void DoFade(float time, AudioSource audio) { if (isFadeIn == true) { fadeTime1 += time; audio.volume = Interpolate.Ease(interpolate_Func, 0.0f, maxVolume, fadeTime1, fadeTime2); if (fadeTime1 >= fadeTime2) { isFadeIn = false; } } else if (isFadeOut == true) { fadeTime1 += time; audio.volume = Interpolate.Ease(interpolate_Func, maxVolume, 0.0f - maxVolume, fadeTime1, fadeTime2); if (fadeTime1 >= fadeTime2) { isFadeOut = false; audio.Stop(); } } }
public int GetValue(float t) { var easeFunc = Interpolate.Ease(this.easeType); var a = this.start; var b = this.end; if (a > b) { t = 1f - t; var tmp = a; a = b; b = tmp; } var start = a; var distance = b - a; // start, distance, elapsed, duration. var value = easeFunc(start, distance, t, 1f); return((int)value); }