miduo_client/Assets/ManagedResources/~Lua/Modules/Gem/GiftManager.lua

184 lines
4.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--新的命格管理
GiftManager = {}
local this = GiftManager
local giftConfig=ConfigManager.GetConfig(ConfigName.GiftConfig)
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
function this.Initialize()
this.allHeroGifts={}
this.playerGifts={}
end
--初始化命石
function this.InitGemsInfo(msg)
end
--初始化英雄礼物
function this.InitHeroGift(id,list)
this.allHeroGifts[id]=list
end
--初始化主角礼物
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]
if equipConfig[id] then
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
else
maxNum=v.Box
break
end
end
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])
end
end
end
--设置主角礼物
function this.SetPlayerGift(list)
for i=1,#list do
table.insert(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)
end
--获取英雄礼物增加的属性
function this.GetHeroGiftAddPro(_id)
local data={}
if not this.allHeroGifts[_id] then
LogError("英雄gift======================nil")
return data
end
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
for k = 1, #pro do
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
end
end
end
--英雄礼物不会加成主角属性
-- local pro2 = equipConfig[id].PlayerProperty
-- if pro2 and #pro2>0 then
-- for k = 1, #pro2 do
-- if not data[pro2[k][1]] then
-- data[pro2[k][1]] = 0
-- end
-- data[pro2[k][1]] = data[pro2[k][1]] + pro2[k][2]
-- end
-- end
end
return data
end
--获取主角礼物增加的属性
function this.GetPlayerGiftAddPro()
local data={}
for i=1,#this.playerGifts do
local id=this.playerGifts[i]
local pro = equipConfig[id].PlayerProperty
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
if not data[key] then
data[key] = 0
end
data[key] = data[key] + value
end
end
end
end
local pro2 = equipConfig[id].Property
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
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
end
end
end
end
end
return data
end
function this.CheckGemRed()
return false
end
function this.CheckSuperGemRed()
return false
end
return this