新增任务系统
This commit is contained in:
parent
9bd90e2516
commit
405fed5123
8 changed files with 621 additions and 3 deletions
|
|
@ -7,6 +7,10 @@ Npc.clicknpcCfg = {}
|
||||||
function clicknpc(actor, npcID, sScript)
|
function clicknpc(actor, npcID, sScript)
|
||||||
Func.sendmsg9(actor, "点击NPC:" .. npcID)
|
Func.sendmsg9(actor, "点击NPC:" .. npcID)
|
||||||
|
|
||||||
|
if MainLineTaskOBJ and MainLineTaskOBJ.onVisitNpc then
|
||||||
|
MainLineTaskOBJ:onVisitNpc(actor, npcID, sScript)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if sScript == "天关接待员" then
|
if sScript == "天关接待员" then
|
||||||
TianGuanOBJ:publicMian(actor, npcID)
|
TianGuanOBJ:publicMian(actor, npcID)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ VarCfg.Player.int["ǧ
|
||||||
VarCfg.Player.int["人参果"] = "INT_人参果"
|
VarCfg.Player.int["人参果"] = "INT_人参果"
|
||||||
VarCfg.Player.int["天山雪莲"] = "INT_天山雪莲"
|
VarCfg.Player.int["天山雪莲"] = "INT_天山雪莲"
|
||||||
VarCfg.Player.int["鞭尸丹"] = "INT_鞭尸丹"
|
VarCfg.Player.int["鞭尸丹"] = "INT_鞭尸丹"
|
||||||
|
VarCfg.Player.int["Ö÷ÏßÈÎÎñID"] = "INT_Ö÷ÏßÈÎÎñID"
|
||||||
|
VarCfg.Player.int["Ö÷ÏßÈÎÎñ״̬"] = "INT_Ö÷ÏßÈÎÎñ״̬"
|
||||||
|
VarCfg.Player.int["Ö÷ÏßÈÎÎñ½ø¶È"] = "INT_Ö÷ÏßÈÎÎñ½ø¶È"
|
||||||
|
|
||||||
VarCfg.Player.int.cd = {}
|
VarCfg.Player.int.cd = {}
|
||||||
VarCfg.Player.int.cd["长生戟"] = "INT_长生戟CD" ---* 长生戟cd
|
VarCfg.Player.int.cd["长生戟"] = "INT_长生戟CD" ---* 长生戟cd
|
||||||
|
|
|
||||||
440
Mirserver/Mir200/Envir/QuestDiary/游戏功能/A0_通用类/MainLineTask.lua
Normal file
440
Mirserver/Mir200/Envir/QuestDiary/游戏功能/A0_通用类/MainLineTask.lua
Normal file
|
|
@ -0,0 +1,440 @@
|
||||||
|
MainLineTaskOBJ = {}
|
||||||
|
|
||||||
|
MainLineTaskOBJ._name = "MainLineTaskOBJ"
|
||||||
|
MainLineTaskOBJ.STATUS_WAIT_VISIT = 0
|
||||||
|
MainLineTaskOBJ.STATUS_DOING = 1
|
||||||
|
MainLineTaskOBJ.STATUS_FINISH = 9
|
||||||
|
|
||||||
|
MainLineTaskOBJ.cfg = {
|
||||||
|
[1] = {
|
||||||
|
id = 1,
|
||||||
|
next = 2,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]了解首充",
|
||||||
|
desc = "了解首充后,前往任意地图击杀任意怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀任意怪物。",
|
||||||
|
rewardText = "经验100万、金币5000",
|
||||||
|
visit = { type = "module", keys = { "ShouChongOBJ" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "money", "经验", 1000000 }, { "money", "金币", 5000 } },
|
||||||
|
},
|
||||||
|
[2] = {
|
||||||
|
id = 2,
|
||||||
|
next = 3,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]拜访渡劫天尊",
|
||||||
|
desc = "拜访渡劫天尊后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "经验100万、金币10000",
|
||||||
|
visit = { type = "npc", ids = { 6 }, scripts = { "转生" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "money", "经验", 1000000 }, { "money", "金币", 10000 } },
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
id = 3,
|
||||||
|
next = 4,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]拜访神兽淬体",
|
||||||
|
desc = "拜访神兽淬体后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "神兽之血*50、神兽之骨*50",
|
||||||
|
visit = { type = "npc", ids = { 5 }, scripts = { "神兽淬体" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "item", "神兽之血", 50, 0 }, { "item", "神兽之骨", 50, 0 } },
|
||||||
|
},
|
||||||
|
[4] = {
|
||||||
|
id = 4,
|
||||||
|
next = 5,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]拜访紫金仙人",
|
||||||
|
desc = "拜访紫金仙人后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "经验100万、千年玄石*50、金币10000",
|
||||||
|
visit = { type = "npc", ids = { 189 }, scripts = { "紫金葫芦" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "money", "经验", 1000000 }, { "item", "千年玄石", 50, 0 }, { "money", "金币", 10000 } },
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
id = 5,
|
||||||
|
next = 6,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]了解绝学NPC",
|
||||||
|
desc = "了解绝学NPC后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "灵石*50、武林秘籍*1",
|
||||||
|
visit = { type = "npc", ids = { 12 }, scripts = { "绝学修炼" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "item", "灵石", 50, 0 }, { "item", "武林秘籍", 1, 0 } },
|
||||||
|
},
|
||||||
|
[6] = {
|
||||||
|
id = 6,
|
||||||
|
next = 7,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]拜访幸运仙子",
|
||||||
|
desc = "拜访幸运仙子后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "经验100万、金币10000",
|
||||||
|
visit = { type = "npc", ids = { 11 }, scripts = { "幸运项链" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "money", "经验", 1000000 }, { "money", "金币", 10000 } },
|
||||||
|
},
|
||||||
|
[7] = {
|
||||||
|
id = 7,
|
||||||
|
next = 8,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]前往装备重铸",
|
||||||
|
desc = "前往装备重铸后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "经验100万、金币10000",
|
||||||
|
visit = { type = "npc", ids = { 10 }, scripts = { "装备重铸" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "money", "经验", 1000000 }, { "money", "金币", 10000 } },
|
||||||
|
},
|
||||||
|
[8] = {
|
||||||
|
id = 8,
|
||||||
|
next = 9,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]前往武器升级",
|
||||||
|
desc = "前往武器升级后,前往任意地图击杀怪物5只。",
|
||||||
|
doingDesc = "前往任意地图击杀怪物。",
|
||||||
|
rewardText = "黑铁矿石*4、金币10000",
|
||||||
|
visit = { type = "npc", ids = { 13 }, scripts = { "武器升级" } },
|
||||||
|
target = { type = "kill_mon", count = 5, map = "*", mon = "*" },
|
||||||
|
rewards = { { "item", "黑铁矿石", 4, 0 }, { "money", "金币", 10000 } },
|
||||||
|
},
|
||||||
|
[9] = {
|
||||||
|
id = 9,
|
||||||
|
next = nil,
|
||||||
|
enabled = true,
|
||||||
|
title = "[主线]任务结束",
|
||||||
|
desc = "主线任务已完成。",
|
||||||
|
doingDesc = "主线任务已完成。",
|
||||||
|
rewardText = "无",
|
||||||
|
visit = nil,
|
||||||
|
target = nil,
|
||||||
|
rewards = {},
|
||||||
|
finish = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getTask(id)
|
||||||
|
return self.cfg[tonumber(id or 1)]
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:setTask(id, cfg)
|
||||||
|
if not id or not cfg then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
cfg.id = tonumber(id)
|
||||||
|
self.cfg[tonumber(id)] = cfg
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:deleteTask(id)
|
||||||
|
id = tonumber(id)
|
||||||
|
if not id then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
self.cfg[id] = nil
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getValidTask(id)
|
||||||
|
id = tonumber(id)
|
||||||
|
if not id then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local task = self:getTask(id)
|
||||||
|
local guard = 0
|
||||||
|
while task and task.enabled == false and task.next and guard < 100 do
|
||||||
|
task = self:getTask(task.next)
|
||||||
|
guard = guard + 1
|
||||||
|
end
|
||||||
|
return task
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getTaskId(actor)
|
||||||
|
local id = Player.getint(actor, VarCfg.Player.int["主线任务ID"]) or 0
|
||||||
|
if id <= 0 then
|
||||||
|
id = 1
|
||||||
|
self:setState(actor, id, self.STATUS_WAIT_VISIT, 0)
|
||||||
|
end
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if task and task.id ~= id then
|
||||||
|
id = task.id
|
||||||
|
local status = task.finish and self.STATUS_FINISH or self.STATUS_WAIT_VISIT
|
||||||
|
self:setState(actor, id, status, 0)
|
||||||
|
elseif not task then
|
||||||
|
id = 9
|
||||||
|
self:setState(actor, id, self.STATUS_FINISH, 0)
|
||||||
|
end
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getStatus(actor)
|
||||||
|
return Player.getint(actor, VarCfg.Player.int["主线任务状态"]) or self.STATUS_WAIT_VISIT
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getProgress(actor)
|
||||||
|
return Player.getint(actor, VarCfg.Player.int["主线任务进度"]) or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:setState(actor, id, status, progress)
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务ID"], id)
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务状态"], status)
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务进度"], progress or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:contains(list, value)
|
||||||
|
if not list then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
for _, v in ipairs(list) do
|
||||||
|
if tostring(v) == tostring(value) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:visitMatched(task, visitKey, npcID, sScript)
|
||||||
|
if not task or not task.visit then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local visit = task.visit
|
||||||
|
if visit.type == "module" then
|
||||||
|
return self:contains(visit.keys, visitKey)
|
||||||
|
end
|
||||||
|
if visit.type == "npc" then
|
||||||
|
return self:contains(visit.ids, npcID) or self:contains(visit.scripts, sScript)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:getRewardView(task)
|
||||||
|
local itemRewards = {}
|
||||||
|
local moneyRewards = {}
|
||||||
|
for _, reward in ipairs((task and task.rewards) or {}) do
|
||||||
|
local rtype = reward[1]
|
||||||
|
local name = reward[2]
|
||||||
|
local num = tonumber(reward[3]) or 0
|
||||||
|
local bind = tonumber(reward[4]) or 0
|
||||||
|
if name and num > 0 then
|
||||||
|
if rtype == "item" then
|
||||||
|
table.insert(itemRewards, { name = name, count = num, bind = bind, type = rtype })
|
||||||
|
elseif rtype == "money" then
|
||||||
|
table.insert(itemRewards, { name = name, count = num, bind = 0, type = rtype })
|
||||||
|
table.insert(moneyRewards, { name = name, count = num })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return itemRewards, moneyRewards
|
||||||
|
end
|
||||||
|
function MainLineTaskOBJ:getTaskView(actor)
|
||||||
|
local id = self:getTaskId(actor)
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if not task then
|
||||||
|
task = self.cfg[9]
|
||||||
|
id = 9
|
||||||
|
self:setState(actor, id, self.STATUS_FINISH, 0)
|
||||||
|
end
|
||||||
|
local status = self:getStatus(actor)
|
||||||
|
local progress = self:getProgress(actor)
|
||||||
|
local target = task and task.target or nil
|
||||||
|
local need = target and target.count or 0
|
||||||
|
if task and task.finish then
|
||||||
|
status = self.STATUS_FINISH
|
||||||
|
progress = 0
|
||||||
|
need = 0
|
||||||
|
end
|
||||||
|
local statusText = "待拜访"
|
||||||
|
local desc = task and task.desc or ""
|
||||||
|
if status == self.STATUS_DOING then
|
||||||
|
statusText = "进行中"
|
||||||
|
desc = task.doingDesc or desc
|
||||||
|
elseif status == self.STATUS_FINISH or (task and task.finish) then
|
||||||
|
statusText = "已完成"
|
||||||
|
desc = task.desc or "主线任务已完成。"
|
||||||
|
end
|
||||||
|
local rewardItems, rewardMoneys = self:getRewardView(task)
|
||||||
|
return {
|
||||||
|
id = task and task.id or id,
|
||||||
|
title = task and task.title or "[主线]任务",
|
||||||
|
desc = desc,
|
||||||
|
status = status,
|
||||||
|
statusText = statusText,
|
||||||
|
progress = progress,
|
||||||
|
need = need,
|
||||||
|
rewardText = task and task.rewardText or "",
|
||||||
|
rewardItems = rewardItems,
|
||||||
|
rewardMoneys = rewardMoneys,
|
||||||
|
finish = task and task.finish and true or false,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:sync(actor)
|
||||||
|
if not isnotnull(actor) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self:tryCompleteReady(actor) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
Message:SubLink(actor, self._name .. "_sync", self:getTaskView(actor))
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:startTask(actor, task)
|
||||||
|
self:setState(actor, task.id, self.STATUS_DOING, 0)
|
||||||
|
Func.sendmsg9(actor, string.format("[主线任务]:#70|已接取:%s", task.title))
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:onVisit(actor, visitKey)
|
||||||
|
local id = self:getTaskId(actor)
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if not task or task.finish or self:getStatus(actor) ~= self.STATUS_WAIT_VISIT then
|
||||||
|
self:sync(actor)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self:visitMatched(task, visitKey, nil, nil) then
|
||||||
|
self:startTask(actor, task)
|
||||||
|
else
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:onVisitNpc(actor, npcID, sScript)
|
||||||
|
local id = self:getTaskId(actor)
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if not task or task.finish or self:getStatus(actor) ~= self.STATUS_WAIT_VISIT then
|
||||||
|
self:sync(actor)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self:visitMatched(task, nil, npcID, sScript) then
|
||||||
|
self:startTask(actor, task)
|
||||||
|
else
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:giveItemRewards(actor, items)
|
||||||
|
if #items <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local itemStrs = {}
|
||||||
|
for _, item in ipairs(items) do
|
||||||
|
table.insert(itemStrs, string.format("%s#%s#%s", item[1], item[2], item[3] or 0))
|
||||||
|
end
|
||||||
|
gives(actor, table.concat(itemStrs, "&"), "主线任务")
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:giveRewards(actor, rewards)
|
||||||
|
local items = {}
|
||||||
|
for _, reward in ipairs(rewards or {}) do
|
||||||
|
local rtype = reward[1]
|
||||||
|
local name = reward[2]
|
||||||
|
local num = tonumber(reward[3]) or 0
|
||||||
|
local bind = tonumber(reward[4]) or 0
|
||||||
|
if rtype == "money" then
|
||||||
|
local moneyId = ConstCfg.sysMoney[name]
|
||||||
|
if moneyId and num > 0 then
|
||||||
|
changemoney(actor, moneyId, "+", num, "主线任务", true)
|
||||||
|
end
|
||||||
|
elseif rtype == "item" and name and num > 0 then
|
||||||
|
table.insert(items, { name, num, bind })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:giveItemRewards(actor, items)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:completeTask(actor, task)
|
||||||
|
self:giveRewards(actor, task.rewards)
|
||||||
|
Func.sendmsg9(actor, string.format("[主线任务]:#70|完成%s,奖励已发放。", task.title))
|
||||||
|
|
||||||
|
local nextTask = self:getValidTask(task.next)
|
||||||
|
if nextTask then
|
||||||
|
if nextTask.finish then
|
||||||
|
self:setState(actor, nextTask.id, self.STATUS_FINISH, 0)
|
||||||
|
else
|
||||||
|
self:setState(actor, nextTask.id, self.STATUS_WAIT_VISIT, 0)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:setState(actor, 9, self.STATUS_FINISH, 0)
|
||||||
|
end
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:tryCompleteReady(actor)
|
||||||
|
if self:getStatus(actor) ~= self.STATUS_DOING then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local id = self:getTaskId(actor)
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if not task or not task.target or task.target.type ~= "kill_mon" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local need = tonumber(task.target.count) or 0
|
||||||
|
if need > 0 and self:getProgress(actor) >= need then
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务进度"], need)
|
||||||
|
self:completeTask(actor, task)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
function MainLineTaskOBJ:onKillMon(actor, mon, itype, kill, monName, mapID)
|
||||||
|
if self:getStatus(actor) ~= self.STATUS_DOING then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local id = self:getTaskId(actor)
|
||||||
|
local task = self:getValidTask(id)
|
||||||
|
if not task or not task.target or task.target.type ~= "kill_mon" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target = task.target
|
||||||
|
if target.map and target.map ~= "*" and tostring(target.map) ~= tostring(mapID) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if target.mon and target.mon ~= "*" and tostring(target.mon) ~= tostring(monName) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local need = tonumber(target.count) or 0
|
||||||
|
local progress = self:getProgress(actor) + 1
|
||||||
|
if progress >= need then
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务进度"], need)
|
||||||
|
self:completeTask(actor, task)
|
||||||
|
else
|
||||||
|
Player.setint(actor, VarCfg.Player.int["主线任务进度"], progress)
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
GameEvent.add(EventCfg.onLogin, function(actor)
|
||||||
|
MainLineTaskOBJ:sync(actor)
|
||||||
|
end, MainLineTaskOBJ)
|
||||||
|
|
||||||
|
GameEvent.add(EventCfg.onqfloadend, function(actor)
|
||||||
|
MainLineTaskOBJ:sync(actor)
|
||||||
|
end, MainLineTaskOBJ)
|
||||||
|
|
||||||
|
GameEvent.add(EventCfg.onKillMon, function(actor, mon, itype, kill, monName, mapID)
|
||||||
|
MainLineTaskOBJ:onKillMon(actor, mon, itype, kill, monName, mapID)
|
||||||
|
end, MainLineTaskOBJ)
|
||||||
|
|
||||||
|
MainLineTaskOBJ.allowFunc = { "query", "visit" }
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:query(actor)
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:visit(actor, p1, p2, p3, data)
|
||||||
|
local visitKey = p1
|
||||||
|
if type(data) == "table" then
|
||||||
|
visitKey = data[1] or data.visitKey or visitKey
|
||||||
|
end
|
||||||
|
if visitKey then
|
||||||
|
self:onVisit(actor, visitKey)
|
||||||
|
else
|
||||||
|
self:sync(actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return MainLineTaskOBJ
|
||||||
|
|
@ -10,11 +10,41 @@ function ui.init(parent, __data__, __update__)
|
||||||
GUI:setTag(Layer, -1)
|
GUI:setTag(Layer, -1)
|
||||||
|
|
||||||
-- Create TaskShow_Layout
|
-- Create TaskShow_Layout
|
||||||
local TaskShow_Layout = GUI:Layout_Create(Layer, "TaskShow_Layout", 0, 0, 200, 185, false)
|
local TaskShow_Layout = GUI:Layout_Create(Layer, "TaskShow_Layout", 0, 0, 202, 188, false)
|
||||||
GUI:setAnchorPoint(TaskShow_Layout, 0.00, 0.00)
|
GUI:setAnchorPoint(TaskShow_Layout, 0.00, 0.00)
|
||||||
GUI:setTouchEnabled(TaskShow_Layout, false)
|
GUI:setTouchEnabled(TaskShow_Layout, false)
|
||||||
GUI:setTag(TaskShow_Layout, 0)
|
GUI:setTag(TaskShow_Layout, 0)
|
||||||
|
|
||||||
|
local Bg = GUI:Layout_Create(TaskShow_Layout, "Bg", 0, 0, 202, 188, false)
|
||||||
|
GUI:Layout_setBackGroundColorType(Bg, 1)
|
||||||
|
GUI:Layout_setBackGroundColor(Bg, "#000000")
|
||||||
|
GUI:Layout_setBackGroundColorOpacity(Bg, 120)
|
||||||
|
GUI:setTouchEnabled(Bg, false)
|
||||||
|
|
||||||
|
local TaskTitle_Text = GUI:Text_Create(TaskShow_Layout, "TaskTitle_Text", 8, 166, 15, "#f6d27a", "[主线]任务")
|
||||||
|
GUI:setAnchorPoint(TaskTitle_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(TaskTitle_Text, "#000000", 1)
|
||||||
|
|
||||||
|
local TaskStatus_Text = GUI:Text_Create(TaskShow_Layout, "TaskStatus_Text", 154, 166, 13, "#28ef01", "")
|
||||||
|
GUI:setAnchorPoint(TaskStatus_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(TaskStatus_Text, "#000000", 1)
|
||||||
|
|
||||||
|
local TaskDesc_Text = GUI:Text_Create(TaskShow_Layout, "TaskDesc_Text", 8, 134, 13, "#ffffff", "")
|
||||||
|
GUI:setAnchorPoint(TaskDesc_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(TaskDesc_Text, "#000000", 1)
|
||||||
|
|
||||||
|
local TaskProgress_Text = GUI:Text_Create(TaskShow_Layout, "TaskProgress_Text", 8, 104, 14, "#28ef01", "进度:0/0")
|
||||||
|
GUI:setAnchorPoint(TaskProgress_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(TaskProgress_Text, "#000000", 1)
|
||||||
|
|
||||||
|
local TaskReward_Text = GUI:Text_Create(TaskShow_Layout, "TaskReward_Text", 8, 75, 12, "#ffd36a", "奖励:无")
|
||||||
|
GUI:setAnchorPoint(TaskReward_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(TaskReward_Text, "#000000", 1)
|
||||||
|
|
||||||
|
local RewardItems_Layout = GUI:Layout_Create(TaskShow_Layout, "RewardItems_Layout", 8, 6, 186, 58, false)
|
||||||
|
GUI:setAnchorPoint(RewardItems_Layout, 0.00, 0.00)
|
||||||
|
GUI:setTouchEnabled(RewardItems_Layout, false)
|
||||||
|
|
||||||
ui.update(__data__)
|
ui.update(__data__)
|
||||||
return Layer
|
return Layer
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,52 @@ end
|
||||||
|
|
||||||
|
|
||||||
TaskShowOBJ.UIfile = getUifile()
|
TaskShowOBJ.UIfile = getUifile()
|
||||||
|
TaskShowOBJ.mainLineData = nil
|
||||||
|
|
||||||
|
local function getShortDesc(data)
|
||||||
|
local status = tonumber(data.status or 0) or 0
|
||||||
|
if data.finish then
|
||||||
|
return "主线任务已完成"
|
||||||
|
end
|
||||||
|
if status == 1 then
|
||||||
|
return "任意地图击杀怪物"
|
||||||
|
end
|
||||||
|
return "拜访目标后击杀5只怪"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getRewardItems(data)
|
||||||
|
local items = {}
|
||||||
|
for _, item in ipairs(data.rewardItems or {}) do
|
||||||
|
table.insert(items, item)
|
||||||
|
end
|
||||||
|
if #items <= 0 then
|
||||||
|
for _, item in ipairs(data.rewardMoneys or {}) do
|
||||||
|
table.insert(items, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #items <= 0 and data.rewardText and data.rewardText ~= "" and data.rewardText ~= "无" then
|
||||||
|
for part in string.gmatch(data.rewardText, "[^、,,%s]+") do
|
||||||
|
local name, count = string.match(part, "^(.+)%*(%d+)$")
|
||||||
|
if not name then
|
||||||
|
name, count = string.match(part, "^(.-)(%d+)万$")
|
||||||
|
if name and count then
|
||||||
|
count = tonumber(count) * 10000
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not name then
|
||||||
|
name, count = string.match(part, "^(.-)(%d+)$")
|
||||||
|
end
|
||||||
|
if not name and string.find(part, "一本", 1, true) then
|
||||||
|
name = string.gsub(part, "一本", "")
|
||||||
|
count = 1
|
||||||
|
end
|
||||||
|
if name and name ~= "" then
|
||||||
|
table.insert(items, { name = name, count = tonumber(count) or 1 })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return items
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function TaskShowOBJ:main()
|
function TaskShowOBJ:main()
|
||||||
|
|
@ -23,6 +69,83 @@ function TaskShowOBJ:main()
|
||||||
|
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self.ui = GUI:ui_delegate(parent)
|
self.ui = GUI:ui_delegate(parent)
|
||||||
|
|
||||||
|
if self.UIfile == "game/Tongyong/TaskShowUI" then
|
||||||
|
self:renderMainLine(self.mainLineData or (MainLineTaskOBJ and MainLineTaskOBJ.data))
|
||||||
|
ssrMessage:SubLink("MainLineTaskOBJ_query")
|
||||||
|
SL:ScheduleOnce(function()
|
||||||
|
ssrMessage:SubLink("MainLineTaskOBJ_query")
|
||||||
|
end, 0.35)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskShowOBJ:syncMainLine(data)
|
||||||
|
self.mainLineData = data
|
||||||
|
if self.UIfile ~= "game/Tongyong/TaskShowUI" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not self.ui or GUI:Win_IsNull(self._parent) then
|
||||||
|
self:main()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:renderMainLine(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskShowOBJ:renderMainLine(data)
|
||||||
|
if not data or not self.ui then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.TaskTitle_Text) then
|
||||||
|
GUI:Text_setString(self.ui.TaskTitle_Text, data.title or "[主线]任务")
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.TaskStatus_Text) then
|
||||||
|
GUI:Text_setString(self.ui.TaskStatus_Text, data.statusText or "")
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.TaskDesc_Text) then
|
||||||
|
GUI:Text_setString(self.ui.TaskDesc_Text, getShortDesc(data))
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.TaskProgress_Text) then
|
||||||
|
local need = tonumber(data.need or 0) or 0
|
||||||
|
local progress = tonumber(data.progress or 0) or 0
|
||||||
|
local progressText = need > 0 and string.format("进度:%d/%d", progress, need) or "进度:已完成"
|
||||||
|
GUI:Text_setString(self.ui.TaskProgress_Text, progressText)
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.TaskReward_Text) then
|
||||||
|
GUI:Text_setString(self.ui.TaskReward_Text, "奖励:")
|
||||||
|
end
|
||||||
|
if GUI:Win_IsNotNull(self.ui.RewardItems_Layout) then
|
||||||
|
GUI:removeAllChildren(self.ui.RewardItems_Layout)
|
||||||
|
local items = getRewardItems(data)
|
||||||
|
if #items <= 0 then
|
||||||
|
local EmptyReward_Text = GUI:Text_Create(self.ui.RewardItems_Layout, "EmptyReward_Text", 0, 24, 12, "#ffd36a", "无")
|
||||||
|
GUI:setAnchorPoint(EmptyReward_Text, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(EmptyReward_Text, "#000000", 1)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i, item in ipairs(items) do
|
||||||
|
if i > 4 then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local name = item.name or item[1]
|
||||||
|
local count = tonumber(item.count or item[2]) or 1
|
||||||
|
local x = 22 + (i - 1) * 44
|
||||||
|
local y = 29
|
||||||
|
local index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", name)
|
||||||
|
if index then
|
||||||
|
local itemShow = GUI:ItemShow_Create(self.ui.RewardItems_Layout, "RewardItem_" .. i, x, y, {
|
||||||
|
index = index,
|
||||||
|
count = count,
|
||||||
|
bgVisible = true,
|
||||||
|
look = true
|
||||||
|
})
|
||||||
|
GUI:setScale(itemShow, 0.86)
|
||||||
|
else
|
||||||
|
local RewardText = GUI:Text_Create(self.ui.RewardItems_Layout, "RewardText_" .. i, x - 18, y, 11, "#ffd36a", tostring(name or "奖励"))
|
||||||
|
GUI:setAnchorPoint(RewardText, 0.00, 0.50)
|
||||||
|
GUI:Text_enableOutline(RewardText, "#000000", 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
13
client/dev/GUILayout/game/tongyong/MainLineTaskOBJ.lua
Normal file
13
client/dev/GUILayout/game/tongyong/MainLineTaskOBJ.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
MainLineTaskOBJ = {}
|
||||||
|
|
||||||
|
MainLineTaskOBJ.__cname = "MainLineTaskOBJ"
|
||||||
|
MainLineTaskOBJ.data = nil
|
||||||
|
|
||||||
|
function MainLineTaskOBJ:sync(arg1, arg2, arg3, data)
|
||||||
|
self.data = data
|
||||||
|
if TaskShowOBJ and TaskShowOBJ.syncMainLine then
|
||||||
|
TaskShowOBJ:syncMainLine(data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return MainLineTaskOBJ
|
||||||
|
|
@ -10,6 +10,11 @@ ShouChongOBJ.cfg = {}
|
||||||
ShouChongOBJ.other = nil
|
ShouChongOBJ.other = nil
|
||||||
ShouChongOBJ.npcid = nil
|
ShouChongOBJ.npcid = nil
|
||||||
|
|
||||||
|
function ShouChongOBJ:main(arg1, arg2, arg3, data)
|
||||||
|
Up_BaseClassOBJ.main(self, arg1, arg2, arg3, data)
|
||||||
|
ssrMessage:SubLink("MainLineTaskOBJ_visit", "ShouChongOBJ")
|
||||||
|
end
|
||||||
|
|
||||||
function ShouChongOBJ:updata()
|
function ShouChongOBJ:updata()
|
||||||
local cfg = self.cfg[1]
|
local cfg = self.cfg[1]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,9 @@ local config = {
|
||||||
Name="沃玛统领"
|
Name="沃玛统领"
|
||||||
},
|
},
|
||||||
[34] = {
|
[34] = {
|
||||||
Hide="0#0",
|
Name="远古·沃玛魔祖",
|
||||||
IDX=34,
|
IDX=34,
|
||||||
Name="远古·沃玛魔祖"
|
Hide="0#0"
|
||||||
},
|
},
|
||||||
[35] = {
|
[35] = {
|
||||||
IDX=35,
|
IDX=35,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue