예제 #1
0
        public void UnloadLevel(string sceneFilePath, Action completeAction, bool async)
        {
            if (async)
            {
                if (QLogger.CanLogInfo)
                {
                    QLogger.LogInfo("Unload of scene " + sceneFilePath + " has begun");
                }

                AsyncOperation operation = SceneManager.UnloadSceneAsync(sceneFilePath);
                operation.completed += delegate(AsyncOperation o)
                {
                    if (QLogger.CanLogInfo)
                    {
                        QLogger.LogInfo("Unload of scene " + sceneFilePath + " has completed");
                    }
                    if (completeAction != null)
                    {
                        completeAction();
                    }
                };
            }
            else
            {
                QLogger.LogErrorAndThrowException("We only have async version for unload as direct one was made obselete by unity");
            }
        }
예제 #2
0
        public UIPanel ShowGamePlayScreen(string screenName, bool visible)
        {
            UIPanelInstance panelInstance = GetPanelInstance(screenName);

            if (panelInstance == null)
            {
                UIPanelInfo panelInfo = GetPanelReference(screenName);
                if (panelInfo == null)
                {
                    QLogger.LogErrorAndThrowException("No screen found with name:" + screenName);
                }
                if (panelInfo.type != UIPanelInfo.Type.GamePlay)
                {
                    QLogger.LogErrorAndThrowException("This panel is not a screen type");
                }
                panelInstance = CreatePanelInstanceAndAddToListIfNess(panelInfo);
                if (panelInstance == null)
                {
                    QLogger.LogErrorAndThrowException("Panel instance was not created!");
                }
            }
            if (!(panelInstance is GamePlayScreenPanelInstance))
            {
                QLogger.LogErrorAndThrowException("This panel is not screen type - 2");
            }
            GamePlayScreenPanelInstance screenInstance = panelInstance as GamePlayScreenPanelInstance;

            if (!gamePlayScreenPanels.Contains(screenInstance))
            {
                gamePlayScreenPanels.Add(screenInstance);
            }

            panelInstance.instance.SetActive(visible);
            return(panelInstance.uiPanel);
        }
예제 #3
0
 // Prevent the class from behind created by the client
 public Singleton()
 {
     if (mUniqueInstance != null)
     {
         QLogger.LogErrorAndThrowException("Singleton [" + typeof(T) + "] cannot be manually instantiated and Singleton.Instance can only be called from the main thread.");
     }
 }
예제 #4
0
        public UIPanelInstance CreatePanelInstanceAndAddToListIfNess(UIPanelInfo panel)
        {
            if (GetPanelInstance(panel.panelName) != null)
            {
                return(GetPanelInstance(panel.panelName));
            }

            if (panel.uiObjectReference == null)
            {
                panel.uiObjectReference = ResourceManager.Instance.LoadAsset <UnityEngine.Object>(panel.objectPath);
            }

            if (panel.uiObjectReference == null)
            {
                QLogger.LogErrorAndThrowException("Panel object not found!");
            }

            GameObject instance = GameObject.Instantiate(panel.uiObjectReference, new Vector3(9999, 9999, 9999), Quaternion.identity, transform) as GameObject;

            instance.SetActive(false);
            instance.transform.localPosition = panel.localPosition;
            UIPanelInstance panelInstance = null;

            if (panel.type == UIPanelInfo.Type.Screen)
            {
                panelInstance = new ScreenPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.Popup)
            {
                panelInstance = new PopupPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.Alert)
            {
                panelInstance = new AlertPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.GamePlay)
            {
                panelInstance = new GamePlayScreenPanelInstance();
            }
            else
            {
                QLogger.LogErrorAndThrowException("Should not be here !");
            }

            panelInstance.panelInfo = panel;
            panelInstance.instance  = instance;
            panelInstance.uiPanel   = instance.GetComponent <UIPanel>();
            if (panelInstance.uiPanel == null)
            {
                QLogger.LogErrorAndThrowException("Ui panel instance not found ");
            }
            panelsInMemory.Add(panelInstance);
            return(panelInstance);
        }
예제 #5
0
        public void SetLog(int track, string log)
        {
            QLogger.Assert(track >= 0 && track < maxTracks);
            this.log[track] = log;

            strLog.Length = 0;                  //clearing

            for (int i = 0; i < maxTracks; i++)
            {
                if (!string.IsNullOrEmpty(this.log[i]))
                {
                    strLog.Append(string.Format("[{0}] -> {1}\n", i, this.log[i]));
                }
            }
        }
예제 #6
0
        // Prevent the class from behind created by the client
        protected virtual void Awake()
        {
            if (uniqueInstance == null)
            {
                uniqueInstance = this;
                if (!DestroyOnSceneSwitch && transform.parent == null)
                {
                    DontDestroyOnLoad(this.gameObject);
                }
            }

            if (uniqueInstance != this)
            {
                QLogger.LogErrorAndThrowException("Cannot have two instances of a SingletonMonoBehaviour " + typeof(T).ToString() + ".");
            }
        }
예제 #7
0
        // Prevent the class from behind created by the client
        protected virtual void Awake()
        {
            if (QLogger.CanLogInfo)
            {
                QLogger.LogInfo(string.Format("{0} instantiated.", typeof(T)));
            }

            if (uniqueInstance == null)
            {
                uniqueInstance = this;
            }
            else if (uniqueInstance != this)
            {
                QLogger.LogErrorAndThrowException("Cannot have two instances of a SingletonMonoBehaviour : " + typeof(T).ToString() + ".");
            }
        }
예제 #8
0
        public void CloseUiPanelAndRemoveFromListIfNess(UIPanelInstance instance)
        {
            if (instance == null)
            {
                QLogger.LogErrorAndThrowException("panel instance is null"); return;
            }

            if (instance.panelInfo.keepInMemory)
            {
                instance.uiPanel.Reset();
                instance.instance.SetActive(false);
            }
            else
            {
                GameObject.Destroy(instance.instance);
                panelsInMemory.Remove(instance);
            }
        }
예제 #9
0
        public T LoadAsset <T>(string path) where T : UnityEngine.Object
        {
            if (!isInitiated)
            {
                Initialize();
            }

            UnityEngine.Object obj = resouceMap.GetObjectAtPath(path);
            if (obj == null)
            {
                QLogger.LogErrorAndThrowException("Object not found for " + path);
            }
            if ((obj as T) == null)
            {
                QLogger.LogErrorAndThrowException("Object casting failed " + path);
            }

            return(obj as T);
        }
예제 #10
0
 public UnityEngine.Object GetObjectAtPath(string path)
 {
     if (Mapping == null)
     {
         QLogger.LogErrorAndThrowException("Mapping is empty");
     }
     foreach (Map map in Mapping)
     {
         if (map.path == path)
         {
             return(map.obj);
         }
     }
     foreach (Map map in FolderMapping)
     {
         if (map.path == path)
         {
             return(map.obj);
         }
     }
     return(null);
 }
예제 #11
0
 public void LoadLevel(string sceneFilePath, bool additive, Action completeAction, bool async)
 {
     if (!isInitiated)
     {
         Initialize();
     }
     if (QLogger.CanLogInfo)
     {
         QLogger.LogInfo("Load scene " + sceneFilePath + " has begun");
     }
     if (async)
     {
         AsyncOperation operation = SceneManager.LoadSceneAsync(sceneFilePath, additive ? LoadSceneMode.Additive : LoadSceneMode.Single);
         operation.completed += delegate(AsyncOperation o)
         {
             if (QLogger.CanLogInfo)
             {
                 QLogger.LogInfo("Load scene " + sceneFilePath + " has completed");
             }
             if (completeAction != null)
             {
                 completeAction();
             }
         };
     }
     else
     {
         SceneManager.LoadScene(sceneFilePath, additive ? LoadSceneMode.Additive : LoadSceneMode.Single);
         if (completeAction != null)
         {
             if (QLogger.CanLogInfo)
             {
                 QLogger.LogInfo("Load scene " + sceneFilePath + " has completed");
             }
             completeAction();
         }
     }
 }
예제 #12
0
        public UIPanel PushScreen(string screenName, bool visible)
        {
            UIPanelInstance panelInstance = GetPanelInstance(screenName);

            if (panelInstance == null)
            {
                UIPanelInfo panelInfo = GetPanelReference(screenName);
                if (panelInfo == null)
                {
                    QLogger.LogErrorAndThrowException("No screen found with name:" + screenName);
                }
                if (panelInfo.type != UIPanelInfo.Type.Screen)
                {
                    QLogger.LogErrorAndThrowException("This panel is not a screen type");
                }
                panelInstance = CreatePanelInstanceAndAddToListIfNess(panelInfo);
                if (panelInstance == null)
                {
                    QLogger.LogErrorAndThrowException("Panel instance was not created!");
                }
            }
            if (!(panelInstance is ScreenPanelInstance))
            {
                QLogger.LogErrorAndThrowException("This panel is not screen type - 2");
            }
            ScreenPanelInstance screenInstance = panelInstance as ScreenPanelInstance;

            if (screenPanelStack.Count > 0)
            {
                screenPanelStack.Peek().uiPanel.OnPusedBack();
                screenPanelStack.Peek().instance.SetActive(false);
            }
            screenPanelStack.Push(screenInstance);
            panelInstance.instance.SetActive(visible);
            return(panelInstance.uiPanel);
        }
예제 #13
0
 public void ShowLoadingScreen(bool show)
 {
     QLogger.LogError("NYI");
 }