Files
Main/Assets/GameAssets/Resources/Lua/Logic/MapLogicEx/MapLogicExSystem.lua

409 lines
19 KiB
Lua
Raw Normal View History

2025-01-25 04:38:09 +08:00
------------------------------------------------
--作者: 杨全福
--日期: 2019-04-15
--文件: MapLogicExSystem.lua
--模块: MapLogicExSystem
--描述: 地图逻辑类
------------------------------------------------
local L_WaterParams = require "Logic.TaskSystem.Data.WaterWaveParam"
--local ChatSystem = CS.Thousandto.Code.Center.GameCenter.ChatSystem
--构造函数
local MapLogicExSystem = {
MapId = 0,
MapCfg = nil, --当前所在场景配置
ActiveLogicMoudle = nil, --当前的副本逻辑文件名
ActiveLogic = nil, --当前激活的逻辑
CacheMsg = List:New(), --缓存的消息
MainUIState = nil, --主界面分页状态
LeftUIState = nil, --左侧分页状态
CopyFormUIState = nil, --副本分页状态
}
--进入场景处理
function MapLogicExSystem:OnEnterScene(mapId, isPlane)
--进入场景时清除地图设置
GameCenter.MapLogicSwitch:Reset()
GameCenter.GetNewItemSystem.PauseGetNewItemTips = false
--查找地图配置
self.MapId = mapId
self.MapCfg = DataConfig.DataMapsetting[mapId]
--创建逻辑脚本
self:NewMapLogic()
self.MainUIState = nil
self.LeftUIState = nil
self.CopyFormUIState = nil
--设置当前地图是否可以支援
if self.MapCfg and self.MapCfg.IfWorldSupport == 1 then
self.IsWorldSupport = true
else
self.IsWorldSupport = false
end
if self.ActiveLogic ~= nil then
local _closeLoading = true
if self.ActiveLogic.OnEnterScene ~= nil then
--进入场景处理
if self.ActiveLogic:OnEnterScene(self) == false then
_closeLoading = false
end
end
if self.ActiveLogic.GetMainUIState ~= nil then
self.MainUIState = self.ActiveLogic:GetMainUIState()
end
if self.MainUIState == nil then
self.MainUIState = self:GetMainUIState()
end
if self.ActiveLogic.GetMainLeftUIState ~= nil then
self.LeftUIState = self.ActiveLogic:GetMainLeftUIState()
end
if self.LeftUIState == nil then
self.LeftUIState = self:GetMainLeftUIState()
end
--设置主界面开关状态
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_MAIN_SUBPANELOPENSTATE)
--设置左侧组队和任务界面状态
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MAINLEFTSUBPABNELOPENSTATE)
if self.CopyFormUIState ~= nil then
GameCenter.MapLogicSwitch:SetCopyFormUIState(self.CopyFormUIState)
end
--处理缓存的消息
if self.ActiveLogic.OnMsgHandle ~= nil then
for i = 1, self.CacheMsg:Count() do
self.ActiveLogic:OnMsgHandle(self.CacheMsg[i])
end
end
self.CacheMsg:Clear()
self:OnSceneCinematicFinish(_closeLoading)
if not isPlane then
if self.MapCfg.PkState == 0 then
--不能PK
Utils.ShowPromptByEnum("C_ENTERMAPTIPS_SAFE")
GameCenter.ChatSystem:AddChat(4, DataConfig.DataMessageString.Get("C_ENTERMAPTIPS_SAFE"))
else
--可以PK
Utils.ShowPromptByEnum("C_ENTERMAPTIPS_WEIXIAN")
GameCenter.ChatSystem:AddChat(4, DataConfig.DataMessageString.Get("C_ENTERMAPTIPS_WEIXIAN"))
end
end
--设置屏幕水波纹
local _param = GameCenter.LuaTaskManager:GetWaterWaveParam()
if _param == nil then
_param = L_WaterParams:New()
end
if _param ~= nil then
if GameCenter.GameSetting:IsEnabled(GameSettingKeyCode.EnablePostEffect) then
if _param.DistanceFactor == 0 and _param.TimeFactor == 0 and _param.WaveWidth == 0 and _param.WaveSpeed ==
0 then
GameCenter.TaskController:ResumeForTransPort()
else
PostEffectManager.Instance:StopWaterWave()
PostEffectManager.Instance:PlayWaterWave(_param.distanceFactor, _param.timeFactor,
_param.totalFactor, _param.waveWidth, _param.waveSpeed, function()
GameCenter.TaskController:ResumeForTransPort()
end)
end
else
GameCenter.TaskController:ResumeForTransPort()
end
end
end
end
--离开场景处理
function MapLogicExSystem:OnLeaveScene(isPlane)
-- if self.MapCfg ~= nil then
-- Debug.Log("MapLogicExSystem:OnLeaveScene" .. self.MapCfg.MapId)
-- end
-- if self.MapCfg and self.MapCfg.IfNewguildCall == 1 then
-- GameCenter.PushFixEvent(UIEventDefine.UICallSoulForm_CLOSE)
-- end
if not isPlane then
if GameCenter.MapLogicSwitch.IsCopyMap then
--copy
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSE_ALL_FORM,
{"UIPanelCopyFailedForm", "UIHUDForm", "UIMainForm", "UIMainFormPC", "UIGuideForm", "UIReliveForm", "UIMsgPromptForm", "UIMsgMarqueeForm", "UILoadingForm", "UICinematicForm", "UIGetEquipTIps", "UIPowerSaveForm", "UIPropertyChangeForm" })
else
--normal
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSE_ALL_FORM,
{"UIPanelCopyFailedForm", "UIReliveForm", "UIHUDForm", "UIMainForm", "UIMainFormPC", "UIGuideForm", "UICopyTeamAskForm", "UICopyTeamPrepareForm", "UICrossMatchingForm", "UILoadingForm", "UIMsgPromptForm", "UIMsgMarqueeForm", "UICinematicForm", "UICopyMapResultExForm", "UIGetEquipTIps", "UIPowerSaveForm", "UIPropertyChangeForm" })
end
end
--切换地图关闭巅峰竞技匹配
local _msg = ReqMsg.MSG_Peak.ReqCancelPeakMatch:New()
_msg:Send()
if self.ActiveLogic ~= nil and self.ActiveLogic.OnLeaveScene ~= nil then
--离开场景处理
self.ActiveLogic:OnLeaveScene()
end
self.ActiveLogic = nil
if self.ActiveLogicMoudle ~= nil then
--卸载脚本
Utils.RemoveRequiredByName(self.ActiveLogicMoudle)
self.ActiveLogicMoudle = nil
end
self.MapId = 0
self.MapCfg = nil
self.CacheMsg:Clear()
self.MainUIState = nil
self.LeftUIState = nil
self.CopyFormUIState = nil
--清空立即前往BOSS所在地system的配置表ID以免其他系统误用
GameCenter.BossInfoTipsSystem.CustomCfgID = 0
GameCenter.LuaCharacterSystem:OnLeaveScene()
end
--更新
function MapLogicExSystem:Update(dt)
if self.ActiveLogic ~= nil and self.ActiveLogic.Update ~= nil then
self.ActiveLogic:Update(dt)
end
end
--创建地图逻辑处理类
function MapLogicExSystem:NewMapLogic()
if self.MapCfg.MapLogicType == MapLogicTypeDefine.WanYaoTa then
self.ActiveLogicMoudle = "Logic.MapLogicEx.WanYaoTa.WanYaoTaLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.DaNengYiFu then
self.ActiveLogicMoudle = "Logic.MapLogicEx.DaNengYiFu.DaNengYiFuLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XianJieZhiMen then
self.ActiveLogicMoudle = "Logic.MapLogicEx.XianJieZhiMen.XianJieZhiMenLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.PlaneCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.PlaneCopy.PlaneCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.YZZDCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.YZZDCopy.YZZDMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.SZZQCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.SZZQLogic.SZZQMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.FuDiCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.FuDiCopy.FuDiLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.FuDiDuoBaoCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.FuDiCopy.FuDiDuoBaoLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.MySelfBossCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.MySelfBoss.MySelfBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.WorldBossCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.NewWorldBoss.NewWorldBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.SuitGemCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.NewWorldBoss.SuitGemBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.MarryQingYuanCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.MarryCopy.MarryQingYuanCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.WuXianBossCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.NewWorldBoss.WuXianBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ArenaShouXi then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ArenaShouXi.ArenaShouXiLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.LvDuPanelCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.PlaneCopy.LvDuPlaneCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.SkyDoorCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.SkyDoor.SkyDoorMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ExpCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ExpCopy.ExpCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.WuXingCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ManyCopy.WuXingCopyMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XinMoCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ManyCopy.XinMoCopyMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.GuardianFaction then
self.ActiveLogicMoudle = "Logic.MapLogicEx.GuardianFaction.GuardianFactionLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.MonsterLand then
self.ActiveLogicMoudle = "Logic.MapLogicEx.HunShouShenLin.HunShouShenLinLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.RealmExpMap then
self.ActiveLogicMoudle = "Logic.MapLogicEx.RealmExpMap.RealmExpMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.StatureBossCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.StatureBoss.StatureBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ShanMen then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ShanMenMap.ShanMenMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.DuJieCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.DuJieCopy.DuJieCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.CeShiCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.CeShiCopy.CeShiCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.TerritorialWar then
self.ActiveLogicMoudle = "Logic.MapLogicEx.TerritorialWar.TerritorialWarLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.MarryCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.MarryCopy.MarryCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.BaJiZhenCopy then
self.ActiveLogicMoudle = "Logic/MapLogicEx/BaJiZhen/BaJiZhenLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.WorldBonfire then
self.ActiveLogicMoudle = "Logic/MapLogicEx/WorldBonfire/WorldBonfireLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ChuanDaoCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ChuanDaoCopy.ChuanDaoCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.GuildTaskCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.GuildTaskCopy.GuildTaskCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XmFight then
self.ActiveLogicMoudle = "Logic.MapLogicEx.XmFight.XmFightMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XMBoss then
self.ActiveLogicMoudle = "Logic.MapLogicEx.XMBoss.XMBossMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.WaoYaoJuanJieFeng then
self.ActiveLogicMoudle = "Logic.MapLogicEx.WYJJieFeng.WYJJieFengLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.NewComCopy then
--self.ActiveLogicMoudle = "Logic.MapLogicEx.NewWorldBoss.NewComLogic"
--新手层替换成普通的Boss逻辑
self.ActiveLogicMoudle = "Logic.MapLogicEx.NewWorldBoss.NewWorldBossLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ChangeJobCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.ChangeJobLogic.ChangeJocLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.SwordSoulCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.SwordSoulCopy.SwordSoulCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.JZSLCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.JZSLCopy.JZSLCopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.FirstFight then
self.ActiveLogicMoudle = "Logic.MapLogicEx.FirstFight.FirstFightLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.TopJjc then
self.ActiveLogicMoudle = "Logic.MapLogicEx.TopJjc.TopJjcLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.CrossFuDi then
self.ActiveLogicMoudle = "Logic.MapLogicEx.FuDiCopy.CrossFuDiLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.CrossMonutCopy then
self.ActiveLogicMoudle = "Logic.MapLogicEx.CrossMount.CrossMountLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.OyLieKai then
self.ActiveLogicMoudle = "Logic.MapLogicEx.FuDiCopy.OyLieKaiLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.SlayerMap then
self.ActiveLogicMoudle = "Logic.MapLogicEx.SlayerMap.SlayerMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XianFuHouse then
self.ActiveLogicMoudle = "Logic.MapLogicEx.XianFu.XianFuHouseMapLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.TopJjcWait then
self.ActiveLogicMoudle = "Logic.MapLogicEx.TopJjc.TopJjcWaitLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.ChangeJobBos1 then
self.ActiveLogicMoudle = "Logic.MapLogicEx.PlaneCopy.ChangeJobBoss1CopyLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.LoversFightFight then
self.ActiveLogicMoudle = "Logic.MapLogicEx.LoversFight.LoversFightFreelogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.LoversFightWait then
self.ActiveLogicMoudle = "Logic.MapLogicEx.LoversFight.LoversFightWaitLogic"
elseif self.MapCfg.MapLogicType == MapLogicTypeDefine.XuMiBaoKu then
self.ActiveLogicMoudle = "Logic.MapLogicEx.XuMiBaoKu.XuMiBaoKuLogic"
else
self.ActiveLogicMoudle = "Logic.MapLogicEx.Normal.NormalMapLogic"
end
if self.ActiveLogicMoudle ~= nil then
--注册副本逻辑脚本
self.ActiveLogic = require(self.ActiveLogicMoudle)
end
end
--处理协议
function MapLogicExSystem:OnMsgHandle(msg)
if self.ActiveLogic == nil then
--还未进入场景,缓存消息
self.CacheMsg:Add(msg)
else
--已经进入场景,直接处理消息
if self.ActiveLogic.OnMsgHandle ~= nil then
self.ActiveLogic:OnMsgHandle(msg)
end
end
end
--进入场景剧情播放完成
function MapLogicExSystem:OnSceneCinematicFinish(closeLoading)
if closeLoading then
--关闭loading
GameCenter.LoadingSystem:Close()
end
--引导检测
GameCenter.GuideSystem:Check(GuideTriggerType.EnterMap, self.MapCfg.MapId)
GameCenter.MainFunctionSystem:OnEnterScene()
GameCenter.CopyMapSystem:OnEnterScene()
GameCenter.DailyActivityTipsSystem:OnEnterScene(self.MapCfg)
GameCenter.AuctionHouseSystem:OnEnterScene()
GameCenter.CrossFuDiSystem:OnEnterScene()
GameCenter.WorldSupportSystem:OnEnterScene()
GameCenter.FuDiSystem:OnEnterScene()
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_ENTERMAP, self.MapCfg.MapId)
GameCenter.LuaCharacterSystem:OnEnterScene()
GameCenter.RankAwardSystem:OnEnterScene()
GameCenter.DailyActivitySystem:OnEnterScene()
if self.MapCfg.CanRiding == 0 then
--当前地图不能骑马,下马
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
if _lp ~= nil then
_lp:MountDown()
end
end
end
--发送离开地图消息
--askText为询问退出的内容不传则默认
function MapLogicExSystem:SendLeaveMapMsg(needAsk, askText)
if needAsk then
if askText ~= nil then
GameCenter.MsgPromptSystem:ShowMsgBox(askText, function(code)
if code == MsgBoxResultCode.Button2 then
self:DoLeaveMap()
end
end)
else
Utils.ShowMsgBox(function(code)
if code == MsgBoxResultCode.Button2 then
self:DoLeaveMap()
end
end, "C_COPY_EXIT_ASK")
end
else
self:DoLeaveMap()
end
end
--执行离开地图
function MapLogicExSystem:DoLeaveMap()
GameCenter.Network.Send("MSG_copyMap.ReqCopyMapOut", {})
if GameCenter.MapLogicSystem.MapCfg.MapLogicType == MapLogicTypeDefine.WuXingCopy then
GameCenter.BISystem:ReqClickEvent(BiIdCode.SLTLeaveChallengeing)
elseif GameCenter.MapLogicSystem.MapCfg.MapLogicType == MapLogicTypeDefine.XinMoCopy then
GameCenter.BISystem:ReqClickEvent(BiIdCode.XMHJLeaveChallengeing)
end
end
--离开地图是否给出提示
function MapLogicExSystem:IsShowExitPrompt()
if self.MapCfg ~= nil and self.MapCfg.IsLeave == 1 then
--弹出提示
Utils.ShowPromptByEnum("C_PLEASE_LEAVE_CURCOPY")
return true
end
return false
end
function MapLogicExSystem:GetMainUIState()
return {
[MainFormSubPanel.PlayerHead] = true, --主角头像
[MainFormSubPanel.TargetHead] = true, --目标头像
[MainFormSubPanel.TopMenu] = true, --顶部菜单
[MainFormSubPanel.MiniMap] = true, --小地图
[MainFormSubPanel.FlySwordGrave] = false, --境界
[MainFormSubPanel.TaskAndTeam] = true, --任务和组队
[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] = true, --打坐
[MainFormSubPanel.RemotePlayerHead] = true, --远程玩家头像
[MainFormSubPanel.ChangeSkill] = true, --变身技能
}
end
function MapLogicExSystem:GetMainLeftUIState()
return {
[MainLeftSubPanel.Task] = true, --任务分页
[MainLeftSubPanel.Team] = true, --队伍分页
[MainLeftSubPanel.Other] = false, --其他分页
}
end
return MapLogicExSystem