TianShuMiJuanManger = {} local this = TianShuMiJuanManger local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) --读表 function this.Initialize() this.fetterData = {} for k,v in ConfigPairs(ConfigManager.GetConfig(ConfigName.SpiritAnimalBook)) do local configData = this.CreatSingleConfigData(v) if not this.fetterData[v.Id] then this.fetterData[v.Id] = {} end this.fetterData[v.Id] = configData end Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, this.OnLevelChange) end function this.OnLevelChange() for k,v in pairs(this.fetterData) do if v.enabled == -2 then v.enabled = this.CheckOpenFetter(v.openLevel) and -1 or -2 end end this.CheckFetterStatus(1) this.CheckFetterStatus(2) this.CheckFetterStatus(3) this.CheckFetterStatus(4) this.CheckFetterStatus(5) end function this.CheckRedPointType(redType) if redType == RedPointType.Hero_Fetter then return this.CheckRedPoint(1) elseif redType == RedPointType.SoulPrint_Fetter then return this.CheckRedPoint(2) elseif redType == RedPointType.TianShuPokemon_Fetter then return this.CheckRedPoint(3) elseif redType == RedPointType.Equip_Fetter then return this.CheckRedPoint(4) elseif redType == RedPointType.Weapon_Fetter then return this.CheckRedPoint(5) end end function this.CreatSingleConfigData(configData) local data = {} data.id = configData.Id data.name = GetLanguageStrById(configData.Name) data.teamers = configData.Teamers data.activePara = configData.ActivePara data.activeParaTip = ""--Language[12277] for i = 1, #data.activePara do local config = propertyConfig[data.activePara[i][1]] local value= GetEquipPropertyFormatStr(config.Style,data.activePara[i][2]) data.activeParaTip = data.activeParaTip..GetLanguageStrById(config.Info).."+"..value .. " " if i%2==0 then data.activeParaTip = data.activeParaTip.."\n" end end data.activeParaTip = rtrim(data.activeParaTip) data.activeForce = configData.ActiveForce data.fetterType = configData.FetterType data.reward = configData.Reward data.openLevel = configData.OpenLevel data.enabled = this.CheckOpenFetter(data.openLevel) and -1 or -2 -- -2 未开启 -1 不可激活 0 可激活 1已激活 return data end --刷新已经激活的羁绊 function this.UpdateFetterId(ids) for i = 1, #ids do if this.fetterData[ids[i]] then this.fetterData[ids[i]].enabled = 1 end end this.CheckFetterStatus(1) this.CheckFetterStatus(2) this.CheckFetterStatus(3) this.CheckFetterStatus(4) this.CheckFetterStatus(5) end --检测条件变化,判断羁绊是否可激活 function this.CheckFetterStatus(fetterType) if fetterType == 1 then local curPokemonSidList = PlayerManager.heroHandBook this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) CheckRedPointStatus(RedPointType.Hero_Fetter) elseif fetterType == 2 then local curPokemonSidList = SoulPrintManager.GetAllHavedSoulPrint() this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) CheckRedPointStatus(RedPointType.SoulPrint_Fetter) elseif fetterType == 3 then local curPokemonSidList = PokemonManager.GetAllPokemonGetDatas() this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) CheckRedPointStatus(RedPointType.Pokemon_Fetter) CheckRedPointStatus(RedPointType.TianShuPokemon_Fetter) elseif fetterType == 4 then local curPokemonSidList = EquipManager.GetHaveEquipDatas() this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) CheckRedPointStatus(RedPointType.Equip_Fetter) elseif fetterType ==5 then local curPokemonSidList = GodWeaponManager.GetAllHandData() this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) CheckRedPointStatus(RedPointType.Weapon_Fetter) end end --刷新羁绊状态 function this.GetAllPokemonFetterDatas(fetterType,curPokemonSidList) local SpiritAnimalBookList = {} for k,v in pairs(this.fetterData) do --LogError("fetterType=="..fetterType.." v.fettertype=="..v.fetterType) if v.fetterType == fetterType and v.enabled == -1 then if this.IsCompound(v.teamers,curPokemonSidList,v.fetterType) then v.enabled = 0 end end end end function this.CheckRedPoint(fetterType) for k,v in pairs(this.fetterData) do if v.fetterType == fetterType and v.enabled == 0 then -- 神将篇判断神将是否加入版本,有一个不在版本内就不显示 if fetterType == 1 then local inVersion = true for _, t in ipairs(v.teamers) do if not HeroManager.InVersion(t[1]) then inVersion = false break end end -- if inVersion then return true end else return true end end end return false end function this.IsCompound(Teamers,curPokemonSidList,fetterType) local isCompound = true for k,v in ipairs(Teamers) do if curPokemonSidList[v[1]] == nil then if isCompound then isCompound = false break end elseif fetterType and fetterType == 4 and curPokemonSidList[v[1]] < v[2] then if isCompound then isCompound = false break end end end return isCompound end --根据type获取羁绊数据 function this.GetFetterDataByFetterType(fetterType) local data = {} --LogError("fetterType===="..fetterType) for k,v in pairs(this.fetterData) do if v.fetterType == fetterType and v.enabled ~= -2 then -- 神将篇判断神将是否加入版本,有一个不在版本内就不显示 if fetterType == 1 then local inVersion = true for _, t in ipairs(v.teamers) do if not HeroManager.InVersion(t[1]) then inVersion = false break end end -- if inVersion then table.insert(data,v) end else --LogError("+++++++++++++++++++++++") table.insert(data,v) end end end return data end function this.CheckOpenFetter(openLevel) if openLevel > PlayerManager.level then return false end return true end --获取所有羁绊总和属性 (羁绊属性直接加在团队属性上) function this.GetAllFetterAddProsBy(fetterType) local fetterData = this.GetFetterDataByFetterType(fetterType) local addAllProVal = {} for key, value in pairs(fetterData) do if value.enabled == 1 and #value.activePara > 0 then for i = 1, #value.activePara do local curPro = value.activePara[i] if curPro[2] > 0 then if addAllProVal[curPro[1]] then addAllProVal[curPro[1]]=addAllProVal[curPro[1]]+curPro[2] else addAllProVal[curPro[1]]=curPro[2] end end end end end return addAllProVal end ----获取所有羁绊总和静态战力 function this.GetAllPokemonFetterAddProsSWarPower(fetterType) local fetterData = this.GetFetterDataByFetterType(fetterType) local addPowerVal = 0 for key, value in pairs(fetterData) do if value.enabled == 1 and value.activeForce > 0 then addPowerVal = addPowerVal + value.ActiveForce end end return addPowerVal end function this.IsHaveItem(fetterType,id,num) local data = {} if fetterType == 1 then data = PlayerManager.heroHandBook elseif fetterType == 2 then data = SoulPrintManager.GetAllHavedSoulPrint() elseif fetterType == 3 then data = PokemonManager.GetAllPokemonGetDatas() elseif fetterType == 4 then data = EquipManager.GetHaveEquipDatas() elseif fetterType ==5 then data = GodWeaponManager.GetAllHandData() end if fetterType == 4 then if data[id] and data[id] >= num then return true else return false end elseif data[id] then return true end return false end return this