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); }); }; }
public override void InitWindowOnAwake() { base.InitWindowOnAwake(); InitWindowCoreData(); twPositions = new TweenPosition[4]; btnInfor = GameUtility.FindDeepChild(this.gameObject, "LeftBottom/Btns/Btn_Infor").gameObject; btnRank = GameUtility.FindDeepChild(this.gameObject, "LeftBottom/Btns/Btn_Rank").gameObject; btnLevel = GameUtility.FindDeepChild(this.gameObject, "LeftBottom/Btns/Btn_Level").gameObject; btnSwitch = GameUtility.FindDeepChild(this.gameObject, "BottomRight/Btn_Switch").gameObject; btnSkill = GameUtility.FindDeepChild(this.gameObject, "LeftBottom/Btns/Btn_Skill").gameObject; lbSwitch = GameUtility.FindDeepChild <UILabel>(this.gameObject, "BottomRight/Btn_Switch/Label"); twPositions[0] = btnInfor.GetComponent <TweenPosition>(); twPositions[1] = btnRank.GetComponent <TweenPosition>(); twPositions[2] = btnLevel.GetComponent <TweenPosition>(); twPositions[3] = btnSkill.GetComponent <TweenPosition>(); UIEventListener.Get(btnRank).onClick = delegate { ShowWindowData showData = new ShowWindowData(); showData.forceResetWindow = true; string[] headIcons = new string[] { "Rambo", "Angry", "Smile", "Laugh", "Dead", "Frown", "Annoyed" }; // fill the rank data ContextDataRank contextData = new ContextDataRank(); contextData.listRankItemDatas = new List <RankItemData>(); // rank list for (int i = 0; i < 10; i++) { RankItemData newData = new RankItemData(); newData.playerName = headIcons[UnityEngine.Random.Range(0, headIcons.Length)]; newData.headIcon = "Emoticon - " + newData.playerName; newData.playerName = "Mr." + newData.playerName; newData.playerDescription = string.Format("I'm {0}", newData.playerName); contextData.listRankItemDatas.Add(newData); } showData.contextData = contextData; UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_Rank, showData); }; UIEventListener.Get(btnSwitch).onClick = delegate { switchFlag = !switchFlag; if (switchFlag) { ShowBtns(); } else { HideBtns(); } }; UIEventListener.Get(btnLevel).onClick = delegate { UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_Level); }; UIEventListener.Get(btnSkill).onClick = delegate { UICenterMasterManager.Instance.ShowWindow(WindowID.WindowID_Skill); }; }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // Check the window control state if (!this.IsWindowInControl(id)) { Debuger.Log("## UIManager has no control power of " + id.ToString()); return(null); } // If the window in shown list just return if (dicShownWindows.ContainsKey((int)id)) { return(null); } UIBaseWindow baseWindow = GetGameWindow(id); // If window not in scene start Instantiate new window to scene bool newAdded = false; if (!baseWindow) { newAdded = true; if (UIResourceDefine.windowPrefabPath.ContainsKey((int)id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[(int)id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); // NOTE: You can add component to the window in the inspector // Or just AddComponent<UIxxxxWindow>() to the target baseWindow = uiObject.GetComponent <UIBaseWindow>(); if (baseWindow.ID != id) { Debuger.LogError(string.Format("<color=cyan>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id)); return(null); } // Get the window target root parent Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); dicAllWindows[(int)id] = baseWindow; } } } if (baseWindow == null) { Debuger.LogError("[window instance is null.]" + id.ToString()); } // Call reset window when first load new window // Or get forceResetWindow param if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } if (showData == null || (showData != null && showData.executeNavLogic)) { // refresh the navigation data ExecuteNavigationLogic(baseWindow, showData); } // Adjust the window depth AdjustBaseWindowDepth(baseWindow); // Add common background collider to window AddColliderBgForWindow(baseWindow); return(baseWindow); }