コード例 #1
0
ファイル: ScaleHydrate.cs プロジェクト: saddamsial/ggj-2020
    private IEnumerator DehydrateRoutine(bool destroyOnFinish)
    {
        Vector3 startScale = _startScale * ScaleOutCurve.Evaluate(1);
        Vector3 endScale   = _startScale * ScaleOutCurve.Evaluate(0);

        for (float time = 0; time < HydrateTime; time += UseUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime)
        {
            float t = time / HydrateTime;
            transform.localScale = Vector3.LerpUnclamped(startScale, endScale, ScaleOutCurve.Evaluate(t));
            yield return(null);
        }

        transform.localScale = startScale;

        if (destroyOnFinish)
        {
            Destroy(gameObject);
        }
        else
        {
            gameObject.SetActive(false);
        }

        Dehydrated?.Invoke();
    }
コード例 #2
0
    private IEnumerator DehydrateRoutine(System.Action finishCallback = null)
    {
        Vector3 startScale = _startScale * GameGlobals.Instance.UIDehydrateCurve.Evaluate(0);
        Vector3 endScale   = _startScale * GameGlobals.Instance.UIDehydrateCurve.Evaluate(1);

        _targetTransform.localScale = startScale;

        if (_enableRandomDelay)
        {
            float waitTime = Random.Range(0, 0.3f);
            for (float time = 0; time < waitTime; time += Time.unscaledDeltaTime)
            {
                yield return(null);
            }
        }

        for (float time = 0; time < kDehydrateTime && _targetTransform != null; time += Time.unscaledDeltaTime)
        {
            float t      = time / kDehydrateTime;
            float tCurve = GameGlobals.Instance.UIDehydrateCurve.Evaluate(t);
            _targetTransform.localScale = _startScale * tCurve;
            yield return(null);
        }

        if (_targetTransform != null)
        {
            _targetTransform.localScale = endScale;
        }

        gameObject.SetActive(false);

        _currentRoutine = null;
        finishCallback?.Invoke();
        Dehydrated?.Invoke();
    }