Esempio n. 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());
    }
Esempio n. 2
0
    public void MoveToCell(BoardCell cell)
    {
        if (Cell)
        {
            Cell.FreeFrom(Unit);
        }

        Cell = cell;
        cell.OccupyBy(Unit);

        CoroutineExt.Restart(ref moveCoroutine, this, MoveTransition());
    }
Esempio n. 3
0
    public void TeleportToCell(BoardCell cell)
    {
        if (Cell)
        {
            Cell.FreeFrom(Unit);
        }

        Cell = cell;
        cell.OccupyBy(Unit);

        transform.position = cell.transform.position;
        CoroutineExt.Stop(ref moveCoroutine, this);
    }
Esempio n. 4
0
    private void OnHidden()
    {
        gameObject.SetActive(false);

        CoroutineExt.Stop(ref fillCoroutine, HealthBars);

        if (shouldDestroyAfterHide)
        {
            Destroy(gameObject);
        }

        HealthBars.UnRegisterHealthBar(this);
    }
Esempio n. 5
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());
    }
Esempio n. 6
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());
    }
Esempio n. 7
0
        void Start()
        {
            fullName = name.Split('_');
            body     = GetComponent <Rigidbody2D>();
            scream   = GetComponent <AudioSource>();

            startPos   = transform.position;
            controller = GetComponentInChildren <BasePattern>();
            automator  = GetComponentInChildren <AutomateBase>();

            int delay = Random.Range(60, 120);

            StartCoroutine(
                CoroutineExt.WaitForFramesDo(delay, () => { controller.TriggerAutoFire = true; automator.enabled = true; })
                );

            endScreen.SetActive(false);
        }
Esempio n. 8
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());
    }
Esempio n. 9
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());
    }
Esempio n. 10
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());
    }
Esempio n. 11
0
 public static Coroutine Start(MonoBehaviour obj, IEnumerator coroutine)
 {
     var coroutineObject = new CoroutineExt();
     return obj.StartCoroutine(coroutineObject.InternalRoutine(coroutine));
 }