local HonorSignet_Controller = {} local private = {} local EventSystem = require("Event/EventSystem") function HonorSignet_Controller.OnStartup() EventSystem.Regist(EventID.UI_HonorSignet_InfoRefresh, private.RefreshRedPoint) EventSystem.Regist(EventID.UI_Achievement_RefreshRedPoint, private.RefreshRedPoint) end function private.RefreshRedPoint() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HonorSignet) and HonorSignet_Controller.IsSignetCanUnlock() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.TownHead_HonorSignet) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.TownHead_HonorSignet) end end function HonorSignet_Controller.IsSignetCanUnlock() for i, v in DataSheetManager.AchievementHonorSignet:GetEnumerator() do local id = v.ID if not HonorSignet_Controller.IsActive(id) and HonorSignet_Controller.IsCanUnlock(id) then return true end end return false end ---@param list 如果传入则使用传入的值,否则使用自己装备的印记数组 function HonorSignet_Controller.OpenEquipSignetDetail(index, list, timeList) if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HonorSignet) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Formation_RelationShip_Closed) return end if list and timeList then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHonorSignetDetailsTips, {index = index, list = list, timeList = timeList}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIHonorSignetDetailsTips, {index = index, list = MDL.HonorSignet.MDL.HonorSignet.GetEquipList()}) end end function HonorSignet_Controller.CalculateAllAttr(id_Table, isDict) local attrDict = {} --传入的可能是list也可能是dict,但是不影响计算 if not id_Table then return else if (isDict and table.getDictCount(id_Table) or #id_Table) == 0 then return end end for key, value in pairs(id_Table) do local id = isDict and key or value if type(id) == "number" then local data = DataSheetManager.AchievementHonorSignet:GetDataByID(id) for i, v in ipairs(data.Attr_Table) do attrDict[v.AttrType] = (attrDict[v.AttrType] or 0) + v.AttrNum end end end local attrList = {} for i, v in pairs(attrDict) do table.insert(attrList, {AttrType = i, AttrNum = v}) end table.sort(attrList, private.SortAttrList) return attrList end function HonorSignet_Controller.IsEquip(id) for i, v in ipairs(MDL.HonorSignet.GetEquipList()) do if v == id then return true end end return false end function HonorSignet_Controller.IsActive(id) return MDL.HonorSignet.GetActiveInfo(id) ~= nil end function HonorSignet_Controller.IsCanUnlock(id) local data = DataSheetManager.AchievementHonorSignet:GetDataByID(id) for i, v in ipairs(data.PreAchievement_Table) do if not CTL.Achievement.IsAchievementCompleted(v.PreAchievementID) then return false end end return true end function private.SortAttrList(attrA, attrB) return attrA.AttrType < attrB.AttrType end return HonorSignet_Controller