/// <summary> /// 初始化新功能开启数据 /// </summary> public void InitFunctionData() { //functionList.Clear(); //Debug.Log("InitFunctionData()"); FDictionary dic = ConfigMng.Instance.OpenNewFunctionRefTable(); FunctionDataInfo funcInfo = null; foreach (OpenNewFunctionRef data in dic.Values) { if (data.prof > 0 && data.prof != mainPlayerInfo.Prof) { continue; } if (data.func_type > 0) { if (!functionList.ContainsKey(data.func_type)) { funcInfo = new FunctionDataInfo(data); functionList[data.func_type] = funcInfo; } else { funcInfo = functionList[data.func_type] as FunctionDataInfo; funcInfo.Update(); } //Debug.Log("funcInfo.Type:" + funcInfo.Type); } } }
/// <summary> /// 设置功能相关红点显示 /// </summary> public void SetFunctionRed(FunctionType _func, bool isRed) { FunctionDataInfo funcInfo = null; if (functionList.ContainsKey((int)_func)) { funcInfo = functionList[(int)_func] as FunctionDataInfo; if (funcInfo != null && isRed != funcInfo.FuncBtnRed) { funcInfo.FuncBtnRed = isRed; } } else { OpenNewFunctionRef refData = ConfigMng.Instance.GetOpenNewFunctionRef((int)_func, mainPlayerInfo.Prof); if (refData == null) { funcInfo = new FunctionDataInfo(_func); funcInfo.FuncBtnRed = isRed; functionList[(int)_func] = funcInfo; } else { funcInfo = new FunctionDataInfo(refData); funcInfo.FuncBtnRed = isRed; functionList[refData.func_type] = funcInfo; } } }
/// <summary> /// 功能开启关闭任务引导特效 /// </summary> protected void CloseTaskGuideByFunction(FunctionDataInfo _data) { //Debug.Log("功能开启关闭任务引导特效"); for (int i = 0, max = taskList.Count; i < max; i++) { if (taskList[i] != null) taskList[i].ShowFx(false); } }
/// <summary> /// 获取某个功能是否显示红点 /// </summary> public bool GetFunctionIsRed(FunctionType _func) { if (functionList.ContainsKey((int)_func)) { FunctionDataInfo data = functionList[(int)_func] as FunctionDataInfo; return(data != null ? data.FuncBtnRed : false); } return(false); }
/// <summary> /// 刷新功能数据 /// </summary> /// <param name="_funcInfo"></param> void UpdateFunctionData(FunctionDataInfo _funcInfo) { nextFunc = FunctionType.None; if (_funcInfo.VipLev > GameCenter.vipMng.VipData.vLev) { return; } funcInfo = _funcInfo; if (_funcInfo.SceneID > 0 && _funcInfo.FunSubGUIType == SubGUIType.NONE && _funcInfo.FunGUIType == GUIType.NONE) { CloseAll(); GameCenter.noviceGuideMng.newFunctionCopyId = _funcInfo.SceneID; GameCenter.uIMng.SwitchToUI(GUIType.NEWFUNCTIONTIPUI); return; } if (_funcInfo.FunSubGUIType == SubGUIType.FUNCTIONOPEN) { if (mainFunc != null && !mainFunc.gameObject.activeSelf) { CloseAll(); mainFunc.FuncInfo = _funcInfo; nextFunc = _funcInfo.NextFunc; mainFunc.OpenUI(); } return; } if (_funcInfo.FunSubGUIType == SubGUIType.GUIDEOPEN) { if (_funcInfo.GuideData == null) { return; } GameCenter.noviceGuideMng.OpenGuide(_funcInfo.GuideData); return; } if (_funcInfo.FunGUIType != GUIType.NONE) { CloseAll(); GameCenter.uIMng.SwitchToUI(_funcInfo.FunGUIType); } else if (_funcInfo.FunSubGUIType != SubGUIType.NONE) { CloseAll(); GameCenter.uIMng.SwitchToSubUI(_funcInfo.FunSubGUIType); } if (_funcInfo.FunGUIType == GUIType.NONE && _funcInfo.FunSubGUIType == SubGUIType.NONE && _funcInfo.GuideData != null) { GameCenter.noviceGuideMng.OpenGuide(_funcInfo.GuideData); nextFunc = _funcInfo.NextFunc; } }
/// <summary> /// 引导结束的时候抛出事件更新功能 /// </summary> void OnGuideOver() { //Debug.Log("结束引导"); if (nextFunc != FunctionType.None) { FunctionDataInfo _funcInfo = GameCenter.mainPlayerMng.GetFunctionData(nextFunc); if (_funcInfo != null)// && _funcInfo.IsOpon) { _funcInfo.Update(true); GameCenter.noviceGuideMng.UpdateFunctionData(_funcInfo); //Debug.Log("更新功能"); } } }
void OpenFunction(TaskInfo task, bool taskNew) { if (task.FuncSequence.Count == 0 || task.TaskState == TaskStateType.ENDED || task.TaskState == TaskStateType.UnTake) { return; } for (int i = 0; i < task.FuncSequence.Count; i++) { OpenNewFunctionRef refData = ConfigMng.Instance.GetOpenNewFunctionRef(task.FuncSequence[i]); if (refData == null) { Debug.Log("任务task=" + task.Task + "step=" + task.Step + "的开启功能id。在功能表中没有找到数据"); continue; } if (refData.open_conditions == 2 && taskNew) { continue; } if (refData.open_conditions == 1 && !taskNew) { continue; } guildTask = task; FunctionDataInfo funcInfo = null; if (refData.func_type <= 0) {//没有与功能相关的引导或者其他处理 funcInfo = new FunctionDataInfo(refData); } else { if (functionList.ContainsKey(refData.func_type)) { funcInfo = functionList[refData.func_type] as FunctionDataInfo; } } if (funcInfo != null) { funcInfo.Update(true); if (GameCenter.noviceGuideMng.UpdateFunctionData != null) { GameCenter.noviceGuideMng.UpdateFunctionData(funcInfo);//开启多个功能时,只支持第一个功能有开启表现 } if (funcInfo.Seqencing != functionSequence) { functionSequence = funcInfo.Seqencing; GameCenter.noviceGuideMng.C2S_GuideSeqencing(funcInfo.Seqencing); } } } }
/// <summary> /// 获取功能开启状态 /// </summary> public bool FunctionIsOpen(FunctionType _func) { if (functionList.ContainsKey((int)_func)) { FunctionDataInfo funcInfo = functionList[(int)_func] as FunctionDataInfo; if (funcInfo != null) { return(funcInfo.IsOpon); } } else { Debug.LogError("功能Type =" + (int)_func + " 没有数据"); } return(true); }
/// <summary> /// 设置后台活动开启 by黄洪兴 /// </summary> /// <param name="_type"></param> /// <param name="_isOpen"></param> public void SetServerActiveOpen(FunctionType _type, bool _isOpen) { FunctionDataInfo funcInfo = null; if (functionList.ContainsKey((int)_type)) { funcInfo = functionList[(int)_type] as FunctionDataInfo; funcInfo.Update(_isOpen); } else { funcInfo = new FunctionDataInfo(_type, _isOpen, FunctionDataInfo.FunctionControlType.PROGRAMCONTROL); functionList[(int)_type] = funcInfo; } if (UpdateServerOpen != null && funcInfo != null) { UpdateServerOpen(funcInfo, _isOpen); //Debug.Log("后台活动开启更新"); } }
void Awake() { //Debug.Log("名字为------:"+this.gameObject.name+"的物体上挂有--------:"+ funcs.Length+"个FunctionButtonUI[]"); if (GameCenter.instance == null) { return; } bool funcLock = GameCenter.instance.NewFunctionLock; /// <summary> /// 如果功能按钮的模块组为空(该脚本所依附的物体上)通过GetComponentsInChildren返回子物体上所有的FunctionButtonUI组件数组 /// 一般情况不会出现 /// </summary> if (funcs == null || funcs.Length <= 0) { //Debug.Log("名字为------:"+this.gameObject.name+"的物体上添加了该脚本但是FunctionButtonUI[]数组为空"); funcs = gameObject.GetComponentsInChildren <FunctionButtonUI>(); } /// <summary> /// 遍历数组判定其父物体显示红点 /// </summary> for (int i = 0; i < funcs.Length; i++) { if (funcs[i] != null && funcs[i].func != FunctionType.None) { //Debug.Log("名字为"+ funcs[i].gameObject.name+ "的物体的group为"+ funcs[i].group); if (funcs[i].parent != null && funcs[i].group > 0) { funcs[i].parent.SetActive(!funcLock); } } } FunctionDataInfo info = null; UIGrid grid = null; //遍历FunctionButtonUI类型的数组由类型去获取功能开启数据 for (int i = 0; i < funcs.Length; i++) { if (funcs[i] != null && funcs[i].func != FunctionType.None) { //Debug.Log("FunctionType = " + funcs[i].func + " int " + (int)funcs[i].func); info = GameCenter.mainPlayerMng.GetFunctionData(funcs[i].func); if (info == null) { funcs[i].gameObject.SetActive(true); if (funcs[i].parent != null) { funcs[i].parent.SetActive(true); grid = funcs[i].parent.GetComponent <UIGrid>(); } if (funcs[i].funcRed != null) { funcs[i].funcRed.SetActive(false); } if (funcs[i].parentRed != null) { funcs[i].parentRed.SetActive(false); } } else { funcs[i].TipDes = info.TipDes; //按钮显示 if (funcLock) { funcs[i].SetShow = info.IsOpon; if (funcs[i].parent != null) { if (!funcs[i].parent.activeSelf && info.IsOpon) { funcs[i].parent.SetActive(true); } grid = funcs[i].parent.GetComponent <UIGrid>(); } } else { funcs[i].SetShow = true; if (funcs[i].parent != null) { funcs[i].parent.SetActive(true); grid = funcs[i].parent.GetComponent <UIGrid>(); } } //红点 if (funcs[i].funcRed != null) { funcs[i].funcRed.SetActive(info.FuncBtnRed); } if (funcs[i].group > 0) { if (!buttonChilds.ContainsKey(funcs[i].group)) { buttonChilds[funcs[i].group] = new ButtonChilds(funcs[i].group); } //如果子物体上有红点显示则以子物体上的FunctionButtonUI组件上的group字段为key 存储子物体上的功能类型 //用字典去存放功能列表 然后用功能列表的长度来判断父红点的显示 if (info.FuncBtnRed) { buttonChilds[funcs[i].group].AddChild(funcs[i].func); } if (funcs[i].parentRed != null) { funcs[i].parentRed.SetActive(buttonChilds[funcs[i].group].childs.Count > 0); } else { Debug.LogError("预制" + funcs[i].name + "的父红点引用为空!"); } } } if (grid != null) { grid.repositionNow = true; } } } int totalRedNum = 0; UIGrid parentGrid = null; for (int i = 0; i < parentFuncs.Length; i++) { if (parentFuncs[i] == null) { continue; } parentGrid = parentFuncs[i].transform.parent.GetComponent <UIGrid>(); int childNum = parentFuncs[i].childFuncs.Count; //设置初始状态(隐藏和RedNum置为0隐藏自身红点) parentFuncs[i].gameObject.SetActive(childNum == 0 ? true : false); parentFuncs[i].RedNum = 0; //在物体绑定的功能列表不为空的情况下判断自身红点的显隐以及统计红点计数 if (childNum > 0) { for (int j = 0; j < childNum; j++) { //由功能类型获取功能数据 info = GameCenter.mainPlayerMng.GetFunctionData(parentFuncs[i].childFuncs[j]); if (info == null) { parentFuncs[i].gameObject.SetActive(true); } else { if (info.IsOpon) { parentFuncs[i].gameObject.SetActive(true); } if (info.FuncBtnRed) { parentFuncs[i].RedNum++; } } //统计每个物体上的功能红点计数 if (additionalTotalRedPoint != FunctionType.None) { totalRedNum += parentFuncs[i].RedNum; } } } //在人物红点功能类型不为None的情况下用功能红点统计来判定人物红点功能是否显示 if (additionalTotalRedPoint != FunctionType.None) { AdditionalTotalRed = totalRedNum > 0; } if (!funcLock) { parentFuncs[i].gameObject.SetActive(true); } if (parentGrid != null) { parentGrid.repositionNow = true; } } }
void UpdateFunctionRed(FunctionDataInfo _info) { //更新红点 for (int i = 0; i < funcs.Length; i++) { //三层if嵌套 最外层判定功能数据开启的类型 if (funcs[i] != null && funcs[i].func == _info.Type && _info.IsOpon) { //次外层以group为条件判断字典中是否包含funcs[i].group的key if (funcs[i].group > 0 && buttonChilds.ContainsKey(funcs[i].group)) { //内层 如果子物体上有红点显示则以子物体上的FunctionButtonUI组件上的group字段为key 存储子物体上的功能类型 否则删除该子物体上的功能类型 if (_info.FuncBtnRed) { buttonChilds[funcs[i].group].AddChild(funcs[i].func); } else { buttonChilds[funcs[i].group].RemoveChild(funcs[i].func); } //子物体所绑定的父物体红点的显示判断 if (funcs[i].parentRed != null) { funcs[i].parentRed.SetActive(buttonChilds[funcs[i].group].childs.Count > 0); } } if (funcs[i].funcRed != null) { funcs[i].funcRed.SetActive(_info.FuncBtnRed); } break; } } //更新红点时对于主界面下方UI的逻辑处理 //循环遍历FunctionChildsButtonUI[]统计红点计数 int totalRedNum = 0; for (int i = 0; i < parentFuncs.Length; i++) { if (parentFuncs[i] == null) { continue; } if (parentFuncs[i].childFuncs.Contains(_info.Type)) { if (_info.FuncBtnRed) { parentFuncs[i].RedNum++; } else { if (parentFuncs[i].RedNum > 0) { parentFuncs[i].RedNum--; } } } if (additionalTotalRedPoint != FunctionType.None) { totalRedNum += parentFuncs[i].RedNum; } } AdditionalTotalRed = totalRedNum > 0; }
void UpdateFunctionData(FunctionDataInfo _info) { //Debug.Log("更新功能"+ _info.Type); if (_info.Type == FunctionType.None) { return; } UIGrid parentGrid = null; UIGrid funcsGrid = null; //功能开启的时候循环遍历FunctionButtonUI[] 如果功能数据的类型与功能模块的类型相等并且功能已经开启则显示此FunctionButtonUI上绑定的parent; for (int i = 0; i < funcs.Length; i++) { if (funcs[i] != null && funcs[i].func == _info.Type && _info.IsOpon) { if (funcs[i].parent != null && !funcs[i].parent.activeSelf) { funcs[i].parent.SetActive(true); //获取此FunctionButtonUI的父物体上的UIGrid组件重新排列一下位置 if (funcsGrid == null) { funcsGrid = funcs[i].parent.transform.parent.GetComponent <UIGrid>(); } if (funcsGrid != null) { funcsGrid.repositionNow = true; } } //设置绑定FunctionButtonUI组件的物体的显隐以及红点的显示 funcs[i].SetShow = _info.IsOpon; if (funcs[i].funcRed != null) { funcs[i].funcRed.SetActive(_info.FuncBtnRed); } //设置FunctionButtonUI上父物体的红点获取父物体上的UiGrid组件重新排列位置 if (funcs[i].parentRed != null && _info.FuncBtnRed) { funcs[i].parentRed.SetActive(true); } if (funcsGrid == null) { funcsGrid = funcs[i].transform.parent.GetComponent <UIGrid>(); } if (funcsGrid != null) { funcsGrid.repositionNow = true; } break; } } //更新功能时对于主界面下方UI的逻辑处理 //循环遍历FunctionChildsButtonUI[]统计红点计数判定红点的显示 UIGrid重新排列 for (int i = 0; i < parentFuncs.Length; i++) { if (parentFuncs[i] != null && parentFuncs[i].childFuncs.Contains(_info.Type) && _info.IsOpon) { parentFuncs[i].gameObject.SetActive(true); if (_info.FuncBtnRed) { parentFuncs[i].RedNum++; } if (parentGrid == null) { parentGrid = parentFuncs[i].transform.parent.GetComponent <UIGrid>(); } if (parentGrid != null) { parentGrid.repositionNow = true; } break; } } }
void UpdateServerOpen(FunctionDataInfo _info, bool _b) { //后台活动开启时候红点显示以及功能图标排列 UIGrid parentGrid = null; UIGrid funcsGrid = null; //循环遍历FunctionButtonUI[] 如果功能数据的类型与功能模块的类型相等显示此FunctionButtonUI上绑定的parent; for (int i = 0; i < funcs.Length; i++) { if (funcs[i] != null && funcs[i].func == _info.Type) { if (funcs[i].parent != null && !funcs[i].parent.activeSelf) { funcs[i].parent.SetActive(true); //获取父物体上的UIGrid 重新排列 if (funcsGrid == null) { funcsGrid = funcs[i].parent.transform.parent.GetComponent <UIGrid>(); } if (funcsGrid != null) { funcsGrid.repositionNow = true; } } //红点的显示 funcs[i].SetShow = _b; if (funcs[i].funcRed != null) { funcs[i].funcRed.SetActive(_info.FuncBtnRed); } if (funcs[i].parentRed != null && _b) { funcs[i].parentRed.SetActive(true); } if (funcsGrid == null) { funcsGrid = funcs[i].transform.parent.GetComponent <UIGrid>(); } if (funcsGrid != null) { funcsGrid.repositionNow = true; } break; } } //对主界面下方UI的逻辑处理 //循环遍历FunctionChildsButtonUI[] 统计红点计数判定红点的显示 UIGrid重新排列 for (int i = 0; i < parentFuncs.Length; i++) { if (parentFuncs[i] != null && parentFuncs[i].childFuncs.Contains(_info.Type)) { parentFuncs[i].gameObject.SetActive(_b); if (_b) { parentFuncs[i].RedNum++; } if (parentGrid == null) { parentGrid = parentFuncs[i].transform.parent.GetComponent <UIGrid>(); } if (parentGrid != null) { parentGrid.repositionNow = true; } break; } } }