------------------------------------------------ --作者: 杨全福 --日期: 2019-05-13 --文件: WanYaoTaLogic.lua --模块: WanYaoTaLogic --描述: 万妖塔副本逻辑 ------------------------------------------------ local SlotUtils = CS.Thousandto.Core.Asset.SlotUtils local WanYaoTaLogic = { --父逻辑系统 Parent = nil, --剩余时间 RemainTime = 0.0, --当前层数 CurLevel = 0, --当前产生的总伤害 AllDamage = 0, --刷怪特效 MonsterFlyVfx = nil, --刷怪特效飞行时间 MonsterFlyVfxTime = -1, --刷怪等待时间 MonsterWaitTime = -1, --是否结束 IsFinish = false, SyncTime = 0, SyncRemainTime = 0, --怪物是否刷新,刷新了才会倒计时 MonsterIsBorn = false, --高度骨骼 HeightBones = nil, } function WanYaoTaLogic: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) --关掉副本界面 GameCenter.PushFixEvent(UIEventDefine.UICopyMapForm_CLOSE) self.IsShowEnterTips = false --进入就开始挂机 GameCenter.MandateSystem:Start() GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSE_ALL_FORM, {"UIHUDForm", "UIMainForm", "UIMainFormPC", "UIGuideForm", "UIReliveForm", "UIMsgPromptForm", "UIMsgMarqueeForm", "UILoadingForm", "UICinematicForm", "UIGetEquipTIps", "UIPowerSaveForm", "UIPropertyChangeForm" }) --注册高度更新脚本,使角色跟随场景高度变化 local _sceneRoot = GameObject.Find("SceneRoot").transform if _sceneRoot ~= nil then local _heightTrans = _sceneRoot:Find("wanyaojuan") if _heightTrans ~= nil then self.HeightBones = List:New() local _index = 0 while true do local _bone = SlotUtils.FindSlotTransform(_heightTrans, string.format("HeightBone%d", _index)) if _bone ~= nil then self.HeightBones:Add(_bone) _index = _index + 1 else break end end local _flyVfxTrans = _heightTrans:Find("[vfx]/map005FX_01") if _flyVfxTrans == nil then _flyVfxTrans = _heightTrans:Find("[vfx]/[far]/map005FX_01") end if _flyVfxTrans ~= nil then self.MonsterFlyVfx = _flyVfxTrans.gameObject self.MonsterFlyVfx:SetActive(false) end end end self.MonsterFlyVfxTime = -1 self.MonsterWaitTime = -1 local _scene = GameCenter.GameSceneSystem.ActivedScene self.CameraManager = _scene.CameraManager if self.CameraManager.CurCamera ~= nil then self.CameraManager.CurCamera.cullingMask = GameCenter.MapLogicSwitch:GetSceneChange1Layer() end end function WanYaoTaLogic:OnLeaveScene() --打开小地图功能 GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.AreaMap, true) --关闭主界面 GameCenter.PushFixEvent(UIEventDefine.UIWYTCopyMainForm_CLOSE) GameCenter.CopyMapSystem:ReqOpenStarPanel() --退出时关闭msgbox GameCenter.MsgPromptSystem:CloseMsgBox() --关闭结算界面 GameCenter.PushFixEvent(UIEventDefine.UIWYTResultForm_CLOSE) local _lpLevel = GameCenter.GameSceneSystem:GetLocalPlayerLevel() if _lpLevel > 140 then GameCenter.CopyMapSystem:SetEnterSceneOpenFunc(FunctionStartIdCode.TowerCopyMap) end --重置主角位置 GameCenter.MapLogicSwitch:SetSkinPartPos(GameCenter.GameSceneSystem:GetLocalPlayerID(), FSkinPartCode.Body, 0, 0, 0) end --播放出生特效 function WanYaoTaLogic:PlayBornVfx() self.MonsterFlyVfxTime = 6 self.MonsterWaitTime = 4.5 GameCenter.ScreenCDSystem:ShowCDEffect(3, DataConfig.DataMessageString.Get("WarBeComing")) end --更新 function WanYaoTaLogic:Update(dt) if self.MonsterIsBorn and not self.IsFinish then self.RemainTime = self.SyncRemainTime - (Time.GetRealtimeSinceStartup() - self.SyncTime) if self.RemainTime < 0 then self.RemainTime = 0 end end if self.MonsterFlyVfxTime > 0 then local _oldTimer = self.MonsterFlyVfxTime self.MonsterFlyVfxTime = self.MonsterFlyVfxTime - dt if _oldTimer >= 3.5 and self.MonsterFlyVfxTime < 3.5 then if self.MonsterFlyVfx ~= nil then self.MonsterFlyVfx:SetActive(false) self.MonsterFlyVfx:SetActive(true) end end if self.MonsterFlyVfxTime <= 0 then self.MonsterFlyVfxTime = -1 if self.MonsterFlyVfx ~= nil then self.MonsterFlyVfx:SetActive(false) end end end if self.MonsterWaitTime > 0 then self.MonsterWaitTime = self.MonsterWaitTime - dt if self.MonsterWaitTime <= 0 then self.MonsterWaitTime = -1 self.MonsterIsBorn = true self.SyncTime = Time.GetRealtimeSinceStartup() --发送刷怪消息 GameCenter.CopyMapSystem:ReqGoOnChallenge() end end if self.HeightBones ~= nil then GameCenter.MapLogicSwitch:ForEachDyanmicHeightCharacter(function(c) --先查找左右两根骨骼 local _curX = c.Position2d.x local _curY = c.Position2d.y local _rightBone = nil local _rightDis = 99999999 local _leftBone = nil local _leftDis = 99999999 for i = 1, #self.HeightBones do local _trans = self.HeightBones[i] local _transPos = _trans.position local _curDis = _transPos.x - _curX if _curDis >= 0 and _curDis < _rightDis then _rightBone = _trans _rightDis = _curDis; end if _curDis <= 0 and -_curDis < _leftDis then _leftBone = _trans _leftDis = -_curDis end end if _rightBone == nil or _leftBone == nil then return end local _lerpValue = (_curX - _leftBone.position.x) / (_rightBone.position.x - _leftBone.position.x) local _height = math.Lerp(_leftBone.position.y, _rightBone.position.y, _lerpValue) GameCenter.MapLogicSwitch:SetSkinPartPos(c.ID, FSkinPartCode.Body, _curX, _height, _curY) end) end end --处理协议 function WanYaoTaLogic:OnMsgHandle(msg) if msg.MsgID == GameCenter.Network.GetMsgID("MSG_copyMap.ResChallengeInfo") then self.SyncTime = Time.GetRealtimeSinceStartup() self.SyncRemainTime = msg.endTime --副本时间 self.RemainTime = msg.endTime; --当前关卡 self.CurLevel = msg.challengeLevel; local _copyData = GameCenter.CopyMapSystem:FindCopyDataByType(CopyMapTypeEnum.TowerCopy); if _copyData ~= nil then _copyData:OnFinishLevel(self.CurLevel); end self.IsFinish = false GameCenter.PushFixEvent(UIEventDefine.UIWYTCopyMainForm_OPEN, self); self.MonsterIsBorn = msg.refresh if not msg.refresh then --怪物还未刷新,播放动画 self:PlayBornVfx() end elseif msg.MsgID == GameCenter.Network.GetMsgID("MSG_copyMap.ResChallengeEndInfo") then GameCenter.GetNewItemSystem.PauseGetNewItemTips = true --结算消息 GameCenter.PushFixEvent(UIEventDefine.UIWYTResultForm_OPEN, msg); if msg.state == 1 then GameCenter.BISystem:ReqClickEvent(BiIdCode.WYJGeneralSucceed) elseif msg.state == 2 then GameCenter.BISystem:ReqClickEvent(BiIdCode.WYJPerfectSucceed) end self.IsFinish = true end end function WanYaoTaLogic: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 WanYaoTaLogic:GetMainLeftUIState() return { [MainLeftSubPanel.Task] = false, --任务分页 [MainLeftSubPanel.Team] = false, --队伍分页 [MainLeftSubPanel.Other] = false, --其他分页 } end return WanYaoTaLogic;