/// <summary> /// 第一次开窗时调用 by吴江 应该每次开窗都要调用呀 /// </summary> protected virtual void Init() { if (subWndDictionary.ContainsKey(initSubGUIType)) { curSubGUIType = SwitchToSubWnd(initSubGUIType); } }
void OpenSubWnd() { if (initSubGUIType != guiBase.InitSubGUIType) { initSubGUIType = guiBase.InitSubGUIType; for (int i = 0; i < subWndType.Length; i++) { if (initSubGUIType == subWndType[i]) { togs[i].value = true; return; } } } if (curSubGUIType != guiBase.CurSubGUIType) { curSubGUIType = guiBase.CurSubGUIType; for (int i = 0; i < subWndType.Length; i++) { if (guiBase.CurSubGUIType == subWndType[i]) { togs[i].value = true; return; } } } }
//填充静态预制 public void FillInfo(SevenDaysTaskRef _dataRef) { //Debug.Log("FillInfo:" + _dataRef.des1); if (_dataRef.Action == 1) { //Debug.Log("_dataRef.Action:"+_dataRef.Action); if (btnGo != null) { UIEventListener.Get(btnGo.gameObject).onClick = delegate { if (_dataRef.num == 1) { GUIType type = (GUIType)System.Enum.Parse(typeof(GUIType), _dataRef.ui); //Debug.Log("type:" + type); GameCenter.uIMng.SwitchToUI(GUIType.NONE); //GameCenter.uIMng.ReleaseGUI(GUIType.SEVENCHALLENGE); GameCenter.uIMng.SwitchToUI(type); } else if (_dataRef.num == 2) { SubGUIType type = (SubGUIType)System.Enum.Parse(typeof(SubGUIType), _dataRef.ui); //GameCenter.uIMng.ReleaseGUI(GUIType.SEVENCHALLENGE); GameCenter.uIMng.SwitchToUI(GUIType.NONE); GameCenter.uIMng.SwitchToSubUI(type); } }; btnGo.gameObject.SetActive(true); //Invoke("DelayShow",0.75f); } } else { if (btnGo != null) { btnGo.gameObject.SetActive(false); } } if (title != null) { //data.des1; title.text = _dataRef.des1; } if (content != null) { ////data.des2; content.text = _dataRef.des2; //Debug.Log("_dataRef.des2:"+ _dataRef.des2); } if (num != null) { num.text = 0.ToString() + "/" + _dataRef.task_condition_num.ToString(); content.text = content.text.Replace("#1", num.text); } if (finish != null) { finish.gameObject.SetActive(false); } updateData(_dataRef); }
/// <summary> /// 直接跳转到某个子界面,必须是跨界面打开才调用。如果是打开本身界面的子界面,则用本身界面自身的接口 by吴江 /// </summary> /// <param name="_subType"></param> /// <param name="_baseOn"></param> public void SwitchToSubUI(SubGUIType _subType, GUIType _baseOn = GUIType.NONE) { GUIType mainType = ConfigMng.Instance.GetSubGUITypeBelong(_subType); if (mainType != GUIType.NONE) { SwitchToUI(mainType, _subType, _baseOn); } }
/// <summary> /// 加载某个界面 by吴江 /// </summary> /// <param name="_name"></param> /// <param name="_needOpen">加载以后是否需要打开</param> /// <returns></returns> public GUIBase GenGUI(string _name, bool _needOpen, SubGUIType _subType = SubGUIType.NONE, GUIType _baseOn = GUIType.NONE, System.Action <GUIBase> _callback = null) { if (uiDictionary.ContainsKey(_name) && uiDictionary[_name] != null) { if (_callback != null) { _callback(uiDictionary[_name]); } return(_needOpen ? uiDictionary[_name].OpenUI() : uiDictionary[_name].CloseUI()); } Object obj = exResources.GetResource(ResourceType.GUI, _name); if (obj == null) { Debug.LogError("找不到名为:" + _name + "的UI预制"); return(null); } GameObject gui = Instantiate(obj) as GameObject; gui.transform.parent = uIRoot.transform; gui.transform.localScale = Vector3.one; gui.transform.localPosition = Vector3.zero; gui.name = obj.name; obj = null; UIAnchor anchor = gui.GetComponent <UIAnchor>(); gui.SetActive(false); if (anchor != null) { anchor.uiCamera = GameCenter.cameraMng.uiCamera; } GUIBase guibase = gui.GetComponent <GUIBase>(); if (guibase != null) { uiDictionary[_name] = guibase; if (_subType != SubGUIType.NONE) { guibase.InitSubGUIType = _subType; } if (_needOpen) { guibase.OpenUI(_baseOn); } if (_callback != null) { _callback(guibase); } return(guibase); } else { Debug.LogError("在" + _name + " UI预制上找不到 GUIBase 组件!"); } return(null); }
void ClickLabelBack(GameObject go) { if (GameCenter.mainPlayerMng.MainPlayerInfo.CurSceneType != SceneType.SCUFFLEFIELD) { GameCenter.messageMng.AddClientMsg(405); return; } string url = labText.GetUrlAtPosition(UICamera.lastWorldPosition); if (!string.IsNullOrEmpty(url)) { string[] urlStr = url.Split('|'); if (urlStr.Length == 3) { switch (urlStr[0]) { case "0": break; case "1": //跳到一级界面 GUIType uiType = (GUIType)Enum.Parse(Type.GetType("GUIType"), urlStr[2]); if (uiType == GUIType.NEWMALL && curEquipmentInfo != null) { GameCenter.buyMng.OpenBuyWnd(curEquipmentInfo); } else { GameCenter.uIMng.SwitchToUI(uiType); } ToolTipMng.CloseAllTooltip(); break; case "2": //跳到二级界面 SubGUIType subUiType = (SubGUIType)Enum.Parse(Type.GetType("SubGUIType"), urlStr[2]); GameCenter.uIMng.SwitchToSubUI(subUiType); ToolTipMng.CloseAllTooltip(); break; case "3": int npcID = 0; if (int.TryParse(urlStr[2], out npcID)) { ToolTipMng.CloseAllTooltip(); GameCenter.uIMng.SwitchToUI(GUIType.NONE); GameCenter.taskMng.PublicTraceToNpc(npcID); } break; } } else { Debug.Log("数据错误!"); } } Debug.Log("url:" + url); }
protected void GoMustDoItem(GameObject go) { if (CurMustDoInfo != null) { if (CurMustDoInfo.UISort == 1) { GUIType type = (GUIType)System.Enum.Parse(typeof(GUIType), CurMustDoInfo.UIType); if (type == GUIType.GUILDMAIN && string.IsNullOrEmpty(GameCenter.mainPlayerMng.MainPlayerInfo.GuildName)) { GameCenter.messageMng.AddClientMsg(408); return; } GameCenter.uIMng.SwitchToUI(type); } else if (CurMustDoInfo.UISort == 2) { SubGUIType type = (SubGUIType)System.Enum.Parse(typeof(SubGUIType), CurMustDoInfo.UIType); GameCenter.uIMng.SwitchToSubUI(type); } //LivelyRef的where字段判断是否做自动寻路 if (CurMustDoInfo.RefData.where != null && CurMustDoInfo.RefData.where.Count >= 3)//大于3,否则下标越界 { CheckAutoPath(CurMustDoInfo.RefData.where); } } //仙盟活跃 if (CurLivelyInfo != null) { if (CurLivelyInfo.UISort == 1) { GUIType type = (GUIType)System.Enum.Parse(typeof(GUIType), CurLivelyInfo.UIType); if (type == GUIType.GUILDMAIN && string.IsNullOrEmpty(GameCenter.mainPlayerMng.MainPlayerInfo.GuildName)) { GameCenter.messageMng.AddClientMsg(408); return; } GameCenter.uIMng.SwitchToUI(type); } else if (CurLivelyInfo.UISort == 2) { SubGUIType type = (SubGUIType)System.Enum.Parse(typeof(SubGUIType), CurLivelyInfo.UIType); GameCenter.uIMng.SwitchToSubUI(type); } //LivelyRef的where字段判断是否做自动寻路 if (CurLivelyInfo.RefData.where != null && CurLivelyInfo.RefData.where.Count >= 3)//大于3,否则下标越界 { CheckAutoPath(CurLivelyInfo.RefData.where); } } }
void Update() { if (!isStart) { isStart = true; onChange(); initSubGUIType = guiBase.InitSubGUIType; curSubGUIType = guiBase.CurSubGUIType; } else { OpenSubWnd(); } }
protected SubGUIType SwitchToSubWnd(SubGUIType _subType) { foreach (SubWnd item in subWndDictionary.Values) { item.CloseUI(); } if (allSubWndNeedInstantiate && !subWndInstantiateState.ContainsKey(_subType) && subWndDictionary.ContainsKey(_subType)) { SubWnd subwnd = Instantiate(subWndDictionary[_subType] as SubWnd) as SubWnd; if (subwnd != null) { subwnd.transform.parent = transform; subwnd.transform.localPosition = Vector3.zero; subwnd.transform.localScale = Vector3.one; subWndDictionary[_subType] = subwnd; subWndInstantiateState[_subType] = true; } } if (subWndDictionary.ContainsKey(_subType)) { initSubGUIType = _subType; //打开界面的时候赋值 by邓成 SubWnd aim = subWndDictionary[_subType] as SubWnd; if (aim != null) { aim.OpenUI(); return(_subType); } else { Debug.LogError("子窗口:" + _subType + "为空!打开失败!"); return(SubGUIType.NONE); } } else { if (_subType != SubGUIType.NONE) { Debug.LogError("找不到子窗口:" + _subType + " ,请先注册!"); } return(SubGUIType.NONE); } }
/// <summary> /// 设置一个UILabel链接至UI界面 /// </summary> public static void SetUrlToUI(UILabel _lab, string _urlDes, string _urlText) { if (_lab != null) { _lab.text = GameHelper.GetUrlString(_urlDes, _urlText); } GameHelper.SetUrlCallback(_lab, (x) => { try { GUIType uiType = (GUIType)Enum.Parse(Type.GetType("GUIType"), (string)x, true); if (uiType != GUIType.NONE) { if (uiType == GUIType.NEWMALL) { GameCenter.newMallMng.OpenMall(); } else if (uiType == GUIType.SHOPWND) { GameCenter.shopMng.OpenShopWnd(); } else { GameCenter.uIMng.SwitchToUI(uiType); } } }catch (System.Exception e) { try { SubGUIType subUiType = (SubGUIType)Enum.Parse(Type.GetType("SubGUIType"), (string)x); GameCenter.uIMng.SwitchToSubUI(subUiType); }catch (System.Exception e2) { GameCenter.messageMng.AddClientMsg("配置错误"); } } }); }
/// <summary> /// 加载某个界面组合 by吴江 /// </summary> /// <param name="_type"></param> /// <param name="_needOpen">加载完以后是否需要打开</param> public void GenGUI(GUIType _type, bool _needOpen, SubGUIType _subType = SubGUIType.NONE, GUIType _baseOn = GUIType.NONE, System.Action <GUIBase> _callback = null) { List <string> needopenlist = GetUIByType(_type); foreach (var item in needopenlist) { if (uiDictionary.ContainsKey(item) && uiDictionary[item] != null) { if (_needOpen) { uiDictionary[item].OpenUI(); } if (_callback != null) { _callback(uiDictionary[item]); } } else { GenGUI(item, _needOpen, _subType, _baseOn, _callback); } } }
/// <summary> /// 返回是否显示红点提示 /// </summary> public void SetData(EquipmentInfo equipmentInfo, UIEventListener.VoidDelegate clickEvent, SubGUIType subGUIType = SubGUIType.NONE) { if (CurEquipmentInfo != null) //重复SetData,去掉前一个物品的委托 { CurEquipmentInfo.OnPropertyUpdate -= OnPropertyUpdate; } CurSubGUIType = subGUIType; CurEquipmentInfo = equipmentInfo; if (itemUI != null) { itemUI.FillInfo(new EquipmentInfo(equipmentInfo, EquipmentBelongTo.PREVIEW)); } UIEventListener.Get(gameObject).onClick = clickEvent; UIEventListener.Get(gameObject).parameter = equipmentInfo; if (CurEquipmentInfo != null) { CurEquipmentInfo.OnPropertyUpdate += OnPropertyUpdate; } if (toggleChoose != null) { toggleChoose.value = false; } ShowRedTip(); }
/// <summary> /// 跳转至某个功能的UI组 by吴江 /// </summary> /// <param name="_type"></param> public void SwitchToUI(GUIType _type, SubGUIType _subType, GUIType _baseOn = GUIType.NONE) { bool needTip = true; if (!CheckFunction(_type, _subType, out needTip)) { if (needTip) { GameCenter.messageMng.AddClientMsg(389); } return; } CurOpenType = _type; CurBaseOnType = _baseOn; List <string> baseList = null; if (_baseOn != GUIType.NONE) { baseList = GetUIByType(_baseOn); } List <string> needReleaseList = new List <string>(); foreach (var item in uiDictionary.Keys) { if (baseList != null && baseList.Contains(item)) { continue; //如果有依赖背景窗口的话,那么依赖背景窗口逃避互斥 by吴江 } if (uiDictionary[item].MutualExclusion) { needReleaseList.Add(item); } } List <string> needopenlist = GetUIByType(_type); for (int i = 0; i < needReleaseList.Count; i++) { string item = needReleaseList[i]; if (!needopenlist.Contains(item)) { GUIBase gui = uiDictionary[item]; gui.CloseUI(); uiDictionary[item] = null; uiDictionary.Remove(item); DestroyImmediate(gui.gameObject, true); DestroyImmediate(gui, true); } } for (int i = 0; i < needopenlist.Count; i++) { string item = needopenlist[i]; if (uiDictionary.ContainsKey(item) && uiDictionary[item] != null) { if (_subType != SubGUIType.NONE) { uiDictionary[item].InitSubGUIType = _subType; } if (uiDictionary[item].isActiveAndEnabled) { uiDictionary[item].CloseUI(); } uiDictionary[item].OpenUI(_baseOn); SetCompareTop(_type, _baseOn); if (uiDictionary[item].MutualExclusion) { CurOpenType = _type; CurMutualExclusionType = _type; } } else { GenGUI(item, true, _subType, _baseOn, (x) => { SetCompareTop(_type, _baseOn); if (x.MutualExclusion) { CurOpenType = _type; CurMutualExclusionType = _type; } }); } } isClosingWnd = true; }
/// <summary> /// 检查功能是否开启 /// </summary> protected bool CheckFunction(GUIType _guiType, SubGUIType _subType, out bool needTip) { needTip = true; if (_subType == SubGUIType.NONE) { switch (_guiType) { case GUIType.EQUIPMENTTRAINING: return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.STRENGTHENING)); case GUIType.GUILDMAIN: bool isOpen = GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.FAIRYAU); if (isOpen && string.IsNullOrEmpty(GameCenter.mainPlayerMng.MainPlayerInfo.GuildName)) { GameCenter.messageMng.AddClientMsg(235); needTip = false; return(false); } return(isOpen); } } else { switch (_subType) { case SubGUIType.STRENGTHING: //强化 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.STRENGTHENING)); case SubGUIType.EQUIPMENTUPGRADE: //升阶 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.DEGREE)); case SubGUIType.ORANGEREFINE: //橙炼 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.ORANGEREFINING)); case SubGUIType.EQUIPMENTWASH: //洗练 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.WASHSPRACTICE)); case SubGUIType.EQUIPMENTINLAY: //镶嵌 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.MOSAIC)); case SubGUIType.EQUIPMENTEXTEND: //继承 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.INHERITANCE)); case SubGUIType.DECOMPOSITION: //分解 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.DECOMPOSITION)); case SubGUIType.GROWUP://宠物成长 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.PETGROWUP)); case SubGUIType.LINGXIU://宠物灵修 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.PETTHEKING)); case SubGUIType.FUSE://宠物成长 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.PETFUSE)); case SubGUIType.PETSKILL://宠物成长 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.PETSKILL)); case SubGUIType.MOUNT://坐骑 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.MOUNT)); case SubGUIType.ILLUSION://幻化 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.UNREAL)); case SubGUIType.MAGICREFINE://法宝淬炼 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.MAGIC)); case SubGUIType.MAGICADDSOUL://法宝注灵 return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.MAGIC)); case SubGUIType.UNDERBOSS://地宫BOSS(讨伐令) return(GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.CHALLENGEBOSS)); case SubGUIType.EXPANDMEMBER: //仙盟成员扩充(聚义符) bool isOpen = GameCenter.mainPlayerMng.FunctionIsOpen(FunctionType.FAIRYAU); if (isOpen && string.IsNullOrEmpty(GameCenter.mainPlayerMng.MainPlayerInfo.GuildName)) { GameCenter.messageMng.AddClientMsg(235); needTip = false; return(false); } return(isOpen); } } return(true); }
/// <summary> /// 进入副本界面,选中副本 /// </summary> public void OpenCopyWndSelected(SubGUIType _type, OneCopySType _oneCopyType) { CurSelectOneCopyType = _oneCopyType; GameCenter.uIMng.SwitchToSubUI(_type); }