Shows the number of current and max lives available in a minigame.
Inheritance: Antura.UI.ABSMinigamesUIComponent
Example #1
0
        void Awake()
        {
            I = this;

            if (HasElement(MinigamesUIElement.Unset))
            {
                Debug.LogWarning("MinigamesUI ► Elements are Unset");
                return;
            }

            Starbar = this.GetComponentInChildren <MinigamesUIStarbar>(true);
            Timer   = this.GetComponentInChildren <MinigamesUITimer>(true);
            Lives   = this.GetComponentInChildren <MinigamesUILives>(true);
            Starbar.gameObject.SetActive(HasElement(MinigamesUIElement.Starbar));
            Timer.gameObject.SetActive(HasElement(MinigamesUIElement.Timer));
            Lives.gameObject.SetActive(HasElement(MinigamesUIElement.Lives));
            if (HasElement(MinigamesUIElement.Timer) && HasElement(MinigamesUIElement.Lives))
            {
                // Shift lives under timer
                Lives.RectTransform.SetAnchoredPosY(Timer.RectTransform.anchoredPosition.y - Timer.RectTransform.sizeDelta.y * 0.5f);
            }

            // Activate and animate elements entrance
            const float duration = 0.5f;

            showTween = DOTween.Sequence();
            TweenParams tp = TweenParams.Params.SetEase(Ease.OutBack);

            if (HasElement(MinigamesUIElement.Starbar))
            {
                showTween.Insert(0, Starbar.RectTransform.DOAnchorPosX(0, duration).From().SetAs(tp));
            }
            if (HasElement(MinigamesUIElement.Timer))
            {
                showTween.Insert(0, Timer.RectTransform.DOAnchorPosX(Timer.RectTransform.sizeDelta.x * 0.5f, duration).From().SetAs(tp));
            }
            if (HasElement(MinigamesUIElement.Lives))
            {
                showTween.Insert(0, Lives.RectTransform.DOAnchorPosX(0, duration).From().SetAs(tp));
            }
        }