Branch_oumei
zhangjiannan 2025-11-19 17:03:47 +08:00
parent d6335b051c
commit d021535e9a
2 changed files with 209 additions and 205 deletions

View File

@ -1,130 +1,146 @@
--新的命格管理
GiftManager = {}
local this = GiftManager
local giftConfig=ConfigManager.GetConfig(ConfigName.GiftConfig)
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
local giftConfig = ConfigManager.GetConfig(ConfigName.GiftConfig)
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
function this.Initialize()
this.allHeroGifts={}
this.playerGifts={}
this.allHeroGifts = {}
this.playerGifts = {}
end
--初始化命石
function this.InitGemsInfo(msg)
end
--初始化英雄礼物
function this.InitHeroGift(id,list)
this.allHeroGifts[id]=list
function this.InitHeroGift(id, list)
this.allHeroGifts[id] = list
end
--初始化主角礼物
function this.InitPlayerGift(list)
this.playerGifts=list
function this.InitPlayerGift(list)
this.playerGifts = list
end
--获取收取等级和最大数量
function this.GetCollectLvAndNum()
local lv=0
local maxNum=0
local collect=0
local curNum=0
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
local lv = 0
local maxNum = 0
local collect = 0
local curNum = 0
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] then
collect=collect+equipConfig[id].Gift
collect = collect + equipConfig[id].Gift
end
end
for k, v in ConfigPairs(giftConfig) do
if collect>=v.Gift then
lv=v.Id
curNum=v.Box
if collect >= v.Gift then
lv = v.Id
curNum = v.Box
else
maxNum=v.Box
maxNum = v.Box
break
end
end
if maxNum==0 then
maxNum=curNum
if maxNum == 0 then
maxNum = curNum
end
return lv,curNum,maxNum
return lv, curNum, maxNum
end
--设置英雄礼物 type 1穿 2
function this.SetHeroGift(id,list,type)
if this.allHeroGifts[id]==nil then
this.allHeroGifts[id]={}
end
for i=1,#list do
if type==1 then
table.insert(this.allHeroGifts[id],list[i])
elseif type==2 then
table.removebyvalue(this.allHeroGifts[id],list[i])
--获取收取等级和最大数量
function this.GetHeroGiftBoxNum(dynamicId)
local list = GiftManager.GetHeroGifts(dynamicId)
local maxNum = #list
for k, v in ConfigPairs(giftConfig) do
if v.Harmony <= PowerCenterManager.allData.level and v.Box > maxNum then
maxNum = v.Box
end
end
HeroManager.ChangeHeroGift(id,this.allHeroGifts[id])
return maxNum
end
--设置英雄礼物 type 1穿 2
function this.SetHeroGift(id, list, type)
if this.allHeroGifts[id] == nil then
this.allHeroGifts[id] = {}
end
for i = 1, #list do
if type == 1 then
table.insert(this.allHeroGifts[id], list[i])
elseif type == 2 then
table.removebyvalue(this.allHeroGifts[id], list[i])
end
end
HeroManager.ChangeHeroGift(id, this.allHeroGifts[id])
end
--设置主角礼物
function this.SetPlayerGift(list)
for i=1,#list do
table.insert(this.playerGifts,list[i])
for i = 1, #list do
table.insert(this.playerGifts, list[i])
end
end
--移除主角礼物
function this.RemovePlayerGift(list)
for i=1,#list do
table.removebyvalue(this.playerGifts,list[i])
for i = 1, #list do
table.removebyvalue(this.playerGifts, list[i])
end
end
function this.GetHeroGifts(_id)
if this.allHeroGifts[_id] then
return this.allHeroGifts[_id]
end
return {}
end
function this.GetPlayerGifts()
return this.playerGifts
end
function this.changeGiftsByType(_type,_list)
function this.changeGiftsByType(_type, _list)
end
--获取英雄礼物增加的属性
function this.GetHeroGiftAddPro(_id)
local data={}
local data = {}
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
local addPro=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp>0 then
addPro=addPro + equipConfig[id].HeroGitUp
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
end
end
end
--HeroGitUp
local list=this.allHeroGifts[_id]
for i=1,#list do
local id=list[i]
local list = this.allHeroGifts[_id]
for i = 1, #list do
local id = list[i]
local pro = equipConfig[id].Property
if pro and #pro>0 then
if pro and #pro > 0 then
for k = 1, #pro do
local key=pro[k][1]
local value=pro[k][2]
if tonumber(key)~=0 and tonumber(key)~=nil then
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= 0 and tonumber(key) ~= nil then
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
data[key] = data[key] + value
end
end
end
--英雄礼物不会加成主角属性
-- local pro2 = equipConfig[id].PlayerProperty
-- if pro2 and #pro2>0 then
@ -141,39 +157,39 @@ end
--获取英雄礼物增加的白板属性属性(表里配置的属性)
function this.GetHeroGiftAddOriginalPro(_id)
local data={}
local data = {}
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
local addPro=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp>0 then
addPro=addPro + equipConfig[id].HeroGitUp
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
end
end
end
--HeroGitUp
local list=this.allHeroGifts[_id]
for i=1,#list do
local id=list[i]
local list = this.allHeroGifts[_id]
for i = 1, #list do
local id = list[i]
local pro = equipConfig[id].Property
if pro and #pro>0 then
if pro and #pro > 0 then
for k = 1, #pro do
local key=pro[k][1]
local value=pro[k][2]
if tonumber(key)~=0 and tonumber(key)~=nil then
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= 0 and tonumber(key) ~= nil then
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
data[key] = data[key] + value
end
end
end
--英雄礼物不会加成主角属性
-- local pro2 = equipConfig[id].PlayerProperty
-- if pro2 and #pro2>0 then
@ -185,54 +201,53 @@ function this.GetHeroGiftAddOriginalPro(_id)
-- end
-- end
end
return data
end
--检测英雄礼物合成红点
function this.CheckHeroGiftComRed()
local giftList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",8)
local giftList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig, "Position", 8)
if giftList then
for i=1,#giftList do
local curequipSign=giftList[i]
if curequipSign.Formula and #curequipSign.Formula>0 and type(curequipSign.Formula[1][1])~="userdata" then
local key=curequipSign.Formula[1][1]
local value=curequipSign.Formula[1][2]
local isMatEnough=false
for i = 1, #giftList do
local curequipSign = giftList[i]
if curequipSign.Formula and #curequipSign.Formula > 0 and type(curequipSign.Formula[1][1]) ~= "userdata" then
local key = curequipSign.Formula[1][1]
local value = curequipSign.Formula[1][2]
local isMatEnough = false
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
local curBagSoulPrintDatas = {}
local maxNum=0
local maxNum = 0
for i = 1, #datas do
if curequipSign.Star>0 then
if curequipSign.Star > 0 then
if datas[i].id == key then
for j=1,datas[i].num do
if maxNum==value then
for j = 1, datas[i].num do
if maxNum == value then
break
end
maxNum=maxNum+1
maxNum = maxNum + 1
end
end
else
if equipConfig[datas[i].id].Quality == key then
for j=1,datas[i].num do
if maxNum==value then
for j = 1, datas[i].num do
if maxNum == value then
break
end
maxNum=maxNum+1
maxNum = maxNum + 1
end
end
end
end
if maxNum>=value then
isMatEnough=true
if maxNum >= value then
isMatEnough = true
end
local resource=curequipSign.Resource
local isGoldEough=true
if resource and #resource>0 and type(resource[1][1])~="userdata" then
for i=1,#resource do
if BagManager.GetItemCountById(resource[i][1]) <resource[i][2] then
isGoldEough=false
local resource = curequipSign.Resource
local isGoldEough = true
if resource and #resource > 0 and type(resource[1][1]) ~= "userdata" then
for i = 1, #resource do
if BagManager.GetItemCountById(resource[i][1]) < resource[i][2] then
isGoldEough = false
end
end
end
@ -243,53 +258,51 @@ function this.CheckHeroGiftComRed()
end
end
return false
end
--检测主角礼物合成红点
function this.CheckPlayerGiftComRed()
local giftList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",7)
local giftList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipConfig, "Position", 7)
if giftList then
for i=1,#giftList do
local curequipSign=giftList[i]
if curequipSign.Formula and #curequipSign.Formula>0 and type(curequipSign.Formula[1][1])~="userdata" then
local key=curequipSign.Formula[1][1]
local value=curequipSign.Formula[1][2]
local isMatEnough=false
for i = 1, #giftList do
local curequipSign = giftList[i]
if curequipSign.Formula and #curequipSign.Formula > 0 and type(curequipSign.Formula[1][1]) ~= "userdata" then
local key = curequipSign.Formula[1][1]
local value = curequipSign.Formula[1][2]
local isMatEnough = false
local datas = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
local curBagSoulPrintDatas = {}
local maxNum=0
local maxNum = 0
for i = 1, #datas do
if curequipSign.Star>0 then
if curequipSign.Star > 0 then
if datas[i].id == key then
for j=1,datas[i].num do
if maxNum==value then
for j = 1, datas[i].num do
if maxNum == value then
break
end
maxNum=maxNum+1
maxNum = maxNum + 1
end
end
else
if equipConfig[datas[i].id].Quality == key then
for j=1,datas[i].num do
if maxNum==value then
for j = 1, datas[i].num do
if maxNum == value then
break
end
maxNum=maxNum+1
maxNum = maxNum + 1
end
end
end
end
if maxNum>=value then
isMatEnough=true
if maxNum >= value then
isMatEnough = true
end
local resource=curequipSign.Resource
local isGoldEough=true
if resource and #resource>0 and type(resource[1][1])~="userdata" then
for i=1,#resource do
if BagManager.GetItemCountById(resource[i][1]) <resource[i][2] then
isGoldEough=false
local resource = curequipSign.Resource
local isGoldEough = true
if resource and #resource > 0 and type(resource[1][1]) ~= "userdata" then
for i = 1, #resource do
if BagManager.GetItemCountById(resource[i][1]) < resource[i][2] then
isGoldEough = false
end
end
end
@ -300,23 +313,23 @@ function this.CheckPlayerGiftComRed()
end
end
return false
end
--检测英雄红点
function this.CheckRoleRedPointById(_id)
local lv,cur,max=this.GetCollectLvAndNum()
local lv, cur, max = this.GetCollectLvAndNum()
if this.allHeroGifts[_id] then
local list=this.allHeroGifts[_id]
if #list>=cur then
local list = this.allHeroGifts[_id]
if #list >= cur then
return false
end
local suitIds={}
for i=1,#list do
table.insert(suitIds,equipConfig[list[i]].SuiteID)
local suitIds = {}
for i = 1, #list do
table.insert(suitIds, equipConfig[list[i]].SuiteID)
end
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
for i=1,#allEquip do
if CheckListIsContainValue1(list,allEquip[i].id)==false and CheckListIsContainValue1(suitIds,equipConfig[allEquip[i].id].SuiteID)==false then
for i = 1, #allEquip do
if CheckListIsContainValue1(list, allEquip[i].id) == false and CheckListIsContainValue1(suitIds, equipConfig[allEquip[i].id].SuiteID) == false then
return true
end
end
@ -325,6 +338,7 @@ function this.CheckRoleRedPointById(_id)
end
return false
end
--获取单个英雄装备数据
function this.GetSingleHeroSingleEquipData(_equipid, _heroDid)
--LogError("获取英雄礼物信息:"..tostring(_equipid).."/".._heroDid)
@ -333,55 +347,55 @@ end
--检测主角红点
function this.CheckPlayerRedPoint()
local isOpen=ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.Gift)
if isOpen==false then
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.Gift)
if isOpen == false then
return false
end
local suitIds={}
for i=1,#this.playerGifts do
table.insert(suitIds,equipConfig[this.playerGifts[i]].SuiteID)
local suitIds = {}
for i = 1, #this.playerGifts do
table.insert(suitIds, equipConfig[this.playerGifts[i]].SuiteID)
end
local allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.PlayerGift)
for i=1,#allEquip do
if CheckListIsContainValue1(this.playerGifts,allEquip[i].id)==false and CheckListIsContainValue1(suitIds,equipConfig[allEquip[i].id].SuiteID)==false then
for i = 1, #allEquip do
if CheckListIsContainValue1(this.playerGifts, allEquip[i].id) == false and CheckListIsContainValue1(suitIds, equipConfig[allEquip[i].id].SuiteID) == false then
return true
end
end
return false
end
--获取英雄潜能等级
function this.GetHeroPotencyLvById(did)
local lv=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
lv=lv+equipConfig[id].PotentialNew[2]
local lv = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
end
end
end
if this.allHeroGifts and this.allHeroGifts[did] then
local list=this.allHeroGifts[did]
for i=1,#list do
local id=list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
lv=lv+equipConfig[id].PotentialNew[2]
local list = this.allHeroGifts[did]
for i = 1, #list do
local id = list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
end
end
end
--LogError("礼物增加 潜能 lv====================================="..lv)
return lv
end
--获取主角礼物添加的潜能等级
function this.GetPlayerGiftAddPotencyLv()
local lv=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
lv=lv+equipConfig[id].PotentialNew[2]
local lv = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
end
end
end
@ -390,32 +404,31 @@ end
--获取英雄礼物添加的潜能等级
function this.GetHeroGiftAddPotencyLv(did)
local lv=0
local lv = 0
if this.allHeroGifts and this.allHeroGifts[did] then
local list=this.allHeroGifts[did]
for i=1,#list do
local id=list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew>0 and type(equipConfig[id].PotentialNew[1])~="userdata" then
lv=lv+equipConfig[id].PotentialNew[2]
local list = this.allHeroGifts[did]
for i = 1, #list do
local id = list[i]
if equipConfig[id] and equipConfig[id].PotentialNew and #equipConfig[id].PotentialNew > 0 and type(equipConfig[id].PotentialNew[1]) ~= "userdata" then
lv = lv + equipConfig[id].PotentialNew[2]
end
end
end
return lv
end
--获取主角礼物增加的属性
function this.GetPlayerGiftAddPro()
local data={}
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
local data = {}
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
local pro = equipConfig[id].PlayerProperty
if pro and #pro>0 then
if pro and #pro > 0 then
for k = 1, #pro do
local key=pro[k][1]
local value= pro[k][2]
if tonumber(key) ~=nil and tonumber(key)~=0 then
if key~=0 and key~=nil then
local key = pro[k][1]
local value = pro[k][2]
if tonumber(key) ~= nil and tonumber(key) ~= 0 then
if key ~= 0 and key ~= nil then
if not data[key] then
data[key] = 0
end
@ -424,55 +437,46 @@ function this.GetPlayerGiftAddPro()
end
end
end
local pro2 = equipConfig[id].Property
if pro2 and #pro2>0 and pro2[1][1]~=0 and pro2[1][1]~=nil then
if pro2 and #pro2 > 0 and pro2[1][1] ~= 0 and pro2[1][1] ~= nil then
for k = 1, #pro2 do
local key=pro2[k][1]
local value=pro2[k][2]
if tonumber(key) ~=nil and tonumber(key)~=0 then
local key = pro2[k][1]
local value = pro2[k][2]
if tonumber(key) ~= nil and tonumber(key) ~= 0 then
if not data[key] then
data[key] = 0
end
if value and value~=0 then
LogError("pro2[k][1]==="..key.." value=="..value)
data[key] = data[key] + value
if value and value ~= 0 then
LogError("pro2[k][1]===" .. key .. " value==" .. value)
data[key] = data[key] + value
end
end
end
end
end
return data
end
function this.CheckGemRed()
return false
end
function this.CheckSuperGemRed()
return false
end
function this.GetPlayerGiftAdd()
local addPro=0
if this.playerGifts and #this.playerGifts>0 then
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp>0 then
addPro=addPro + equipConfig[id].HeroGitUp
local addPro = 0
if this.playerGifts and #this.playerGifts > 0 then
for i = 1, #this.playerGifts do
local id = this.playerGifts[i]
if equipConfig[id] and equipConfig[id].HeroGitUp and equipConfig[id].HeroGitUp > 0 then
addPro = addPro + equipConfig[id].HeroGitUp
end
end
end
return addPro/100
return addPro / 100
end
return this
return this

View File

@ -94,7 +94,7 @@ this.ScrollBar = Util.GetGameObject(self.gameObject, "listObj/bg/Scrollbar"):Get
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.mask:SetActive(false)
this.collectImg = Util.GetGameObject(self.gameObject, "collectImg"):GetComponent("Image")
this.lvTxt = Util.GetGameObject(self.gameObject, "lvTxt"):GetComponent("Text")
--this.lvTxt = Util.GetGameObject(self.gameObject, "lvTxt"):GetComponent("Text")
--this.collectImg.sprite=Util.LoadSprite("gh_tt_8")
this.gainChipBtn = Util.GetGameObject(self.gameObject, "gainBtn")
this.btn_help = Util.GetGameObject(self.gameObject, "btn_help")
@ -259,15 +259,15 @@ function this.RefreshWindowData()
this.force.text = ""
--显示上面赠送的
local list = GiftManager.GetHeroGifts(curHeroData.dynamicId)
lv, curNum, maxNum = GiftManager.GetCollectLvAndNum()
maxNum = GiftManager.GetHeroGiftBoxNum(curHeroData.dynamicId)
--if #list>=50 then
--curNum=#list+6
--maxNum=#list+6
--else
curNum = 12
maxNum = 12
curNum = maxNum
--maxNum = 12
--end
this.lvTxt.text = "收集度" .. lv .. ""
--this.lvTxt.text = "收集度" .. lv .. "级"
--LogError("lv========="..lv.." curnum=="..curNum.." maxNum=="..maxNum)
--maxNum=0
giftDatas = {}