Example #1
0
        private void Awake()
        {
            #region Make Singleton
            //Check if instance already exists
            if (instance == null)
            {
                //if not, set instance to this
                instance = this;
            }

            //If instance already exists and it's not this:
            else if (instance != this)
            {
                //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
                Destroy(gameObject);
            }

            //Sets this to not be destroyed when reloading scene
            DontDestroyOnLoad(gameObject);
            #endregion

            //ForceName
            this.name = "[MANAGER]UIManager";

            //Check Tag
            if (!this.gameObject.CompareTag("Manager"))
            {
                XDebug.LogErrorRed(this.name + "'s Tag is not set to Manager", "!!!ERROR!!!");
            }
        }
Example #2
0
        /// <summary>
        /// Updates the FPS Related Variables and UI Elements
        /// </summary>
        public void UpdateFPSModule()
        {
            if (!useFPSModule)
            {
                XDebug.ManagerLog("FPS MODULE IS INACTIVE", "****UI MANAGER****");
                return;
            }

            if (currentAmmoText)
            {
                currentAmmoText.text = currentAmmo.ToString();
            }

            if (clipSizeText)
            {
                clipSizeText.text = clipSize.ToString();
            }

            if (totalAmmoText)
            {
                totalAmmoText.text = totalAmmo.ToString();
            }

            if (currentGrenadesText)
            {
                currentGrenadesText.text = currentGrenades.ToString();
            }

            if (totalGrenadesText)
            {
                totalGrenadesText.text = totalGrenades.ToString();
            }
        }
Example #3
0
        IEnumerator TestRestart()
        {
            yield return(new WaitForSeconds(2f));

            mainTimer.RestartTimer(10);


            if (mainTimer.TimerExpired == null)
            {
                XDebug.LogYellow("TimerCallBackEmpty", "----");
                mainTimer.TimerExpired = new UnityEngine.Events.UnityEvent();
            }
            mainTimer.TimerExpired.AddListener(TestCallBack);

            yield break;
        }
Example #4
0
        private void TestMainTimer()
        {
            mainTimer.TotalTime = 5f;
            mainTimer.Init();
            mainTimer.EnableDebugMode();
            mainTimer.timerMode = Timer.TimerMode.Incremental;

            //mainTimer.SetTimer(5f);

            if (mainTimer.TimerExpired == null)
            {
                XDebug.LogYellow("CallBackEmpty", "----");
                mainTimer.TimerExpired = new UnityEngine.Events.UnityEvent();
            }
            mainTimer.TimerExpired.AddListener(TestCallBack);

            CreateTimerInstance("XYZ");
            CreateTimerInstance("ABC", true);
        }
Example #5
0
        /// <summary>
        /// Iterate over all the children to find the Last GameObject with tag
        /// </summary>
        /// <param name="m_transform">Transform Target</param>
        /// <param name="tag">String Tag to Match</param>
        /// <returns>Returns the Last Child with desired Tag, Or returns null if the Target Transfomr has no child</returns>
        public static GameObject FindLastChildWithTag(this Transform target, string tag)
        {
            GameObject childGameObject = null;

            if (target.childCount == 0)
            {
                XDebug.LogRed("Transform has no Children, RETURNING NULL", "**[EXTENSION METHOD ERROR]**");
                return(childGameObject);
            }
            else
            {
                //Iterate over all the children to find the Last GameObject with tag
                for (int i = 1; i < target.childCount; i++)
                {
                    if (target.GetChild(i).gameObject.CompareTag(tag))
                    {
                        childGameObject = target.GetChild(i).gameObject;
                    }
                }
            }

            return(childGameObject);
        }
Example #6
0
        private void IncrementTime()
        {
            if (isExpired)
            {
                Debug.Log("Game Timer is Expired");
                return;
            }
            if (timer < TotalTime)
            {
                timer++;
            }
            else if (timer == TotalTime)
            {
                if (isDebug)
                {
                    XDebug.ManagerLog("Invoking Expired Event", "****TIMER****");
                    TimerExpired.Invoke();
                }
                else
                {
                    TimerExpired.Invoke();
                }

                isExpired = true;
                CancelInvoke("IncrementTime");
                CancelInvoke("DecrementTime");
                if (isDebug)
                {
                    XDebug.ManagerLog("TimerExpired", "****TIMER****");
                }
            }

            if (!isExpired)
            {
                FormatTime(timer);
            }
        }
Example #7
0
        /// <summary>
        /// Iterate over all the children to find the All GameObjects with tag
        /// </summary>
        /// <param name="m_transform">Transform Target</param>
        /// <param name="tag">String Tag to Match</param>
        /// <returns>Returns the All Children with desired Tag, Or returns null if the Target Transfomr has no child</returns>
        public static GameObject[] FindAllChildrenWithTag(this Transform target, string tag)
        {
            GameObject[] childGameObject = null;
            int          count           = 0;

            if (target.childCount == 0)
            {
                XDebug.LogRed("Transform has no Children, RETURNING NULL", "**[EXTENSION METHOD ERROR]**");
                return(childGameObject);
            }
            else
            {
                //Iterate over all the children to find the All GameObjects with tag
                for (int i = 1; i < target.childCount; i++)
                {
                    if (target.GetChild(i).gameObject.CompareTag(tag))
                    {
                        count++;
                    }
                }

                childGameObject = new GameObject[count];
                count           = 0; //Re-Initialize to be the counter of the New Array

                for (int i = 1; i < target.childCount; i++)
                {
                    if (target.GetChild(i).gameObject.CompareTag(tag))
                    {
                        childGameObject[count] = target.GetChild(i).gameObject;
                        count++;
                    }
                }
            }

            return(childGameObject);
        }
Example #8
0
        /// <summary>
        /// Updates the Health Related Variables and UI Elements
        /// </summary>
        public void UpdateHealthModule()
        {
            if (!useHealthModule)
            {
                XDebug.ManagerLog("HEALTH MODULE IS INACTIVE", "****UI MANAGER****");
                return;
            }


            if (healthText)
            {
                healthText.text = CurrentHealth.ToString();
            }

            if (CurrentHealth > MaxHealth)
            {
                CurrentHealth = MaxHealth;
            }

            if (CurrentHealth < 0)
            {
                CurrentHealth = 0;
            }
        }
Example #9
0
 private void TestCallBack()
 {
     XDebug.LogGreen("TIMER EXPIRE CALL BACK", "***");
     StartCoroutine(TestRestart());
 }