235 lines
7.9 KiB
Lua
235 lines
7.9 KiB
Lua
------------------------------------------------
|
|
-- 作者: 王圣
|
|
-- 日期: 2021-03-19
|
|
-- 文件: LuaTestBehavior.lua
|
|
-- 模块: LuaTestBehavior
|
|
-- 描述: lua测试任务行为
|
|
------------------------------------------------
|
|
-- 引用
|
|
local L_WrapMode = CS.UnityEngine.WrapMode
|
|
local L_AnimClipNameDefine = CS.Thousandto.Core.Asset.AnimClipNameDefine
|
|
local L_AnimationPartType = CS.Thousandto.Core.Asset.AnimationPartType
|
|
local L_Behavior = require "Logic.TaskSystem.Behavior.TaskBehavior"
|
|
local L_WaterParam = require "Logic.TaskSystem.Data.WaterWaveParam"
|
|
local L_MonsterProperty = CS.Thousandto.Code.Logic.MonsterProperty
|
|
local ArriveToAnim = {
|
|
-- anim类型 0: 主角动作 1: 法宝动作 2: 宠物动作
|
|
AnimType = 0,
|
|
-- 位面副本ID
|
|
PlaneCopyId = 0,
|
|
-- 位面副本地图id
|
|
TargetMapId = 0,
|
|
TargetPos = nil,
|
|
Param = nil,
|
|
|
|
-- 在副本里面需要移动到的坐标
|
|
Move_x = 0,
|
|
Move_y = 0,
|
|
|
|
-- 移动的起始坐标
|
|
StarMovePos = Vector3.zero,
|
|
-- 移动的终点坐标
|
|
EndMovePos = Vector3.zero,
|
|
|
|
-- 播放动作片段的名字
|
|
ActionName = "",
|
|
-- 动作片段的tick时间
|
|
Tick = 0,
|
|
-- 动作片段播放时间
|
|
PlayClipTime = 0,
|
|
-- 当前Anim type
|
|
CurAnimType = TaskAnimType.Default
|
|
}
|
|
|
|
function ArriveToAnim:New(type, taskId)
|
|
return Utils.Extend(L_Behavior:New(type, taskId), self)
|
|
end
|
|
|
|
function ArriveToAnim:OnSetTarget(id, count, talkId, x, y, itemID, type)
|
|
if type == nil then
|
|
type = -1
|
|
end
|
|
self.TaskTarget.TagId = id
|
|
self.TaskTarget.PosX = x
|
|
self.TaskTarget.PosY = y
|
|
self.TaskTarget.TCount = count
|
|
self.TaskTarget.TagName = L_MonsterProperty.GetName(self.TaskTarget.TagId)
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(Id)
|
|
if _task ~= nil then
|
|
if self.TargetPos == nil then
|
|
self.TargetPos = {
|
|
MapId = _task.Data.MapID,
|
|
X = self.TaskTarget.PosX,
|
|
Y = 0,
|
|
Z = self.TaskTarget.PosY
|
|
}
|
|
end
|
|
self.TaskTarget.MapName = _task.Data:GetMapName()
|
|
end
|
|
-- 设置位面屏幕效果数据
|
|
if self.Param == nil then
|
|
self.Param = L_WaterParam:New()
|
|
end
|
|
local _planesShowEnter = ""
|
|
local _target = ""
|
|
_target = _task:GetTaskTarget(self.Id)
|
|
_planesShowEnter = _task:GetPlanShowEnter(self.Id)
|
|
if _planesShowEnter ~= nil and _planesShowEnter ~= "" then
|
|
local _strs = Utils.SplitNumber(_planesShowEnter, '_')
|
|
for i = 1, #_strs do
|
|
if #_strs.Length ~= 5 then
|
|
Debug.LogError("Task WaterWaveEffect cfg isError")
|
|
break
|
|
end
|
|
self.Param.distanceFactor = _strs[1]
|
|
self.Param.timeFactor = _strs[2]
|
|
self.Param.totalFactor = _strs[3]
|
|
self.Param.waveWidth = _strs[4]
|
|
self.Param.waveSpeed = _strs[5]
|
|
end
|
|
end
|
|
-- 设置位面副本Id
|
|
if _target ~= nil and _target ~= "" then
|
|
local _strs = Utils.SplitNumber(target, '_')
|
|
if #_strs >= 3 then
|
|
self.AnimType = _strs[1]
|
|
self.PlaneCopyId = _strs[3]
|
|
end
|
|
end
|
|
self.ActionName = _task:GetActionName()
|
|
local _movePos = _task:GetMovePos()
|
|
self.Move_x = _movePos.x
|
|
self.Move_y = _movePos.z
|
|
end
|
|
|
|
function ArriveToAnim:OnSetTargetDes()
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(Id)
|
|
if _task == nil then
|
|
return
|
|
end
|
|
self.Des = _task:GetJinDuDes()
|
|
self.UiDes = self.Des
|
|
end
|
|
|
|
function ArriveToAnim:CallBack()
|
|
-- 调用Npc寻路接口
|
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|
if _lp == nil then
|
|
return
|
|
end
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
if _task.Data.IsAccess then
|
|
local _cloneCfg = DataConfig.DataCloneMap[self.PlaneCopyId]
|
|
if _cloneCfg ~= nil then
|
|
self.TargetMapId = _cloneCfg.Mapid
|
|
end
|
|
if GameCenter.MapLogicSystem.MapCfg.MapId == self.TargetMapId then
|
|
if self.TaskTarget.TagId == 0 then
|
|
-- 播放主角动作
|
|
self.PlayClipTime = _lp:GetAnimClipLength(self.ActionName)
|
|
_lp:PlayAnim(self.ActionName, Core.Asset.AnimationPartType.AllBody)
|
|
_lp.IsCatching = true
|
|
self.CurAnimType = TaskAnimType.PlayAnim
|
|
elseif self.TaskTarget.TagId == 1 then
|
|
elseif self.TaskTarget.TagId == 2 then
|
|
-- 播放宠物动作
|
|
local _pet = GameCenter.GameSceneSystem:GetLocalPet()
|
|
if _pet ~= nil then
|
|
self.CurAnimType = TaskAnimType.MoveTo;
|
|
self.StarMovePos = Vector3(_pet.Position.x, _pet.Position.y, _pet.Position.z)
|
|
self.EndMovePos = Vector3(self.Move_x, _pet.Position.y, self.Move_y)
|
|
self.PlayClipTime = _pet:GetAnimClipLength(self.ActionName)
|
|
end
|
|
end
|
|
self.Tick = 0;
|
|
else
|
|
-- 没到到达目标点
|
|
if self.TaskTarget.Count ~= self.TaskTarget.TCount then
|
|
GameCenter.MapLogicSwitch.CanMandate = false;
|
|
PlayerBT.Task:TaskArriveToAnimEx(self.TaskTarget.TagId, self.Id, self.TargetPos.MapId, self.TargetPos.X,
|
|
self.TargetPos.Y, self.TargetPos.Z)
|
|
end
|
|
end
|
|
GameCenter.LuaTaskManager.CurSelectTaskID = self.Id
|
|
else
|
|
-- 找npc接取任务
|
|
_task:AccessTask()
|
|
end
|
|
end
|
|
|
|
function ArriveToAnim:OnDoBehavior(isClick)
|
|
-- Debug.Log("yy ArriveToAnim OnDoBehavior ")
|
|
self:TransPort(Utils.Handler(self.CallBack, self))
|
|
end
|
|
|
|
function ArriveToAnim:OnUpdate(dt)
|
|
if self.CurAnimType ~= TaskAnimType.Default then
|
|
-- 判断是否在任务地图里面
|
|
if GameCenter.MapLogicSystem.MapCfg.MapId == self.TargetMapId then
|
|
if self.AnimType == 0 then
|
|
-- 主角动作
|
|
self:TickPlayerAction(dt)
|
|
elseif self.AnimType == 1 then
|
|
-- 法宝动作
|
|
self:TickFbAction(dt)
|
|
elseif self.AnimType == 2 then
|
|
-- 宠物动作
|
|
end
|
|
else
|
|
-- 不在任务地图
|
|
if self.AnimType == 0 then
|
|
-- 主角动作
|
|
elseif self.AnimType == 1 then
|
|
-- 法宝动作
|
|
elseif self.AnimType == 2 then
|
|
-- 宠物动作
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- tick玩家动作
|
|
function ArriveToAnim:TickPlayerAction(dt)
|
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|
if _lp ~= nil then
|
|
if self.Tick < self.PlayClipTime then
|
|
self.Tick = self.Tick + dt
|
|
else
|
|
-- 请求服务器任务完成
|
|
local _task = GameCenter.LuaTaskManager.TaskContainer:FindTakByID(self.Id)
|
|
local _isSpecialTask = self:CheckSpecialTask(_task)
|
|
if not _isSpecialTask then
|
|
if _task ~= nil then
|
|
self.Tick = 0;
|
|
self.CurAnimType = TaskAnimType.Default;
|
|
_lp.IsCatching = false;
|
|
_lp:PlayAnim(L_AnimClipNameDefine.NormalIdle, L_AnimationPartType.AllBody, L_WrapMode.Once)
|
|
GameCenter.LuaTaskManager:SubMitTask(_task.Data.Id, _task.Data.Type)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-- tick法宝动作
|
|
function ArriveToAnim:TickFbAction(dt)
|
|
end
|
|
|
|
-- tick宠物动作
|
|
function ArriveToAnim:TickPetAction(dt)
|
|
end
|
|
|
|
function ArriveToAnim:CheckSpecialTask(task)
|
|
if task.Data.Type == TaskType.Guild then
|
|
if task.Data.Cfg.ConquerSubtype == 2 then
|
|
if self.TaskTarget.IsEnd then
|
|
-- 打开仙盟任务界面
|
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.GuildTask)
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
return false;
|
|
end
|
|
|
|
return ArriveToAnim
|