461 lines
18 KiB
Lua
461 lines
18 KiB
Lua
------------------------------------------------
|
|
--作者: 杨全福
|
|
--日期: 2019-05-13
|
|
--文件: JZSLCopyLogic.lua
|
|
--模块: JZSLCopyLogic
|
|
--描述: 剑主试炼副本逻辑
|
|
------------------------------------------------
|
|
local CSGameCenter = CS.Thousandto.Code.Center.GameCenter
|
|
|
|
local JZSLCopyLogic = {
|
|
--父逻辑系统
|
|
Parent = nil,
|
|
--等待时间
|
|
WaitTime = 0,
|
|
--剩余时间
|
|
RemainTime = 0.0,
|
|
SyncTime = 0,
|
|
SyncRemainTime = 0,
|
|
--配置ID
|
|
SwordCfgId = 0,
|
|
|
|
--是否结束
|
|
IsFinish = false,
|
|
|
|
AnimTimer = -1,
|
|
--特效节点
|
|
AnimGos = nil,
|
|
VfxGos = nil,
|
|
--动画时间
|
|
AnimTimes = {
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
7.333, 7.333, 11, 5, 10, 5.5,
|
|
},
|
|
IsHideCamera = false,
|
|
|
|
--播放飞剑获得效果
|
|
StateTimer = 0,
|
|
SwordGetState = 0,
|
|
--渡劫动作定义
|
|
PlayEndAnims = {
|
|
[1] = "dujie05",
|
|
[7] = "dujie06",
|
|
[13] = "dujie08",
|
|
[19] = "dujie09",
|
|
[25] = "dujie10",
|
|
[31] = "dujie11",
|
|
},
|
|
FlySwordVfxs = {
|
|
[1] = {{"VFXRoot", 22}, {"Bone01", 23}},
|
|
[7] = {{"Bone01", 24}, {"Bone02", 25}},
|
|
},
|
|
PlayerVfxs = {
|
|
[1] = {{"", 26}},
|
|
[7] = {{"", 30}},
|
|
[13] = {{"", 27}},
|
|
[19] = {{"", 31}},
|
|
[25] = {{"", 32}},
|
|
[31] = {{"", 33}},
|
|
},
|
|
StartDis = 0,
|
|
StartYaw = 0,
|
|
StartPitch = 0,
|
|
StartOffsetY = 0,
|
|
StartOffsetX = 0,
|
|
StartFov = 0,
|
|
TargetDis = 3,
|
|
TargetYaw = 220,
|
|
TargetPitch = 13,
|
|
TargetOffsetY = 1,
|
|
TargetOffsetX = 0,
|
|
TargetFov = 60,
|
|
}
|
|
|
|
function JZSLCopyLogic:OnEnterScene(parent)
|
|
self.Parent = parent
|
|
|
|
--设置开关
|
|
GameCenter.MapLogicSwitch.CanRide = false
|
|
GameCenter.MapLogicSwitch.CanFly = false
|
|
GameCenter.MapLogicSwitch.CanRollDoge = true
|
|
GameCenter.MapLogicSwitch.CanMandate = true
|
|
GameCenter.MapLogicSwitch.CanOpenTeam = false
|
|
GameCenter.MapLogicSwitch.ShowNewFunction = false
|
|
GameCenter.MapLogicSwitch.UseAutoStrikeBack = true
|
|
GameCenter.MapLogicSwitch.CanTeleport = false
|
|
GameCenter.MapLogicSwitch.IsCopyMap = true
|
|
GameCenter.MapLogicSwitch.IsPlaneCopyMap = false
|
|
GameCenter.MapLogicSwitch.HoldFighting = false
|
|
|
|
--关掉小地图功能
|
|
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.AreaMap, false)
|
|
--关掉菜单
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSE_MAINMENU)
|
|
|
|
self.AnimGos = {}
|
|
self.VfxGos = {}
|
|
local _sceneRoot = GameObject.Find("SceneRoot").transform
|
|
if _sceneRoot ~= nil then
|
|
for i = 1, 36 do
|
|
local _bigId = (i - 1) // 6 + 1
|
|
local _smId = (i - 1) % 6 + 1
|
|
self.AnimGos[i] = UIUtils.FindGo(_sceneRoot, string.format("[timeline]/[%d]/[Jian%d]", _bigId, _smId))
|
|
if self.AnimGos[i] ~= nil then
|
|
self.AnimGos[i]:SetActive(false)
|
|
end
|
|
self.VfxGos[i] = UIUtils.FindGo(_sceneRoot, string.format("[vfx]/[1]/[far]/[Jian%d]", i))
|
|
if self.VfxGos[i] ~= nil then
|
|
self.VfxGos[i]:SetActive(false)
|
|
end
|
|
end
|
|
for i = 1, 6 do
|
|
local _go = UIUtils.FindGo(_sceneRoot, string.format("[timeline]/[%d]", i))
|
|
if _go ~= nil then
|
|
_go:SetActive(true)
|
|
end
|
|
end
|
|
end
|
|
self.AnimTimer = -1
|
|
self.LP = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|
local _scene = GameCenter.GameSceneSystem.ActivedScene
|
|
self.CameraControl = _scene.SceneCameraControl
|
|
self.CameraManager = _scene.CameraManager
|
|
self.CacheResultMsg = nil
|
|
self:ChangeEndState(0)
|
|
|
|
--预加载结算界面资源
|
|
CSGameCenter.TextureManager:PreLoadTexture(AssetUtils.GetImageAssetPath(ImageTypeCode.UI, "tex_n_d_167_3"))
|
|
CSGameCenter.TextureManager:PreLoadTexture(AssetUtils.GetImageAssetPath(ImageTypeCode.UI, "tex_n_d_jianlingjiesuan"))
|
|
CSGameCenter.TextureManager:PreLoadTexture(AssetUtils.GetImageAssetPath(ImageTypeCode.UI, "tex_n_d_167_5"))
|
|
|
|
--清除剑灵觉醒cd
|
|
local _swordSkill = GameCenter.PlayerSkillSystem.FlySwordSkill
|
|
if _swordSkill ~= nil then
|
|
GameCenter.PlayerSkillSystem:EndCD(_swordSkill.CfgID)
|
|
end
|
|
end
|
|
|
|
function JZSLCopyLogic:OnLeaveScene()
|
|
--打开小地图功能
|
|
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.AreaMap, true)
|
|
--关闭主界面
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLCopyMainForm_CLOSE)
|
|
--关闭结算界面
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLResultForm_CLOSE)
|
|
|
|
--卸载动作
|
|
local _endAnim = self.PlayEndAnims[self.SwordCfgId]
|
|
if _endAnim ~= nil then
|
|
GameCenter.MapLogicSwitch:TakeOffAnimation(self.LP, _endAnim)
|
|
end
|
|
|
|
if self.UseJiaFeiJian then
|
|
self.LP:UnLoadFlySword()
|
|
self.LP.PropMoudle.FlySwordUID = 0
|
|
self.LP.PropMoudle.FlySwordCfgID = 0
|
|
end
|
|
self.LP.IsDuJieing = false
|
|
self.LP.IsCatching = false
|
|
self.LP:ResetDirection()
|
|
end
|
|
|
|
--更新
|
|
function JZSLCopyLogic:Update(dt)
|
|
self:UpdateEndState(dt)
|
|
if self.WaitTime > 0 then
|
|
self.WaitTime = self.WaitTime - dt
|
|
if self.WaitTime <= 0 then
|
|
self.RemainTime = self.RemainTime + self.WaitTime
|
|
self.SyncTime = Time.GetRealtimeSinceStartup()
|
|
self.SyncRemainTime = self.RemainTime
|
|
end
|
|
return
|
|
end
|
|
if not self.IsFinish then
|
|
self.RemainTime = self.SyncRemainTime - (Time.GetRealtimeSinceStartup() - self.SyncTime)
|
|
if self.RemainTime < 0 then
|
|
self.RemainTime = 0
|
|
end
|
|
end
|
|
end
|
|
|
|
--处理协议
|
|
function JZSLCopyLogic:OnMsgHandle(msg)
|
|
if msg.MsgID == GameCenter.Network.GetMsgID("MSG_HuaxinFlySword.ResSwordTombCopyInfo") then
|
|
self.WaitTime = msg.startTime
|
|
if self.WaitTime <= 0 then
|
|
self.SyncTime = Time.GetRealtimeSinceStartup()
|
|
self.SyncRemainTime = msg.endTime
|
|
else
|
|
GameCenter.ScreenCDSystem:ShowCDEffect(self.WaitTime, DataConfig.DataMessageString.Get("WarBeComing"));
|
|
end
|
|
--副本时间
|
|
self.RemainTime = msg.endTime;
|
|
self.IsFinish = false
|
|
self.SwordCfgId = msg.id
|
|
--加载动作
|
|
local _endAnim = self.PlayEndAnims[self.SwordCfgId]
|
|
if _endAnim ~= nil then
|
|
GameCenter.MapLogicSwitch:PutOnAnimation(self.LP, _endAnim)
|
|
end
|
|
|
|
self.AnimTimer = -1
|
|
local _cfg = DataConfig.DataFlySwordGrave[self.SwordCfgId]
|
|
if _cfg ~= nil then
|
|
self.IsHideCamera = false
|
|
self.AnimTimer = self.AnimTimes[self.SwordCfgId]
|
|
for i = 1, 36 do
|
|
if self.AnimGos[i] ~= nil then
|
|
self.AnimGos[i]:SetActive(self.SwordCfgId == i)
|
|
if self.SwordCfgId == i then
|
|
self.IsHideCamera = true
|
|
end
|
|
end
|
|
end
|
|
if self.IsHideCamera then
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_ADD_MAINCAMERA_HIDECOUNTER)
|
|
end
|
|
end
|
|
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLCopyMainForm_OPEN, self);
|
|
elseif msg.MsgID == GameCenter.Network.GetMsgID("MSG_HuaxinFlySword.ResSwordTombResult") then
|
|
GameCenter.GetNewItemSystem.PauseGetNewItemTips = true
|
|
--结算消息
|
|
self.CacheResultMsg = msg
|
|
local _cfg = DataConfig.DataFlySwordGrave[self.SwordCfgId]
|
|
if _cfg ~= nil then
|
|
if _cfg.Type == 1 and msg.success then
|
|
self:ChangeEndState(4)
|
|
else
|
|
self:ChangeEndState(5)
|
|
end
|
|
end
|
|
self.IsFinish = true
|
|
end
|
|
end
|
|
|
|
function JZSLCopyLogic:GetMainUIState()
|
|
return {
|
|
[MainFormSubPanel.PlayerHead] = true, --主角头像
|
|
[MainFormSubPanel.TargetHead] = true, --目标头像
|
|
[MainFormSubPanel.TopMenu] = true, --顶部菜单
|
|
[MainFormSubPanel.MiniMap] = true, --小地图
|
|
[MainFormSubPanel.FlySwordGrave] = true, --境界
|
|
[MainFormSubPanel.TaskAndTeam] = false, --任务和组队
|
|
[MainFormSubPanel.Joystick] = true, --摇杆
|
|
[MainFormSubPanel.Exp] = true, --经验
|
|
[MainFormSubPanel.MiniChat] = true, --小聊天框
|
|
[MainFormSubPanel.Skill] = true, --技能
|
|
[MainFormSubPanel.SelectPkMode] = true, --选择PK模式
|
|
[MainFormSubPanel.FunctionFly] = true, --新功能开启飞行界面
|
|
[MainFormSubPanel.FastPrompt] = true, --快速提醒界面
|
|
[MainFormSubPanel.FastBts] = true, --快速操作按钮界面
|
|
[MainFormSubPanel.Ping] = true, --ping
|
|
[MainFormSubPanel.SkillWarning] = false, --技能释放警示
|
|
[MainFormSubPanel.CustomBtn] = true, --自定义按钮
|
|
[MainFormSubPanel.SitDown] = false, --打坐
|
|
[MainFormSubPanel.RemotePlayerHead] = true, --远程玩家头像
|
|
[MainFormSubPanel.ChangeSkill] = true, --变身技能
|
|
}
|
|
end
|
|
|
|
function JZSLCopyLogic:GetMainLeftUIState()
|
|
return {
|
|
[MainLeftSubPanel.Task] = false, --任务分页
|
|
[MainLeftSubPanel.Team] = false, --队伍分页
|
|
[MainLeftSubPanel.Other] = false, --其他分页
|
|
}
|
|
end
|
|
|
|
function JZSLCopyLogic:ChangeEndState(state)
|
|
self.SwordGetState = state
|
|
if self.SwordGetState == 4 then
|
|
self.StateTimer = 0
|
|
GameCenter.MandateSystem:End()
|
|
self.LP.FightState = false
|
|
self.LP.IsCatching = true
|
|
self.LP.IsDuJieing = true
|
|
self.LP:UnLoadFlySword()
|
|
--卸载主角宠物
|
|
local _pet = GameCenter.GameSceneSystem:GetLocalPet()
|
|
if _pet ~= nil then
|
|
GameCenter.GameSceneSystem:RemoveRemoteEntity(_pet.ID)
|
|
end
|
|
--卸载主角魂甲和法宝
|
|
local _charList = GameCenter.LuaCharacterSystem.CharList
|
|
for i = #_charList, 1, -1 do
|
|
local _char = _charList[i]
|
|
GameCenter.GameSceneSystem:RemoveRemoteEntity(_char.CSChar.ID)
|
|
end
|
|
elseif self.SwordGetState == 1 then
|
|
self.StartDis = self.CameraControl.CurDis
|
|
self.StartYaw = 195
|
|
self.StartPitch = self.CameraControl.CurPitch
|
|
self.StartOffsetY = self.CameraControl.CurOffsetY
|
|
self.StartOffsetX = self.CameraControl.CurOffsetX
|
|
self.StartFov = self.CameraControl.CurFov
|
|
self.StateTimer = 0
|
|
self.CameraControl.FreeMode = true
|
|
self.LPStartRotY = self.LP.ModelTransform.localEulerAngles.y
|
|
if self.LPStartRotY > 0 then
|
|
self.LPStartRotY = self.LPStartRotY % 360
|
|
if self.LPStartRotY > 180 then
|
|
self.LPStartRotY = self.LPStartRotY - 360
|
|
end
|
|
elseif self.LPStartRotY < 0 then
|
|
self.LPStartRotY = self.LPStartRotY % 360
|
|
if self.LPStartRotY < -180 then
|
|
self.LPStartRotY = self.LPStartRotY + 360
|
|
end
|
|
end
|
|
self.LPEndRotY = 40
|
|
self.LP:UnLoadFlySword()
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSE_ALL_FORM, {"UIHUDForm", "UIMainForm", "UIMainFormPC", "UIGuideForm", "UIReliveForm", "UIMsgPromptForm", "UIMsgMarqueeForm", "UILoadingForm", "UICinematicForm", "UIGetEquipTIps", "UIPowerSaveForm", "UIPropertyChangeForm" })
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_MAIN_HIDEANIMATION)
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLCopyMainForm_CLOSE)
|
|
if self.LPStartRotY < self.LPEndRotY then
|
|
self.LP:PlayAnim("turnright", 0, 1)
|
|
else
|
|
self.LP:PlayAnim("turnleft", 0, 1)
|
|
end
|
|
elseif self.SwordGetState == 2 then
|
|
local _playAnim = self.PlayEndAnims[self.SwordCfgId]
|
|
self.SitDownAnimTime = 0
|
|
if _playAnim ~= nil then
|
|
self.LP:PlayAnim(_playAnim, 0, 1)
|
|
if self.LP.Skin ~= nil then
|
|
self.SitDownAnimTime = self.LP.Skin:GetAnimClipLength(_playAnim)
|
|
end
|
|
end
|
|
if self.SitDownAnimTime <= 0 then
|
|
self.SitDownAnimTime = 3
|
|
self.LP:PlayAnim("idle", 0, 2)
|
|
end
|
|
local _cfg = DataConfig.DataFlySwordGrave[self.SwordCfgId]
|
|
if _cfg ~= nil then
|
|
if self.LP.PropMoudle.FlySwordUID == 0 then
|
|
--还没有飞剑,造一把假飞剑
|
|
self.UseJiaFeiJian = true
|
|
self.LP.PropMoudle.FlySwordUID = 99
|
|
end
|
|
self.LP.PropMoudle.FlySwordCfgID = _cfg.FlySwordId
|
|
self.LP.PropMoudle.FlySwordSkillId = _cfg.FlySwordId
|
|
self.LP:LoadFlySword(true)
|
|
end
|
|
--玩家身上播放特效
|
|
local _vfxCfg = self.PlayerVfxs[self.SwordCfgId]
|
|
if _vfxCfg ~= nil then
|
|
local _playerId = self.LP.ID
|
|
for i = 1, #_vfxCfg do
|
|
GameCenter.MapLogicSwitch:PlayVfx(_playerId, ModelTypeCode.OtherVFX, _vfxCfg[i][2], _vfxCfg[i][1], FSkinPartCode.Body, true)
|
|
end
|
|
end
|
|
elseif self.SwordGetState == 3 then
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_MAIN_SHOWANIMATION)
|
|
local _cfg = DataConfig.DataFlySwordGrave[self.SwordCfgId]
|
|
if _cfg ~= nil then
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLActiveResultForm_OPEN, _cfg);
|
|
end
|
|
elseif self.SwordGetState == 5 then
|
|
self.StateTimer = 0
|
|
end
|
|
end
|
|
function JZSLCopyLogic:UpdateEndState(dt)
|
|
if self.SwordGetState == 0 then
|
|
if self.AnimTimer > 0 then
|
|
local _frontTime = self.AnimTimer
|
|
self.AnimTimer = self.AnimTimer - dt
|
|
if _frontTime > 2.5 and self.AnimTimer <= 2.5 then
|
|
for i = 1, 36 do
|
|
if self.VfxGos[i] ~= nil then
|
|
self.VfxGos[i]:SetActive(self.SwordCfgId == i)
|
|
end
|
|
end
|
|
end
|
|
if self.AnimTimer <= 0 then
|
|
for i = 1, 36 do
|
|
if self.AnimGos[i] ~= nil then
|
|
self.AnimGos[i]:SetActive(false)
|
|
end
|
|
end
|
|
--开始挂机
|
|
GameCenter.MandateSystem:Start()
|
|
if self.IsHideCamera then
|
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_DEC_MAINCAMERA_HIDECOUNTER)
|
|
end
|
|
self.IsHideCamera = false
|
|
|
|
local _mList = GameCenter.GameSceneSystem:FindMonsters()
|
|
local _mTableList = List:New(_mList)
|
|
for i = 1, #_mTableList do
|
|
_mTableList[i].IsShowModel = true
|
|
end
|
|
else
|
|
--隐藏所有怪物
|
|
local _mList = GameCenter.GameSceneSystem:FindMonsters()
|
|
local _mTableList = List:New(_mList)
|
|
for i = 1, #_mTableList do
|
|
_mTableList[i].IsShowModel = false
|
|
end
|
|
end
|
|
else
|
|
--强制自动挂机
|
|
if not GameCenter.MandateSystem:IsRunning() and not GameCenter.BlockingUpPromptSystem:IsRunning() then
|
|
GameCenter.MandateSystem:Start()
|
|
end
|
|
end
|
|
elseif self.SwordGetState == 4 then
|
|
self.StateTimer = self.StateTimer + dt
|
|
if self.StateTimer >= 3 then
|
|
self:ChangeEndState(1)
|
|
end
|
|
elseif self.SwordGetState == 1 then
|
|
self.StateTimer = self.StateTimer + dt
|
|
if self.StateTimer >= 0.7 then
|
|
self.CameraControl.CurDis = self.TargetDis
|
|
self.CameraControl.CurYaw = self.TargetYaw
|
|
self.CameraControl.CurPitch = self.TargetPitch
|
|
self.CameraControl.CurOffsetY = self.TargetOffsetY
|
|
self.CameraControl.CurOffsetX = self.TargetOffsetX
|
|
self.CameraControl.CurFov = self.TargetFov
|
|
self:ChangeEndState(2)
|
|
UnityUtils.SetLocalEulerAngles(self.LP.ModelTransform, 0, self.LPEndRotY, 0)
|
|
else
|
|
local _lerpValue = self.StateTimer / 0.7
|
|
self.CameraControl.CurDis = math.Lerp(self.StartDis, self.TargetDis, _lerpValue)
|
|
self.CameraControl.CurYaw = math.Lerp(self.StartYaw, self.TargetYaw, _lerpValue)
|
|
self.CameraControl.CurPitch = math.Lerp(self.StartPitch, self.TargetPitch, _lerpValue)
|
|
self.CameraControl.CurOffsetY = math.Lerp(self.StartOffsetY, self.TargetOffsetY, _lerpValue)
|
|
self.CameraControl.CurOffsetX = math.Lerp(self.StartOffsetX, self.TargetOffsetX, _lerpValue)
|
|
self.CameraControl.CurFov = math.Lerp(self.StartFov, self.TargetFov, _lerpValue)
|
|
|
|
local _rotY = math.Lerp(self.LPStartRotY, self.LPEndRotY, _lerpValue)
|
|
UnityUtils.SetLocalEulerAngles(self.LP.ModelTransform, 0, _rotY, 0)
|
|
end
|
|
elseif self.SwordGetState == 2 then
|
|
if self.SitDownAnimTime > 0 then
|
|
self.SitDownAnimTime = self.SitDownAnimTime - dt
|
|
if self.SitDownAnimTime <= 0 then
|
|
self:ChangeEndState(3)
|
|
end
|
|
end
|
|
elseif self.SwordGetState == 5 then
|
|
self.StateTimer = self.StateTimer + dt
|
|
if self.StateTimer >= 3 then
|
|
--弹出结算
|
|
if not self.CacheResultMsg.success then
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLResultForm_OPEN, self.CacheResultMsg)
|
|
else
|
|
GameCenter.PushFixEvent(UIEventDefine.UIJZSLActiveResultForm_OPEN, DataConfig.DataFlySwordGrave[self.SwordCfgId]);
|
|
end
|
|
self:ChangeEndState(0)
|
|
end
|
|
elseif self.SwordGetState == 3 then
|
|
end
|
|
end
|
|
|
|
return JZSLCopyLogic; |