Example #1
0
    private void PlayVisibility(bool show)
    {
        IEnumerator Sequence()
        {
            if (show && gameObject.activeSelf == false)
            {
                gameObject.SetActive(true);
            }

            float t = 0f;

            while (t < 1f)
            {
                t += Time.deltaTime / 0.15f;

                yield return(null);
            }

            if (show == false)
            {
                OnHidden();
            }
        }

        CoroutineExt.Restart(ref visibilityCoroutine, HealthBars, Sequence());
    }
Example #2
0
    public void MoveToCell(BoardCell cell)
    {
        if (Cell)
        {
            Cell.FreeFrom(Unit);
        }

        Cell = cell;
        cell.OccupyBy(Unit);

        CoroutineExt.Restart(ref moveCoroutine, this, MoveTransition());
    }
Example #3
0
    public void PlayAppearAnimation()
    {
        IEnumerator Sequence()
        {
            float t = 0f;

            while (t < 1f)
            {
                t += Time.deltaTime / 0.2f;
                transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, Curves.easeOut.Evaluate(t));
                yield return(null);
            }
        }

        CoroutineExt.Restart(ref visibilityCoroutine, this, Sequence());
    }
Example #4
0
    private void PlayVisibilityAnimation(bool show)
    {
        IEnumerator Transition()
        {
            const float TargetScale = 1.1f;

            if (show && gameObject.activeSelf == false)
            {
                gameObject.SetActive(true);

                canvasGroup.alpha    = 0f;
                transform.localScale = Vector3.one * TargetScale;
            }

            if (show)
            {
                OnShowing();
            }

            float startAlpha = canvasGroup.alpha;
            float endAlpha   = show ? 1f : 0f;

            Vector3 startScale = transform.localScale;
            Vector3 endScale   = show ? Vector3.one : Vector3.one * TargetScale;

            float t = 0f;

            while (t < 1f)
            {
                t += Time.deltaTime / 0.2f;

                canvasGroup.alpha    = Mathf.Lerp(startAlpha, endAlpha, t);
                transform.localScale = Vector3.Lerp(startScale, endScale, t);

                yield return(null);
            }

            if (show == false)
            {
                gameObject.SetActive(false);
            }
        }

        CoroutineExt.Restart(ref visibilityCoroutine, GameUI, Transition());
    }
Example #5
0
    public void PlayDamageResponseShake()
    {
        IEnumerator Sequence()
        {
            shakeAmount = damageResponseShakeAmount;

            yield return(new WaitForSeconds(damageResponseShakeDuration));

            float t = 0f;

            while (t < 1f)
            {
                t          += Time.deltaTime / 0.1f;
                shakeAmount = Mathf.Lerp(damageResponseShakeAmount, 0f, t);
                yield return(null);
            }
        }

        CoroutineExt.Restart(ref damageResponseShakeCoroutine, this, Sequence());
    }
Example #6
0
    public void PlayDeathAnimation()
    {
        IEnumerator Sequence()
        {
            Vector3 startScale = transform.localScale;
            Vector3 endScale   = startScale * 1.15f;

            float t = 0f;

            while (t < 1f)
            {
                t += Time.deltaTime / 0.4f;
                spriteRenderer.color = spriteRenderer.color.SetA(Mathf.Lerp(1f, 0f, t));
                transform.localScale = Vector3.Lerp(startScale, endScale, t);
                yield return(null);
            }

            OnHided.Invoke();
        }

        CoroutineExt.Restart(ref visibilityCoroutine, this, Sequence());
    }
Example #7
0
    private void PlayUpdateValue()
    {
        IEnumerator Sequence()
        {
            float startFillAmount = fillImage.fillAmount;
            float endFillAmount   = healthSystem.NormalizedCurrentHealth;

            float t = 0f;

            while (t < 1f)
            {
                t += Time.deltaTime / 0.15f;

                fillImage.fillAmount = Mathf.Lerp(startFillAmount, endFillAmount, Curves.smooth.Evaluate(t));
                fillImage.color      = GetFillColor();

                yield return(null);
            }
        }

        CoroutineExt.Restart(ref fillCoroutine, HealthBars, Sequence());
    }