金猪
This commit is contained in:
parent
50a2ff4b9f
commit
0fe15f3ba1
@ -4,7 +4,7 @@ function GodPigData:init(data)
|
|||||||
data = data or GConst.EMPTY_TABLE
|
data = data or GConst.EMPTY_TABLE
|
||||||
self.data.id = data.id or 0
|
self.data.id = data.id or 0
|
||||||
if self.data.id == 0 then
|
if self.data.id == 0 then
|
||||||
self.data.id = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value
|
self.data.id = self:getFirstLevelId()
|
||||||
end
|
end
|
||||||
self.data.count = data.count or 0
|
self.data.count = data.count or 0
|
||||||
self.data.cd = data.cd or 0
|
self.data.cd = data.cd or 0
|
||||||
@ -34,6 +34,27 @@ function GodPigData:addGoldPigCount()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GodPigData:getFirstLevelId()
|
||||||
|
if self.firstLevelId == nil then
|
||||||
|
self.firstLevelId = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value
|
||||||
|
end
|
||||||
|
return self.firstLevelId
|
||||||
|
end
|
||||||
|
|
||||||
|
function GodPigData:getTimeOverCD()
|
||||||
|
if self.timeOverCD == nil then
|
||||||
|
self.timeOverCD = ConfigManager:getConfig("const")["act_gold_pig_cd"].value * 3600
|
||||||
|
end
|
||||||
|
return self.timeOverCD
|
||||||
|
end
|
||||||
|
|
||||||
|
function GodPigData:getBoughtCD()
|
||||||
|
if self.boughtCD == nil then
|
||||||
|
self.boughtCD = ConfigManager:getConfig("const")["act_gold_pig_buy_cd"].value * 3600
|
||||||
|
end
|
||||||
|
return self.boughtCD
|
||||||
|
end
|
||||||
|
|
||||||
function GodPigData:getCfg()
|
function GodPigData:getCfg()
|
||||||
if self.cfg == nil then
|
if self.cfg == nil then
|
||||||
self.cfg = ConfigManager:getConfig("act_god_pig")
|
self.cfg = ConfigManager:getConfig("act_god_pig")
|
||||||
@ -67,4 +88,34 @@ function GodPigData:tryActiveGoldPig()
|
|||||||
self.data.endTime = Time:getServerTime() + self:getDuration()
|
self.data.endTime = Time:getServerTime() + self:getDuration()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 时间到了,消失并降档
|
||||||
|
function GodPigData:onTimeOver()
|
||||||
|
if not self.data.isOpen then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.data.isOpen = false
|
||||||
|
local cfg = self:getCfg()
|
||||||
|
local info = cfg[self.data.id]
|
||||||
|
if info == nil then
|
||||||
|
self.data.id = self:getFirstLevelId()
|
||||||
|
else
|
||||||
|
self.data.id = info.before_id or self:getFirstLevelId()
|
||||||
|
end
|
||||||
|
self.data.cd = self:getTimeOverCD()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 购买后,消失并升档位
|
||||||
|
function GodPigData:onBought(id)
|
||||||
|
if not self.data.isOpen then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.data.isOpen = false
|
||||||
|
local cfg = self:getCfg()
|
||||||
|
local info = cfg[id]
|
||||||
|
if info then
|
||||||
|
self.data.id = info.next_id or id
|
||||||
|
end
|
||||||
|
self.data.cd = self:getBoughtCD()
|
||||||
|
end
|
||||||
|
|
||||||
return GodPigData
|
return GodPigData
|
||||||
Loading…
x
Reference in New Issue
Block a user