81 lines
1.9 KiB
Lua
81 lines
1.9 KiB
Lua
|
|
------------------------------------------------
|
|
--作者: 王圣
|
|
--日期: 2019-07-15
|
|
--文件: GrowthWayTaskData.lua
|
|
--模块: GrowthWayTaskData
|
|
--描述: 成长之路每日任务数据
|
|
------------------------------------------------
|
|
--引用
|
|
local ItemData = require "Logic.ServeCrazy.ServeCrazyItemData"
|
|
local GrowthWayTaskData = {
|
|
CfgId = 0,
|
|
--任务总次数
|
|
TotalCount = 0,
|
|
--当前完成次数
|
|
CurCount = 0,
|
|
--完成奖励星星数
|
|
StarNum = 0,
|
|
--打开UIid
|
|
OpenUIId = 0,
|
|
--打开参数
|
|
OpenParam = 0,
|
|
--任务描述
|
|
TaskDes = nil,
|
|
--显示的道具Item
|
|
Item = nil,
|
|
--是否领取
|
|
IsRward = false,
|
|
Cfg = nil,
|
|
State = 0,
|
|
}
|
|
|
|
function GrowthWayTaskData:New()
|
|
local _m = Utils.DeepCopy(self)
|
|
return _m
|
|
end
|
|
--解析数据
|
|
function GrowthWayTaskData:Parase(cfg)
|
|
if cfg ~= nil then
|
|
self.CfgId = cfg.Id
|
|
local list = Utils.SplitStr(cfg.Condition,'_')
|
|
self.TotalCount = tonumber(list[#list])
|
|
self.StarNum = cfg.Rate
|
|
self.OpenUIId = cfg.RelationUI
|
|
self.OpenParam = cfg.RelationSubUI
|
|
self.TaskDes = cfg.Des
|
|
self.Item = ItemData:New()
|
|
self.Item:Parase(cfg.Reward)
|
|
self.Cfg = cfg
|
|
end
|
|
end
|
|
|
|
--解析消息
|
|
function GrowthWayTaskData:ParaseMsg(msg)
|
|
if not msg.IsRward and msg.state then
|
|
--GameCenter.GrowthWaySystem.CurGold = GameCenter.GrowthWaySystem.CurGold - self.Cfg.Worth
|
|
end
|
|
self.CurCount = msg.progress
|
|
self.IsRward = msg.state
|
|
if self.IsRward then
|
|
self.State = 3
|
|
else
|
|
if self.CurCount >= self.TotalCount then
|
|
self.State = 1
|
|
else
|
|
self.State = 2
|
|
end
|
|
end
|
|
end
|
|
|
|
--是否可以领取道具
|
|
function GrowthWayTaskData:CanRewardItem()
|
|
if self.CurCount>=self.TotalCount then
|
|
if not self.IsRward then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
return GrowthWayTaskData |