Example #1
0
        private IEnumerator CoolDown()
        {
            float currentCharge = 0.0f;

            while (currentCharge < currentBoosterPrefab.m_CoolDownTime)
            {
                currentCharge += Time.deltaTime;
                float percentage = currentCharge / currentBoosterPrefab.m_CoolDownTime;

                // change boost loading UI to mirror numbers
                BoostLoading boostLoading = GameMaster.Instance.m_UIManager.m_BoostLoading;
                if (boostLoading != null)
                {
                    boostLoading.SetPercentage(percentage);
                }

                yield return(null);
            }

            // NOW CAN USE BOOSTER!
            canActivate = true;
            // set boost image to current booster image
            BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading;

            boostLoadingUI.SetBoostSprite(currentBoosterPrefab.m_UISprite);
            boostLoadingUI.SetPercentage(100.0f);
        }
Example #2
0
        // sets equipped booster but doesnt activate it
        public void SetEquippedBooster(Booster booster)
        {
            currentBoosterPrefab = booster;
            BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading;

            boostLoadingUI.SetBoostSprite(currentBoosterPrefab.m_UISprite);
        }
Example #3
0
        void Awake()
        {
            if (m_LeaderboardPanel == null)
            {
                m_LeaderboardPanel = FindObjectOfType <LeaderboardPanel>();
            }
            if (m_ConfirmLogoutPanel == null)
            {
                m_ConfirmLogoutPanel = FindObjectOfType <ConfirmLogoutPanel>();
            }

            // show login panels
            if (m_LoginSignupPanels == null)
            {
                m_LoginSignupPanels = FindObjectOfType <LoginSignUpPanels>();
            }
            if (m_LoginSignupPanels)
            {
                m_LoginSignupPanels.gameObject.SetActive(true);
            }

            if (m_InfoPanel == null)
            {
                m_InfoPanel = FindObjectOfType <InfoPanel>();
            }
            if (m_MainMenuPanel == null)
            {
                m_MainMenuPanel = FindObjectOfType <MainMenuPanel>();
            }
            if (m_FadePanel == null)
            {
                m_FadePanel = FindObjectOfType <FadePanel>();
            }
            if (m_LevelPanel == null)
            {
                m_LevelPanel = FindObjectOfType <LevelPanel>();
            }
            if (m_ShopCanvas == null)
            {
                m_ShopCanvas = FindObjectOfType <ShopCanvas>();
            }
            if (m_BoostLoading == null)
            {
                m_BoostLoading = FindObjectOfType <BoostLoading>();
            }
            if (m_ScorePanel == null)
            {
                m_ScorePanel = FindObjectOfType <ScoreMenuPanel>();
            }
        }
Example #4
0
        // countdown timer for when boost is over
        private IEnumerator StartBoostDurationCountdown()
        {
            BoostLoading boostLoading = GameMaster.Instance.m_UIManager.m_BoostLoading;

            if (boostLoading != null)
            {
                float currTime = currentBoosterInstance.m_CoolDownTime;
                while (currTime >= 0.0f)
                {
                    currTime -= Time.deltaTime;
                    boostLoading.SetText((currTime).ToString("F1"));
                    yield return(null);
                }
            }
        }
Example #5
0
        public void Reset()
        {
            // if we have a booster prefab that is equipped on player
            if (currentBoosterPrefab != null)
            {
                // stop possible coroutines that could still be running
                StopCoroutine("StartBoostDurationCountdown");
                StopCoroutine("CoolDown");
                StopCoroutine("ActivateCurrentBooster");

                // allow the boost to be reset and active
                BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading;
                boostLoadingUI.SetPercentage(100.0f);
                canActivate = true;

                // destroy previous instance of boost is there was one
                if (currentBoosterInstance != null)
                {
                    Destroy(currentBoosterInstance.gameObject);
                }
            }
        }
Example #6
0
        // activates equipped booster
        public IEnumerator ActivateCurrentBooster()
        {
            if (currentBoosterPrefab != null && canActivate)
            {
                BoostLoading boostLoadingUI = GameMaster.Instance.m_UIManager.m_BoostLoading;
                boostLoadingUI.HideBoostImage();
                currentBoosterInstance = Instantiate(currentBoosterPrefab, this.transform);
                if (!currentBoosterInstance.shouldShowOnPlayer)
                {
                    currentBoosterInstance.spriteRenderer.enabled = false;
                }
                currentBoosterInstance.Activate();
                canActivate = false;

                // duration countdown
                yield return(StartCoroutine("StartBoostDurationCountdown"));

                // cooldown timer
                yield return(StartCoroutine("CoolDown"));

                boostLoadingUI.ShowBoostImage();
                canActivate = true;
            }
        }
Example #7
0
 private void OnEnable()
 {
     instance = (BoostLoading)target;
 }