107 lines
4.0 KiB
Lua
107 lines
4.0 KiB
Lua
------------------------------------------------
|
|
-- 作者: 王圣
|
|
-- 日期: 2021-03-19
|
|
-- 文件: BCollection.lua
|
|
-- 模块: BCollection
|
|
-- 描述: 任务采集行为
|
|
------------------------------------------------
|
|
-- 引用
|
|
local L_Behavior = require "Logic.TaskSystem.Behavior.TaskBehavior"
|
|
local BCollection = {}
|
|
|
|
function BCollection:New(type, taskId)
|
|
return Utils.Extend(L_Behavior:New(type, taskId), self)
|
|
end
|
|
|
|
function BCollection:OnSetTarget(id, count, talkId, x, y, itemID, type)
|
|
self.TaskTarget.TagId = id
|
|
self.TaskTarget.TCount = count
|
|
local _cfg = DataConfig.DataGather[self.TaskTarget.TagId]
|
|
self.TaskTarget.TagName = _cfg == nil and nil or _cfg.Name
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if _task ~= nil then
|
|
self.TaskTarget.MapName = _task.Data:GetMapName()
|
|
end
|
|
end
|
|
function BCollection:SetTargetDes()
|
|
if self.TaskTarget.Count >= self.TaskTarget.TCount then
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if _task ~= nil then
|
|
if _task:IsAuto() then
|
|
self.Des = DataConfig.DataMessageString.Get("TASK_BEHEAIOR_OVER")
|
|
else
|
|
self.Des = _task:GetJinDuDes()
|
|
end
|
|
self.UiDes = _task:GetUIDes(self.TaskTarget.Count, self.TaskTarget.TCount)
|
|
end
|
|
else
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if _task == nil then
|
|
return
|
|
end
|
|
if _task.Data.Type == TaskType.Main or _task.Data.Type == TaskType.Daily or _task.Data.Type == TaskType.Guild or
|
|
_task.Data.Type == TaskType.ZhuanZhi then
|
|
self.Des = _task:GetJinDuDes()
|
|
else
|
|
self.Des = UIUtils.CSFormat(DataConfig.DataMessageString.Get("TASK_BEHEAIOR_COLLECT"),
|
|
self.TaskTarget.MapName, self.TaskTarget.TagName, self.TaskTarget.Count,
|
|
self.TaskTarget.TCount)
|
|
end
|
|
self.UiDes = self.Des
|
|
end
|
|
end
|
|
|
|
function BCollection:CallBack()
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if self.TaskTarget.Count == self.TaskTarget.TCount or self.TaskTarget.IsEnd then
|
|
local _isSpecialTask = false
|
|
if _task.Data.Type == TaskType.Guild then
|
|
if _task.Data.Cfg.ConquerSubtype == 2 then
|
|
-- 打开仙盟任务界面
|
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.GuildTask)
|
|
_isSpecialTask = true;
|
|
end
|
|
end
|
|
if not _isSpecialTask then
|
|
local _openId = _task:SubMitTaskOpenPanel()
|
|
if _openId == 0 then
|
|
GameCenter.LuaTaskManager:SubMitTask(_task.Data.Id, _task.Data.Type)
|
|
else
|
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(_openId)
|
|
end
|
|
end
|
|
else
|
|
if _task.Data.IsAccess then
|
|
-- 采集
|
|
PlayerBT.Task:TaskCollectObj(self.TaskTarget.TagId, self.Id, self.TaskTarget.Count, self.TaskTarget.TCount)
|
|
else
|
|
-- 找npc接取任务
|
|
_task:AccessTask()
|
|
end
|
|
end
|
|
end
|
|
|
|
function BCollection:OnDoBehavior(isClick)
|
|
-- Debug.Log("yy BCollection OnDoBehavior ")
|
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|
if _lp == nil then
|
|
return
|
|
end
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if _task ~= nil then
|
|
if _task.Data.Type == TaskType.ZhanChang then
|
|
if self.TaskTarget.Count ~= self.TaskTarget.TCount then
|
|
if GameCenter.MapLogicSystem.MapCfg.Type == UnityUtils.GetObjct2Int(MapTypeDef.Copy) then
|
|
PlayerBT.Task:TaskCollectObj(self.TaskTarget.TagId, _task.Data.Id, self.TaskTarget.TCount)
|
|
end
|
|
else
|
|
PlayerBT.ChangeState(PlayerBDState.Default)
|
|
end
|
|
else
|
|
self:TransPort(Utils.Handler(self.CallBack, self))
|
|
end
|
|
end
|
|
end
|
|
|
|
return BCollection
|