Пример #1
0
    private IEnumerator UpdateSizeAsync()
    {
        AudioManager.Instance.PlaySound(_growSound);

        Vector3 startScale = _visualRoot.localScale;
        Vector3 endScale   = Vector3.one * CritterConstants.GetCreatureSizeScale(_size);

        for (float time = 0; time < kGrowAnimationDuration; time += Time.deltaTime)
        {
            float t      = time / kGrowAnimationDuration;
            float tCurve = _growUpCurve.Evaluate(t);
            _visualRoot.localScale = Vector3.LerpUnclamped(startScale, endScale, tCurve);
            yield return(null);
        }
    }
Пример #2
0
    private void SetSize(CritterConstants.CreatureSize newSize, bool animate)
    {
        _size            = newSize;
        _critterDNA.Size = newSize;
        _vigorUI.gameObject.SetActive(((int)_size >= (int)kMinVigorSize));

        if (animate)
        {
            StartCoroutine(UpdateSizeAsync());
        }
        else
        {
            _visualRoot.localScale = Vector3.one * CritterConstants.GetCreatureSizeScale(_size);
        }
    }