Example #1
0
    public override void Handle()
    {
        if (useQueue)
        {
            //  Tick lifetime if active
            if (IsActive())
            {
                if (lifeTime >= duration)
                {
                    Disable();
                }

                lifeTime += Time.deltaTime;
            }

            //  If next in queue is a matching type, pull it
            if (UIMaster.GetWaitingTexts().Count > 0 && UIMaster.GetWaitingTexts()[0].type == type)
            {
                lifeTime = 0f;

                textElement.text = UIMaster.GetWaitingTexts()[0].text;
                UIMaster.GetWaitingTexts().RemoveAt(0);

                Enable();
            }
        }
        else
        {
            for (int i = 0; i < UIMaster.GetWaitingTexts().Count; i++)
            {
                UIText waitingText = UIMaster.GetWaitingTexts()[i];

                if (waitingText.type == type)
                {
                    textElement.text = waitingText.text;
                    UIMaster.GetWaitingTexts().RemoveAt(i);

                    Enable();
                    return;
                }
            }

            //  Fallback to disabling
            Disable();
        }
    }