コード例 #1
0
ファイル: DoorAndKeyObstacle.cs プロジェクト: kijun/art
    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);
    }
コード例 #2
0
 public virtual void Update()
 {
     if (moving != null)
     {
         moving.Update(Time.deltaTime);
         rect.anchoredPosition = moving.Lerp();
         if (moving.IsDone())
         {
             moving = null;
         }
     }
 }
コード例 #3
0
ファイル: DoorAndKeyObstacle.cs プロジェクト: kijun/art
    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)));
    }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
    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");
    }
コード例 #6
0
ファイル: Frame.cs プロジェクト: kijun/art
    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);
    }