IEnumerator OpenDoor() { if (keyProgress == null) { keyProgress = Instantiate <Transform>(keyProgressPrefab); keyProgress.transform.position = key.transform.position.SwapZ(10); keyProgress.localScale = Vector3.zero; } LerpDelegate openFunc = delegate(float openFraction) { openProgress = openFraction; SetBallSize(openProgress); SetDoorAlpha(1 - openProgress); }; IEnumerator lerpCoroutine = LerpHelper.Lerp(openFunc, secondsToOpen); while (lerpCoroutine.MoveNext()) { yield return(null); } //yield return StartCoroutine(LerpHelper.Lerp(openFunc, secondsToOpen)); doorOpened = true; door.SetActive(false); }
public virtual void Update() { if (moving != null) { moving.Update(Time.deltaTime); rect.anchoredPosition = moving.Lerp(); if (moving.IsDone()) { moving = null; } } }
IEnumerator CloseDoor() { float startingProgress = openProgress; LerpDelegate closeFunc = delegate(float timeFraction) { openProgress = startingProgress - startingProgress * timeFraction; SetBallSize(openProgress); SetDoorAlpha(1 - openProgress); }; yield return(StartCoroutine(LerpHelper.Lerp(closeFunc, secondsToOpen * startingProgress))); }
void Update() { if (lerpPosition != null) { lerpPosition.Update(Time.deltaTime); rectTransform.anchoredPosition = lerpPosition.Lerp(); if (lerpPosition.IsDone()) { lerpPosition = null; } } if (IsSource && gameMain != null) { button.interactable = gameMain.CanMoveToDest(this); } }
IEnumerator Ascend() { Rigidbody2D rgbd = GetComponent <Rigidbody2D>(); rgbd.velocity = ascendVelocity; rgbd.angularVelocity = ascendAngularVelocity; // TODO lerp on the rest yield return(StartCoroutine(LerpHelper.Lerp( delegate(float ratio) { SetChildrenAlpha(startAlpha + ratio * (1f - startAlpha)); }, ascendDuration))); rgbd.velocity = Vector2.zero; rgbd.angularVelocity = 0; yield return(new WaitForSeconds(freezeDuration)); yield return(StartCoroutine(LerpHelper.Lerp(delegate(float ratio) { SetChildrenAlpha(1 - ratio); }, fadeDuration))); Debug.Log("DONE"); }
IEnumerator LockAndUnlock() { if (activated) { yield break; } yield return(StartCoroutine( LerpHelper.Lerp( delegate(float ratio) { SetAlpha(defaultAlpha + ratio * (1f - defaultAlpha)); }, lockDelay))); yield return(new WaitForSeconds(lockDuration)); yield return(StartCoroutine( LerpHelper.Lerp( delegate(float ratio) { SetAlpha(1 - ratio); }, unlockDelay))); activated = true; enabled = false; // TODO make it reusable //Destroy(gameObject); }