Esempio n. 1
0
        public override void InitWindowOnAwake()
        {
            this.windowID = WindowID.WindowID_Matching;
            base.InitWindowOnAwake();

            InitWindowData();

            btnWin  = GameUtility.FindDeepChild(this.gameObject, "BtnWin").gameObject;
            btnLose = GameUtility.FindDeepChild(this.gameObject, "BtnLose").gameObject;

            // win the game
            UIEventListener.Get(btnWin).onClick = delegate
            {
                GameMonoHelper.GetInstance().LoadGameScene("TestEmptyScene", delegate
                {
                    // 是否需要一个退出比赛单独接口?
                    // UIManager.GetInstance().ShowWindow(WindowID.WindowID_TopBar);
                    // UIManager.GetInstance().ShowWindow(WindowID.WindowID_LevelDetail);

                    UIManager.GetInstance().ShowWindow(WindowID.WindowID_MatchResult);
                    UIBaseWindow baseWindow = UIManager.GetInstance().GetGameWindow(WindowID.WindowID_MatchResult);
                    ((UIMatchResult)baseWindow).SetMatchResult(true, targetBackWindowId);
                });
            };

            // lose the game
            UIEventListener.Get(btnLose).onClick = delegate
            {
                GameMonoHelper.GetInstance().LoadGameScene("TestEmptyScene", delegate
                {
                    UIManager.GetInstance().ShowWindow(WindowID.WindowID_MatchResult);
                    UIBaseWindow baseWindow = UIManager.GetInstance().GetGameWindow(WindowID.WindowID_MatchResult);
                    ((UIMatchResult)baseWindow).SetMatchResult(false, targetBackWindowId);
                });
            };
        }
Esempio n. 2
0
        protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
        {
            // 检测控制权限
            if (!this.IsWindowInControl(id))
            {
                Debug.Log("UIManager has no control power of " + id.ToString());
                return(null);
            }
            if (shownWindows.ContainsKey(id))
            {
                return(null);
            }

            // 隐藏callWindowId指向窗口

            /*if(showData != null)
             *  HideWindow(showData.callWindowId, null);*/

            UIBaseWindow baseWindow = GetGameWindow(id);
            bool         newAdded   = false;

            if (!baseWindow)
            {
                newAdded = true;
                // 窗口不存在从内存进行加载
                if (UIResourceDefine.windowPrefabPath.ContainsKey(id))
                {
                    string     prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[id];
                    GameObject prefab     = Resources.Load <GameObject>(prefabPath);
                    if (prefab != null)
                    {
                        GameObject uiObject = (GameObject)GameObject.Instantiate(prefab);
                        NGUITools.SetActive(uiObject, true);
                        baseWindow = uiObject.GetComponent <UIBaseWindow>();
                        // 需要动态添加对应的控制界面,prefab不用添加脚本
                        Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType);
                        GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform);
                        allWindows[id] = baseWindow;
                    }
                }
            }

            if (baseWindow == null)
            {
                Debug.LogError("[window instance is null.]" + id.ToString());
            }

            // 重置界面(第一次添加,强制Reset)
            if (newAdded || (showData != null && showData.forceResetWindow))
            {
                baseWindow.ResetWindow();
            }

            // 显示界面固定内容


            // 导航系统数据更新
            RefreshBackSequenceData(baseWindow);
            // 调整层级depth
            AdjustBaseWindowDepth(baseWindow);
            // 添加背景Collider
            AddColliderBgForWindow(baseWindow);
            return(baseWindow);
        }