local GuildCultivation_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') function GuildCultivation_Controller.OnStartup() EventSystem.Regist(EventID.UI_GuildCultivateInfoRefresh, private.RefreshRedPoint) EventSystem.Regist(EventID.UI_GuildBuildingInfoRefresh, private.RefreshRedPoint) EventSystem.Regist(EventID.BagItem_Update, private.RefreshRedPoint) EventSystem.Regist(EventID.UI_RefreshCurrency, private.RefreshRedPoint) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.RefreshRedPoint) end function GuildCultivation_Controller.OpenGuildCultivation() MDL.GuildCultivation.GuildCultivateOpenReq() end --这个函数因为判断的时候需要根据情况改变字色,所以单独写了。 --与策划反复确认过,条件为这两个不会改变。 function GuildCultivation_Controller.IsSkillUnlock(triggerId, params) local des = DataSheetManager.TriggerType:GetDataByID(triggerId).TaskDesText if triggerId == LuaConst.UnlockConditionType.TeamLevel then local level = tonumber(params) if level == 0 then return false end local teamLevel = MDL.HeroSelect.GetTeamLevel() local teamLevelStr = UTL.Item.GetNobilityByTeamLevel(level) -- 爵位转换 local unlockText = string.FormatByIdsId(Const_IDS[des], teamLevel >= level and UTL.Color.FormatGreenColor(teamLevelStr) or UTL.Color.FormatRedColor(teamLevelStr)) return teamLevel >= level, unlockText elseif triggerId == LuaConst.UnlockConditionType.GuildBuildLevelByType then local data = string.split(params, ";") local id = tonumber(data[1]) local level = tonumber(data[2]) local levelRes = false local buildingName local info = MDL.Guild.GetGuildMemberInfo() for i, v in ipairs(info.buildingInfo) do if id == v.buildingId then buildingName = DataSheetManager.GuildBuildingBase:GetDataByID(v.buildingId).BuildingName if v.level >= level then levelRes = true end break end end local unlockText = string.FormatByIdsId(Const_IDS[des], UIUtils.GetLocalizedTxt(Const_IDS[buildingName]), levelRes and UTL.Color.FormatGreenColor(level) or UTL.Color.FormatRedColor(level)) return levelRes, unlockText else return MDL.Unlock.IsComplete(triggerId, params, des) end end function private.RefreshRedPoint() if GuildCultivation_Controller.IsGuildCultivationCanLevelUp() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_Cultivation) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_Cultivation) end end function GuildCultivation_Controller.IsGuildCultivationCanLevelUp() for i, v in ipairs(DataSheetUtil.GetSortedGuildCultivationData()) do local cultivateId = v.CultivationType local level = MDL.GuildCultivation.GetGuildCultivationInfoById(cultivateId) if GuildCultivation_Controller.IsSkillCanLevelUp(cultivateId, level + 1) then return true end end return false end function GuildCultivation_Controller.IsSkillCanLevelUp(cultivateId, level) return GuildCultivation_Controller.IsSkillLevelUpUnlock(cultivateId, level) and GuildCultivation_Controller.IsSkillLevelItemEnough(cultivateId, level) end function GuildCultivation_Controller.IsSkillLevelUpUnlock(cultivateId, level) local __, cultivationLevelData = DataSheetManager.CultivationLevel:TryGetDataByCultivationType_Level(cultivateId, level) if cultivationLevelData then for i, v in ipairs(cultivationLevelData.LevelUpTrigger_Table) do if v.LevelUpTriggerID and v.LevelUpTriggerID > 0 then local isUnlock = MDL.Unlock.IsComplete(v.LevelUpTriggerID, v.LevelUpTriggerParams, "") if not isUnlock then return false end end end return true else return false end end function GuildCultivation_Controller.IsSkillLevelItemEnough(cultivateId, level) local cultivationLevelData = DataSheetManager.CultivationLevel:GetDataByCultivationType_Level(cultivateId, level) if cultivationLevelData then for i, v in ipairs(cultivationLevelData.LevelUpItem_Table) do local itemId = v.ItemID local count if itemId and itemId > 0 then count = MDL.Currency.IsMoneyTypeByItemID(itemId) and MDL.Currency.GetMoneyCount(itemId) or MDL.Bag.GetItemCount(itemId) if count < v.ItemNum then return false end end end return true else return false end end return GuildCultivation_Controller