require("game.scene.MainCamera") require("game.scene.Scene") require("game.scene.SceneConfig") require("operation.OperateManager") require("game.mainUI.PreChangeSceneView") SceneManager = SceneManager or BaseClass(BaseModel) local SceneManager = SceneManager local GlobalEventSystem = GlobalEventSystem local SceneEventType = SceneEventType local table_remove = table.remove local table_insert = table.insert local math_sqrt = math.sqrt local math_pow = math.pow local math_acos = math.acos local math_floor = math.floor local math_pi = math.pi SceneManager.START = "SceneManager_event_start" SceneManager.DISPOSE ="SceneManager_event_dispose" function SceneManager:__init() if SceneManager.Instance ~= nil then LogError("SceneManager is a singleton class") end SceneManager.Instance = self self.client_role_num = 0 -- 当前客户端显示的角色数量 self.server_role_num = 0 -- 当前服务器显示的角色数量 self.role_limit_num = Config.otherFightInfo.scene_max_role_count -- 最大显示人数 self.scene_Info = nil --当前场景数据 self.last_scene_id = 0 --上一个场景ID self.curr_scene_id = 0 --当前场景ID self.next_scene_id = 0 --下一个场景ID self.last_dun_id = 0 --上一个副本id self.curr_dun_id = 0 --副本,0代表不是副本场景 self.npc_doors_loaded = false self.jumppoint_loaded = false self.isStart = false --场景是否加载完成 self.role_vo_list = {} --其他玩家 Vo列表 self.partner_vo_list = {} --伙伴Vo列表 self.monster_vo_list = {} --怪物 Vo列表(怪物的instance_id作为key) self.npc_vo_list = {} --Npc Vo列表(Npc的instance_id作为key) self.sceneNpcList = {} --当前场景的NPC,12100协议列表数据 self.door_vo_list = {} --门点 Vo列表(enter_scene_id作为key) self.monster_type_list = {} --怪物类型列表 self.monster_type_in_scenes = {} -- 每个场景里的所有怪物类型 self.jump_vo_list = {} --跳点对象列表 self.other_vo_list = {} --除了以上以外的一般场景对象 self.grave_vo_list = {} --怪物死亡墓碑vo列表 self.monster_vo_pool = Array.New() self.role_vo_pool = Array.New() self.delay_role_vo_list = {} -- 延迟创建角色 self.delay_monster_list = Array.New() --延迟加载的怪物列表 --主角中的嘲讽buff的发起者 self.chaofeng_attacker_compress_id = nil --被主角攻击过的玩家id self.mainRole_attacker_list = {} self.mainRole_attacker_count = 0 --攻击过主角的玩家id self.mainRole_defender_list = {} self.mainRole_defender_count = 0 --被主角杀死的怪物数量,当前只用于经验副本 self.mainRole_kill_monster_count = 0 --记录最近一次和其他玩家战斗的时间 self.last_role_attact_time = 0 --主角释放技能成功 服务端返回后的技能列表 记录每个主角技能等服务端返回后的时间 self.main_role_server_back_skill_list = {} self.clone_role_id_count = 0 self.clone_role_start_id = 274877906944 -- 2的38次方 self.killerName = "" --凶手名字 self.killerGuildName = "" --凶手社团名字 self.killerType = 0 --凶手的类型 1怪 2人 self.killerRoleId = 0 self.killerVo = nil --杀手信息 self.can_relive = 1 --是否能复活 self.next_relive_time = 0 --下次能复活的时间戳 self.last_fight_msg = {} --上一次给服务端发送的20001对象,副技能用 self.is_collect = false --是否在采集 self.is_no_loading_scene = false self.temp_check_list = {} --缓存的当前场景的判断列表 self.mat_prop_blocks = {} self.curr_frame_rate = FINAL_FRAMERATE --当前计算的平均帧频 self:InitPropBlocks() self.temp_monster_bounds_size = {} --缓存当前场景怪物模型的包围盒高度 self.set_model_limit_flag = true --部分多人玩法要开启外观限制 self.is_first_enter_tower_dun = false--爬塔副本第一次进入不需要无缝切换 self.curr_req_scene_id = false --当前正在请求切换场景的id self.record_pre_monster_data={} self.drop_pos_unit = 80--掉落位置单位数 self.mirror_scene_id = SceneActivityMirrorSceneId.None self.last_mirror_scene_id = SceneActivityMirrorSceneId.None self:InitDropPosCfg()--初始化掉落随机位置列表 self.camera_rotate_cfg = {} --场景摄像机旋转参数 end function SceneManager:getInstance() if SceneManager.Instance == nil then SceneManager.New() end return SceneManager.Instance end function SceneManager:InitPropBlocks( ) local blocks = Optimizer.CreateMatPropertyBlocks(20) for i=0, blocks.Length-1 do table.insert(self.mat_prop_blocks, blocks[i]) end end function SceneManager:PushPorpBlock( prop_block ) if self.mat_prop_blocks and prop_block then table.insert(self.mat_prop_blocks, prop_block) end end function SceneManager:PopPorpBlock() local prop_block = false if self.mat_prop_blocks then prop_block = table.remove(self.mat_prop_blocks) end if not prop_block then prop_block = Optimizer.CreateMatPropertyBlock() end return prop_block end function SceneManager:GetMonsterBoundsSize( type_id ) return self.temp_monster_bounds_size[type_id] end function SceneManager:SetMonsterBoundsSize( type_id, size_y ) self.temp_monster_bounds_size[type_id] = size_y end function SceneManager:SetLastPkTime( ) self.last_role_attact_time = TimeUtil:getServerTime() end function SceneManager:SetLastFightMsg(type,msg,att_object_id) self.last_fight_msg[type] = self.last_fight_msg[type] or {} if type == SceneBaseType.MainRole then self.last_fight_msg[type] = msg elseif type == SceneBaseType.Pokemon then self.last_fight_msg[type][att_object_id] = msg end end function SceneManager:GetLastFightMsg(type,att_object_id) if type == SceneBaseType.MainRole then return self.last_fight_msg[type] elseif type == SceneBaseType.Pokemon then if self.last_fight_msg[type] and self.last_fight_msg[type][att_object_id] then return self.last_fight_msg[type][att_object_id] end end end function SceneManager:SetKillerInfo(type, killerId) end function SceneManager:AddMainRoleBackSkill(skill_id) self.main_role_server_back_skill_list[skill_id] = Status.NowTime end function SceneManager:GetMainRoleBackSkillTime(skill_id) return self.main_role_server_back_skill_list[skill_id] end function SceneManager:RemoveMainRoleBackSkill(skill_id) self.main_role_server_back_skill_list[skill_id] = nil end function SceneManager:ClearMainRoleBackSkill() self.main_role_server_back_skill_list = {} end function SceneManager:AddMainRoleAttacker(role_id, skill_id) -- local attacker_info = self.mainRole_attacker_list[role_id] -- if attacker_info == nil then -- attacker_info = {start_time = Status.NowTime, skill_id = skill_id, attack_count = 1} -- self.mainRole_attacker_list[role_id] = attacker_info -- self.mainRole_attacker_count = self.mainRole_attacker_count + 1 -- local max_count = Config.otherFightInfo.mainRole_attacker_max_count -- if self.mainRole_attacker_count > max_count then -- local min_start_time = 99999 -- local min_role_id = nil -- for id, vo in pairs(self.mainRole_attacker_list) do -- if min_start_time > vo.start_time then -- min_start_time = vo.start_time -- min_role_id = id -- end -- end -- if min_role_id then -- self.mainRole_attacker_list[min_role_id] = nil -- end -- end -- else -- attacker_info.start_time = Status.NowTime -- if attacker_info.skill_id == skill_id then -- attacker_info.attack_count = attacker_info.attack_count + 1 -- else -- attacker_info.skill_id = skill_id -- attacker_info.attack_count = 1 -- end -- end end function SceneManager:AddMainRoleDefender(role_id) local defender_info = self.mainRole_defender_list[role_id] if defender_info == nil then defender_info = {start_time = Status.NowTime} self.mainRole_defender_list[role_id] = defender_info self.mainRole_defender_count = self.mainRole_defender_count + 1 local max_count = Config.otherFightInfo.mainRole_defender_max_count if self.mainRole_defender_count > max_count then local min_start_time = 99999 local min_role_id = nil for id, vo in pairs(self.mainRole_defender_list) do if min_start_time > vo.start_time then min_start_time = vo.start_time min_role_id = id end end if min_role_id then self.mainRole_defender_list[min_role_id] = nil end end -- if RoleManager.Instance.mainRoleInfo.pk_status == RoleVo.PK_STATUS.Peace then -- local role_vo = self:GetRoleVo(role_id) -- if role_vo then -- role_vo:ChangeVar("pk_status", role_vo.pk_status, nil, true) -- end -- end else defender_info.start_time = Status.NowTime end end function SceneManager:ClearMainRoleAttacker() self.mainRole_attacker_list = {} self.mainRole_attacker_count = 0 end function SceneManager:ResetMainRoleAttackerAttackCount() for id, info in pairs(self.mainRole_attacker_list) do info.attack_count = 0 end end function SceneManager:ClearMainRoleDefender() self.mainRole_defender_list = {} self.mainRole_defender_count = 0 end --被主角击杀的obj数量,用于经验副本和虚空秘境 function SceneManager:AddMainRoleKillCount(obj_type) if (SceneManager.Instance:IsAwakeScene() or SceneManager.Instance:IsExpScene()) and obj_type == SceneBaseType.Monster then self.mainRole_kill_monster_count = self.mainRole_kill_monster_count + 1 end end function SceneManager:ResetMainRoleKillMonsterCount() self.mainRole_kill_monster_count = 0 end --返回登录,清空一下数据 function SceneManager:GameStartClearCache() self.last_scene_id = 0 self.curr_scene_id = 0 self:SetCurrentReqChangeSceneId(false) self.curr_dun_id = 0 self:SetLastDunId( 0 ) end function SceneManager:SetCurrDunId(dun_id) self:SetLastDunId( self.curr_dun_id ) self.curr_dun_id = dun_id -- BaseDungeonModel:getInstance():InitDungeonInfo(self.curr_dun_id) -- if not (self.last_dun_id == self.curr_dun_id and self.last_dun_id > 0) then --不是同一个副本的切场景情况就要重置怒气 -- RoleManager.Instance.mainRoleInfo:ChangeVar("anger", 0, nil, true) -- end end function SceneManager:GetCurrDunId() return self.curr_dun_id or 0 end function SceneManager:SetCurrentSceneId(sceneId) self.last_scene_id = self.curr_scene_id self.curr_scene_id = sceneId self.scene_Info = self:GetSceneInfo(sceneId) self:SetCurrentReqChangeSceneId(false) self.temp_check_list = {} self.role_limit_num = 40 -- 最大显示人数 if self:IsMainCityAndFieldScene() then self.role_limit_num = 30 elseif self:IsGuildScene() then self.role_limit_num = 45 end end function SceneManager:SetCurrentReqChangeSceneId(sceneId) self.curr_req_scene_id = sceneId end function SceneManager:IsReqChangeScene() return self.curr_req_scene_id ~= false end function SceneManager:GetLastSceneId() return self.last_scene_id end function SceneManager:SetLastDunId( dun_id ) self.last_dun_id = dun_id or 0 --2020.4.27新增一个针对副本类任务的补充处理 --[[ 因 副本失败之后 需要 上次副本标记 来修复处理自动任务的重复进副本 引起 连续进同一个副本的任务且中间过程没有切地图的时候 第二次会中断任务 解决方式:61003返回副本成功之后重置 上次副本标记 --]] end function SceneManager:GetLastDunId() return self.last_dun_id end function SceneManager:GetSceneId() return self.curr_scene_id end function SceneManager:GetSceneName(sceneId) if sceneId then local data = self:GetSceneInfo(sceneId) if data then return data.name end else if self.scene_Info then return self.scene_Info.name end end return "" end function SceneManager:GetSceneType(sceneId) local scene_Info = self:GetSceneInfo(sceneId) return scene_Info and scene_Info.type or 0 end function SceneManager:GetSceneBirthPos(sceneId) local scene_Info = self:GetSceneInfo(sceneId) if scene_Info then return scene_Info.x, scene_Info.y end end function SceneManager:GetSceneInfo(sceneId) sceneId = sceneId or self:GetSceneId() if self.scene_Info and self.scene_Info.id == sceneId then return self.scene_Info end local data = ConfigItemMgr.Instance:GetSceneItem(sceneId) if not data and sceneId > 0 then Message.show("场景DB文件缺失数据,ID:" .. sceneId) end return data end function SceneManager:GetSceneNpcInfo(npcId, sceneId) local sceneId = sceneId or self:GetSceneId() local sceneInfo = self:GetSceneInfo(sceneId) if sceneInfo and type(sceneInfo.Npcs) == "table" then for npc_id, npc_info in pairs(sceneInfo.Npcs) do if tonumber(npc_id) == tonumber(npcId) then return npc_info end end end end --获取场景内的跳点配置 function SceneManager:GetSceneJumpPoints() if self.scene_Info == nil then return {} end local scene_id = self:GetSceneId() local jump_info = Config.JumpSceneInfo[scene_id] if jump_info == nil then return {} end return jump_info end function SceneManager:GetSceneDoors() if self.scene_Info == nil or self.scene_Info.Doors == nil then return {} end return self.scene_Info.Doors end function SceneManager:GetSceneDoorInfo(id, sceneId) sceneId = sceneId or self:GetSceneId() local sceneInfo = self:GetSceneInfo(sceneId) if sceneInfo == nil or sceneInfo.Doors == nil then return nil end return sceneInfo.Doors[id] end function SceneManager:ClearAllVo() self.isStart = false self:ClearMainRoleDefender() self:ClearMainRoleAttacker() self:ClearMainRoleBackSkill() self:ClearAllRoleVo() self:ClearAllMonsterVo() self:ClearAllPartnerVo() self:ClearAllOtherVo() self:ClearAllGraveVo() --场景有变化时才清空传送门和NPC if self:GetSceneId() ~= self.last_scene_id then self:ClearAllNpcVo() self:ClearAllDoorVo() self:ClearAllJumpPointVo() self.npc_doors_loaded = false self.jumppoint_loaded = false end self.monster_type_list = {} SceneManager.ResetCacheSceneType(self) GlobalEventSystem:Fire(SceneManager.DISPOSE) end function SceneManager:LoadJumpPoints() if self.jumppoint_loaded then return end local jumppoints = self:GetSceneJumpPoints() if jumppoints then for id, info in ipairs(jumppoints) do local jumppoint_vo = JumpPointVo.New() jumppoint_vo:CreateJumpPointInfo(id,info) self:AddJumpPointVo(jumppoint_vo) end end self.jumppoint_loaded = true end function SceneManager:LoadNpcsAndDoors() if self.npc_doors_loaded then return end local doors = self:GetSceneDoors() local doorId = 1 if doors then if SceneManager.Instance:IsIntrusionWorldHoneScene() then for id, info in pairs(doors) do local door_vo = DoorVo.New() door_vo:CreateDoorInfo(info) door_vo.id = doorId --流水id if IntrusionModel:getInstance().default_server_rank_list[door_vo.index] then doorId = doorId + 1 self:AddDoorVo(door_vo) end end else for id, info in pairs(doors) do local door_vo = DoorVo.New() door_vo:CreateDoorInfo(info) door_vo.id = doorId --流水id doorId = doorId + 1 self:AddDoorVo(door_vo) end local info = Config.ConfigDoorInSameScene[SceneManager.Instance:GetSceneId()] if info then for id, info in pairs(Config.ConfigDoorInSameScene[SceneManager.Instance:GetSceneId()]) do --在同一个场景里的传送门 local door_vo = DoorVo.New() door_vo:CreateDoorInfo(info) door_vo.id = doorId --流水id -- print("创建传送门 ",door_vo.id) -- door_vo.enter_scene_id = door_vo.enter_scene_id.."-"..door_vo.index door_vo.is_same_scene = true door_vo.enter_scene_name = info.name doorId = doorId + 1 self:AddDoorVo(door_vo) end end end end local npcs = self:GetNpcList() for id, info in pairs(npcs) do local npc_id = info.instance_id or info.npc_id if npc_id ~= 0 then if info.is_show == 0 then if self.npc_vo_list[npc_id] then self:DeleteNpcVo(npc_id) end else local npc_info = NpcVo.New() npc_info:CreateNpcInfo(info) self:AddNpcVo(npc_info) end end end self.npc_doors_loaded = true end function SceneManager:SceneStart() self.isStart = true self:TryFireStartEvent() end function SceneManager:TryFireStartEvent() if not self.isStart or GlobalEventSystem == nil then return end GlobalEventSystem:Fire(SceneManager.START) end function SceneManager:IsSceneStart() return self.isStart end function SceneManager:AddJumpPointVo( jump_vo) self.jump_vo_list[jump_vo.instance_id] = jump_vo GlobalEventSystem:Fire(SceneEventType.JUMPPOINT_VO_ADD, jump_vo) end function SceneManager:ClearAllJumpPointVo( ) for k, _ in pairs(self.jump_vo_list) do GlobalEventSystem:Fire(SceneEventType.JUMPPOINT_VO_REMOVE, k) end self.jump_vo_list = {} end --[[@ 功能: 添加一个门点信息到VoManager 参数: enter_scene_id 进入场景实例ID int32 door_vo 门点Vo结构体 Vo 返回值: 无 其它: 无 ]] function SceneManager:AddDoorVo( door_vo) local id = door_vo.enter_scene_id if door_vo.is_same_scene then id = door_vo.enter_scene_id.."-"..door_vo.index end self.door_vo_list[id] = door_vo GlobalEventSystem:Fire(SceneEventType.DOOR_VO_ADD, id, door_vo) end --[[@ 功能: 场景传送点 ]] function SceneManager:GetTheDoorVo( ) for k,v in pairs(self.door_vo_list) do return v end end --[[@ 功能: 根据进入场景ID获取一个门点信息 参数: enter_scene_id 进入场景实例ID int32 返回值: 对应的门点信息 Vo 其它: 无 ]] function SceneManager:GetDoorVo( enter_scene_id ) return self.door_vo_list[enter_scene_id] end function SceneManager:GetDoorVoList() return self.door_vo_list end function SceneManager:ClearAllDoorVo( ) for k,vo in pairs(self.door_vo_list) do -- local id = k -- if vo.is_same_scene then -- id = vo.enter_scene_id.."-"..vo.index -- end GlobalEventSystem:Fire(SceneEventType.DOOR_VO_REMOVE, k) end self.door_vo_list = {} end function SceneManager:GetNpcList() return self.sceneNpcList end function SceneManager:SetNpcList(list) self.sceneNpcList = list end function SceneManager:UpdateNpcListPos(npc_id, real_x, real_y) if self.sceneNpcList[npc_id] then self.sceneNpcList[npc_id].pos_x = real_x self.sceneNpcList[npc_id].pos_y = real_y end end function SceneManager:GetSceneNpcInfoByID( npc_id ) return self.sceneNpcList[npc_id] end --[[@ 功能: 添加一个Npc信息到Manger 参数: npc_ins_id Npc实例ID int32 npc_vo NpcVo信息 object 返回值: 无 其它: 无 ]] function SceneManager:AddNpcVo(npc_vo) self.npc_vo_list[npc_vo.instance_id] = npc_vo self.sceneNpcList[npc_vo.instance_id] = npc_vo GlobalEventSystem:Fire(SceneEventType.NPC_VO_ADD, npc_vo.instance_id, npc_vo) end function SceneManager:DynamicAddNpc(npcid,npc_x,npc_y, args) if npcid and npc_x and npc_y then local npc_info = NpcVo.New() local info = {npc_id = npcid, pos_x = npc_x, pos_y = npc_y, args = args} npc_info:CreateNpcInfo(info) npc_info.pos_x = npc_x --X坐标(int16) npc_info.pos_y = npc_y --Y坐标(int16) npc_info.logic_x = npc_info.pos_x / SceneObj.LogicRealRatio.x npc_info.logic_y = npc_info.pos_y / SceneObj.LogicRealRatio.y print("= = =添加NPC:", npc_info.pos_x, npc_info.pos_y) self:AddNpcVo(npc_info) end end --[[@ 功能: 动态删除Npc 参数: 返回值: 无 其它: 无 作者: deadline ]] function SceneManager:DynamicDelNpc(npcid) if self.npc_vo_list[npcid] then self:DeleteNpcVo(npcid) end end --[[@ 功能: 获取一个Npc信息 参数: npc_ins_id Npc实例ID int32 返回值: 获取到的Npc信息 其它: 无 ]] function SceneManager:GetNpcVo( npc_ins_id ) return self.npc_vo_list[npc_ins_id] end --[[@ 功能: 清除所有Npc Vo信息 参数: 无 返回值: 无 其它: 无 ]] function SceneManager:ClearAllNpcVo( ) for k,_ in pairs(self.npc_vo_list) do GlobalEventSystem:Fire(SceneEventType.NPC_VO_REMOVE, k) end self.npc_vo_list = {} end --[[ 功能:清除npc 其他. ]] function SceneManager:DeleteNpcVo(id) if self.npc_vo_list[id] ~= nil then GlobalEventSystem:Fire(SceneEventType.NPC_VO_REMOVE, id) end self.sceneNpcList[id] = nil self.npc_vo_list[id] = nil end --添加怪物类型 function SceneManager:AddMonsterType(monsterTypeVo) self.monster_type_list[monsterTypeVo.type_id] = monsterTypeVo end --[[ 功能:获取怪物类型vo 其他. ]] -- function SceneManager:GetMonsterType(type_id) -- return self.monster_type_list[type_id] -- end -- function SceneManager:GetAllMonsterTypes() -- return self.monster_type_list -- end --获取指定场景中的所有怪物类型 -- function SceneManager:GetMonsterTypeInScene(scene_id) -- self.monster_type_in_scenes = self.monster_type_in_scenes or {} -- local monster_types = self.monster_type_in_scenes[scene_id] -- return monster_types -- end -- function SceneManager:AddMonsterTypeInScene(scene_id, types) -- self.monster_type_in_scenes[scene_id] = types -- end --[[@ 功能: 添加一个怪物Vo信息到Manager 参数: ins_id 怪物实例ID int32 monster_vo 怪物Vo信息 MonsterVo isdelay 是否是 延迟加载 返回值: 无 其它: 无 ]] function SceneManager:AddMonsterVo( monster_vo, isdelay ) -- if self:GetMonsterType(monster_vo.type_id) == nil then -- local monsterTypeVo = MonsterTypeVo.New() -- monsterTypeVo.type_id = monster_vo.type_id -- monsterTypeVo.name = monster_vo.name -- monsterTypeVo.type = monster_vo.type -- monsterTypeVo.pos_x = monster_vo.pos_x -- monsterTypeVo.pos_y = monster_vo.pos_y -- monsterTypeVo.level = monster_vo.level -- monsterTypeVo.guaji_flag = monster_vo.guaji_flag -- monsterTypeVo.boss_type = monster_vo.boss_type -- monsterTypeVo.res_id = monster_vo.monster_res -- self:AddMonsterType(monsterTypeVo) -- end if self:IsInRecordPreMonsterData(monster_vo.instance_id) then if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].name then monster_vo.name = self.record_pre_monster_data[monster_vo.instance_id].name end if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].level then monster_vo.level = self.record_pre_monster_data[monster_vo.instance_id].level end if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].hp then monster_vo.hp = self.record_pre_monster_data[monster_vo.instance_id].hp end if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].maxHp then monster_vo.maxHp = self.record_pre_monster_data[monster_vo.instance_id].maxHp end end isdelay = isdelay or false if isdelay == true and monster_vo.load_immediately ~= 1 then --延迟加载 self.delay_monster_list:PushBack(monster_vo) else self.monster_vo_list[monster_vo.instance_id] = monster_vo GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_ADD, monster_vo.instance_id, monster_vo) end end --12090 怪物改名,改名可能比创怪完毕更早来,没找到对象时先记录一下 ,创怪时再重新赋值 function SceneManager:RecordPreMonsterData(instance_id,data) self.record_pre_monster_data[instance_id] = self.record_pre_monster_data[instance_id] or {} self.record_pre_monster_data[instance_id].id = instance_id if data.name then self.record_pre_monster_data[instance_id].name = data.name end if data.level then self.record_pre_monster_data[instance_id].level = data.level end if data.hp then self.record_pre_monster_data[instance_id].hp = data.hp end if data.maxHp then self.record_pre_monster_data[instance_id].maxHp = data.maxHp end end function SceneManager:IsInRecordPreMonsterData(instance_id) for k,v in pairs(self.record_pre_monster_data) do if instance_id == v.id then return true end end return false end function SceneManager:ClearRecordPreMonsterData(instance_id) if self.record_pre_monster_data and self.record_pre_monster_data[instance_id] then self.record_pre_monster_data[instance_id] = nil end end --[[@ 功能: 根据怪物实例ID获取怪物Vo信息 参数: ins_id 怪物实例ID int32 返回值: 怪物Vo信息 MonsterVo 其它: 无 ]] function SceneManager:GetMonsterVo( ins_id ) return self.monster_vo_list[ins_id] end --删除指定类型的怪物 function SceneManager:DeleteMonstersByType(type_id) for i, v in pairs(self.monster_vo_list) do if v.type_id == type_id and not v.is_client_monster then self:DeleteMonsterVo(v.instance_id, SceneManager.DELETE_MONSTER_BY_TYPE) end end end --根据唯一id 获取客户端剧情怪物 function SceneManager:GetClientMonsterVoByInstanceId(ins_id) local monster_vo = self.monster_vo_list[ins_id] if monster_vo and monster_vo.is_client_monster then return monster_vo end return nil end --删除指定类型的怪物,用于剧情 function SceneManager:DeleteClientMonstersByInstanceId(ins_id) local monster_vo = self.monster_vo_list[ins_id] if monster_vo and monster_vo.is_client_monster then self:DeleteMonsterVo(ins_id, SceneManager.DELETE_MONSTER_BY_TYPE) end end --删除指定类型的怪物,用于剧情 function SceneManager:DeleteClientMonstersByType(type_id) for i, v in pairs(self.monster_vo_list) do if v.type_id == type_id and v.is_client_monster then self:DeleteMonsterVo(v.instance_id, SceneManager.DELETE_MONSTER_BY_TYPE) end end end function SceneManager:GetClientMonsterVoByTypeId(type_id) for id, monster_vo in pairs(self.monster_vo_list) do if monster_vo.type_id == type_id and monster_vo.is_client_monster then return monster_vo end end return nil end function SceneManager:GetMonsterVoByTypeId(type_id) for id, monster_vo in pairs(self.monster_vo_list) do if monster_vo.type_id == type_id then return monster_vo end end local size = self.delay_monster_list:GetSize() if size > 0 then for index = 0, size - 1 do local monster_vo = self.delay_monster_list:Get(index) if monster_vo.type_id == type_id then return monster_vo end end end return nil end --获取随机一个不等于not_instance_id的怪物 function SceneManager:GetRandomMonsterVoByTypeId(type_id, not_instance_id) local tb = {} for id, monster_vo in pairs(self.monster_vo_list) do if monster_vo.type_id == type_id then table_insert(tb, monster_vo) end end if #tb > 1 then local times = 0 while times<1000 do times = times + 1 local rand = math.random(1, #tb) if tb[rand] and tb[rand].instance_id~=not_instance_id then return tb[rand] end end elseif #tb==1 and tb[1].instance_id~=not_instance_id then --只有一只怪物 return tb[1] end return nil end function SceneManager:GetDelayMonsterVo(ins_id) local size = self.delay_monster_list:GetSize() if size > 0 then for index = 0, size - 1 do local info = self.delay_monster_list:Get(index) if info and ins_id == info.instance_id then return info end end end end function SceneManager:GetDelayMonsterNum() local size = self.delay_monster_list:GetSize() return size end --从延迟加载列表中取一个vo并创建 function SceneManager:AddDelaydMonsterVo() local size = self.delay_monster_list:GetSize() if size > 0 then local vo = self.delay_monster_list:PopFront() self:AddMonsterVo(vo) end end --[[@ 功能: 根据怪物实例ID移除一个怪物Vo信息 参数: ins_id 怪物实例ID int32 返回值: 无 其它: 无 ]] SceneManager.DELETE_MONSTER_WAVE_RESET = 1 SceneManager.DELETE_MONSTER_BATTLE_GROUND = 2 SceneManager.DELETE_MONSTER_OUTLAND_WAR = 3 SceneManager.DELETE_MONSTER_RESULT_VIEW = 4 SceneManager.DELETE_MONSTER_DEAD = 5 SceneManager.DELETE_MONSTER_12006 = 6 SceneManager.DELETE_MONSTER_BY_TYPE = 7 SceneManager.DELETE_MONSTER_FIGHT_ERROR = 8 SceneManager.DELETE_MONSTER_AI = 9 function SceneManager:DeleteMonsterVo( ins_id , delete_type) local size = self.delay_monster_list:GetSize() local vo = self.monster_vo_list[ins_id] local type_id = vo and vo.type_id if vo == nil then if size > 0 then for index = 0, size - 1 do local info = self.delay_monster_list:Get(index) if info and ins_id == info.instance_id then type_id = info.type_id self.delay_monster_list:Erase(index) break end end end else self:ClearRecordPreMonsterData(ins_id) self.monster_vo_list[ins_id] = nil end if vo then GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_REMOVE, ins_id, type_id,vo) end return vo end function SceneManager:GetAllMonsterVo() return self.monster_vo_list end function SceneManager:ClearAllMonsterVo() for k, vo in pairs(self.monster_vo_list) do GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_REMOVE, vo.instance_id, vo.type_id,vo) end self.delay_monster_list = Array.New() --延迟加载的怪物列表 self.monster_vo_list = {} end function SceneManager:AddMonsterVoPool(vo) if self.monster_vo_pool:GetSize() < 40 then vo:ResetData() self.monster_vo_pool:PushBack(vo) end end function SceneManager:CreateMonsterVo() if self.monster_vo_pool:GetSize() > 0 then return self.monster_vo_pool:PopFront() end return MonsterVo.New() end function SceneManager:AddRoleVoPool(vo) if self.role_vo_pool:GetSize() < 40 then vo:ResetData() self.role_vo_pool:PushBack(vo) end end function SceneManager:CreateRoleVo() if self.role_vo_pool:GetSize() > 0 then return self.role_vo_pool:PopFront() end return RoleVo.New() end function SceneManager:AddOtherVo(other_vo) self.other_vo_list[other_vo.instance_id] = other_vo GlobalEventSystem:Fire(SceneEventType.OTHER_VO_ADD, other_vo.instance_id, other_vo) end function SceneManager:GetOtherVo( ins_id ) return self.other_vo_list[ins_id] end function SceneManager:DeleteOtherVo( ins_id) local vo = self:GetOtherVo(ins_id) if vo then self.other_vo_list[ins_id] = nil GlobalEventSystem:Fire(SceneEventType.OTHER_VO_REMOVE, ins_id, vo) return vo end end function SceneManager:GetAllOtherVo() return self.other_vo_list end function SceneManager:ClearAllOtherVo() for k, vo in pairs(self.other_vo_list) do GlobalEventSystem:Fire(SceneEventType.OTHER_VO_REMOVE, vo.instance_id, vo) end self.other_vo_list = {} end function SceneManager:getMonsterList() local ret = {} for _, vo in pairs(self.monster_vo_list) do table_insert(ret, vo) end local size = self.delay_monster_list:GetSize() if size > 0 then for index = 0, size - 1 do local vo = self.delay_monster_list:Get(index) table_insert(ret, vo) end end return ret end --重置缓存角色vo的队列 function SceneManager:ResetCachedRoleList() self:ClearDelayAllRoleVo() -- 清空 延迟加载的玩家数据 end function SceneManager:AddRoleVo(role_vo, is_from_server) local role_id = role_vo.role_id local main_role_id = RoleManager.Instance:GetMainRoleId() if role_id == main_role_id then RoleManager.Instance.mainRoleInfo:ChangeFromVo(role_vo) self.server_role_num = self.server_role_num + 1 return end --如果是从服务端发来的角色信息,就把角色vo缓存起来,分帧创建,切换场景清空 if is_from_server then if self.role_vo_list[role_id] == nil then --新增的情况数量加一 self.server_role_num = self.server_role_num + 1 self:AddDelayRoleTable(role_vo) return end end if self.role_vo_list[role_id] == nil then --新增的情况数量加一 self.client_role_num = self.client_role_num + 1 end self.role_vo_list[role_id] = role_vo EventSystem.Fire(GlobalEventSystem,SceneEventType.ROLE_VO_ADD, role_id, role_vo) role_vo.particle_priority = 2 end --[[@ 功能: 根据联合ID获取一个角色信息 参数: role_id 角色联合ID int32 返回值: 角色信息 RoleVo 其它: 无 作者: deadline ]] function SceneManager:GetRoleVo( role_id ) if role_id == RoleManager.Instance:GetMainRoleId() then return RoleManager.Instance.mainRoleInfo else return self.role_vo_list[role_id] end end --[[ 功能:获取所有角色信息 参数:角色信息列表 其他:无 作者:xinyy ]] function SceneManager:GetAllRoleVos( ) return self.role_vo_list end --[[@ 功能: 根据联合ID从Manager中移除一个角色信息 参数: role_id 角色联合ID int32 返回值: 无 其它: 无 作者: deadline ]] function SceneManager:DeleteRoleVo( role_id ) if role_id == RoleManager.Instance:GetMainRoleId() then return end --删除延迟加载列表 self:DeleteDelayRoleVo(role_id) if self.role_vo_list[role_id] ~= nil then self.server_role_num = self.server_role_num - 1 self.client_role_num = self.client_role_num - 1 self.role_vo_list[role_id] = nil GlobalEventSystem:Fire(SceneEventType.ROLE_VO_REMOVE, role_id) end end --[[@ 功能: 移除所有角色信息 参数: 无 返回值: 无 其它: 无 作者: deadline ]] function SceneManager:ClearAllRoleVo( ) for k, _ in pairs(self.role_vo_list) do GlobalEventSystem:Fire(SceneEventType.ROLE_VO_REMOVE, k) end self.role_vo_list = {} self.client_role_num = 0 self.server_role_num = 0 end --立马加载角色 function SceneManager:ImmeAddRoleVo(role_id) local delay_role_len = #self.delay_role_vo_list local vo = nil for i = 1, delay_role_len do vo = self.delay_role_vo_list[i] if vo.role_id == role_id then table_remove(self.delay_role_vo_list, i) self:AddRoleVo(vo) return end end end -- 分帧加载玩家 function SceneManager:AddDelayRoleTable( role ) table_insert(self.delay_role_vo_list, role) end function SceneManager:AddDelayRoleVo() --限制场景最大数量 if self.client_role_num >= self.role_limit_num then return end local n = #self.delay_role_vo_list if n > 0 then local role_vo = self.delay_role_vo_list[n] self.delay_role_vo_list[n] = nil self:AddRoleVo(role_vo) end end --删除延迟加载列表 function SceneManager:DeleteDelayRoleVo(role_id) local delay_role_len = #self.delay_role_vo_list local vo = nil for i = 1, delay_role_len do vo = self.delay_role_vo_list[i] if vo.role_id == role_id then table_remove(self.delay_role_vo_list,i) break end end end -- 2020年9月12日新增 某些状态改变的逻辑要获取到未加载的vo function SceneManager:GetDelayRoleVo(role_id) local delay_role_len = #self.delay_role_vo_list local vo = nil for i = 1, delay_role_len do vo = self.delay_role_vo_list[i] if vo.role_id == role_id then return vo end end return nil end function SceneManager:GetDelayRoleNum() return #self.delay_role_vo_list end function SceneManager:ClearDelayAllRoleVo() self.delay_role_vo_list = {} end --获取除了主角以外的场景对象 function SceneManager:GetSceneObjVo(instance_id) local vo = SceneManager.Instance:GetMonsterVo(instance_id) if vo then return vo, SceneBaseType.Monster end vo = SceneManager.Instance:GetRoleVo(instance_id) or SceneManager.Instance:GetOtherVo(instance_id) return vo end --创建分身 function SceneManager:CreateCloneRole(role_id, x, y, horse_id, birth_angle, name, head_wear_id) local mvo = self:GetRoleVo(role_id) if mvo == nil then print("分身的主体死了,不能再创建分身") return end local vo = RoleVo.New() self.clone_role_id_count = self.clone_role_id_count + 1 vo.role_id = self.clone_role_start_id + self.clone_role_id_count --用户ID(int32) vo.plat_name = mvo.plat_name --平台名(string) vo.server_id = mvo.server_id --服ID(int16) vo.name = name or "" --玩家名(string) vo.pos_x = x or mvo.pos_x --X像素坐标(int16) vo.pos_y = y or mvo.pos_y --Y像素坐标(int16) vo.level = 1 vo.hp = mvo.hp vo.maxHp = mvo.maxHp vo.career = mvo.career vo.move_speed = mvo.move_speed vo.vip_flag = mvo.vip_flag vo.fighting = mvo.fighting vo.imageId = mvo.imageId vo.warGroup = mvo.warGroup vo.head_wear_id = mvo.head_wear_id vo.birth_angle = birth_angle or 0 vo.fashion_model_list = mvo.fashion_model_list vo.level_model_list = mvo.level_model_list vo.horse_id = horse_id vo.is_ride = 1 vo.is_virtual_friend = true vo.create_time = Status.NowTime self:AddRoleVo(vo) return vo.role_id end function SceneManager:AddPartnerVo(partner_vo) local partner_id = partner_vo.partner_id self.partner_vo_list[partner_id] = partner_vo GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_ADD, partner_id, partner_vo) partner_vo.particle_priority = 2 end function SceneManager:GetPartnerVo( partner_id ) return self.partner_vo_list[partner_id] end function SceneManager:GetAllPartnerVos( ) return self.partner_vo_list end function SceneManager:DeletePartnerVo( partner_id ) local vo = self:GetPartnerVo(partner_id) if vo ~= nil then self.partner_vo_list[partner_id] = nil GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_REMOVE, partner_id) return vo end end function SceneManager:ClearAllPartnerVo( ) for k, _ in pairs(self.partner_vo_list) do GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_REMOVE, k) end self.partner_vo_list = {} end function SceneManager:IsBlockXY(x, y, jump_state) local state = MapView:getInstance():IsBlockXY(x,y,jump_state) return state end function SceneManager:IsAreaType(x, y, area_type) local state = MapView:getInstance():IsAreaType(x,y,area_type) return state end function SceneManager:CheckIsInScreen(x, y) local camera_pos = MainCamera.Instance:GetCameraPos() local ratio = MainCamera.Instance:GetCameraRatio() -- print(x,y,camera_pos.x,camera_pos.y,camera_pos.x - ScreenWidth * 0.5 * ratio,camera_pos.x + ScreenWidth * 0.5 * ratio,camera_pos.y - ScreenHeight * 0.3 * ratio,camera_pos.y + ScreenHeight * 0.8 * ratio) if x < (camera_pos.x - ScreenWidth * 0.5 * ratio) or x > (camera_pos.x + ScreenWidth * 0.5 * ratio) or y < (camera_pos.y - ScreenHeight * 0.8 * ratio) or y > (camera_pos.y + ScreenHeight * 1 * ratio) then return false end return true end function SceneManager:GetAngle(pos1, pos2, real_pos) local x = 0 local y = 0 if real_pos then x = pos2.x - pos1.x y = pos2.y - pos1.y else x = pos1 y = pos2 end local hyp = math_sqrt(math_pow(x, 2) + math_pow(y, 2)) if hyp == 0 then return 0 end local cos = x / hyp local radian = math_acos(cos) if radian == 0 then return 0 end local angle = 180 / (math_pi / radian) if y < 0 then angle = 360 - angle end return math_floor(angle + 0.5) end --得到textureshader 普通模型的默认shader 无alpha透明通道 function SceneManager:GetTextureShader() if self.texture_shader == nil then self.texture_shader = Shader.Find( "Unlit/Texture") end return self.texture_shader end --得到Alphatextureshader 有alpha透明通道 已经可以更改颜色 function SceneManager:GetColorTextureShader() if self.color_texture_shader == nil then self.color_texture_shader = ShaderTools.GetShader("Alpha_shader") end return self.color_texture_shader end --变灰shader function SceneManager:GetGrayShader() if self.gray_shader == nil then self.gray_shader = ShaderTools.GetShader("Gray_level_shader") end return self.gray_shader end function SceneManager:SetGrayShader(monster_id,material,shader) shader = shader or self:GetGrayShader() if monster_id and material then material.shader = shader local config = Config.ConfigModelGray.info[monster_id] or Config.ConfigModelGray.info.default if config then --Unlit - Texture 自带一个灰度颜色,要重置 material:SetColor("_Color",Color(1,1,1,1)) material:SetFloat("_inBlack",config.input_black) material:SetFloat("_inGamma",config.input_gamma) material:SetFloat("_inWhite",config.input_white) material:SetFloat("_outWhite",config.output_white) material:SetFloat("_outBlack",config.output_black) end end end --[[ --模型UI遮罩Shader 根据本身shader,获取对应的遮罩shader function SceneManager:GetModelMaskShader(cur_shader_name) if cur_shader_name == "Unlit/Texture" or cur_shader_name == "Unlit/AlphaTexture" then self.modelMask_shader = ShaderTools.GetShader("Unlit_Texture_Mask") --普通无光材质 elseif cur_shader_name == "Custom/mb_flowalphablendmask" or cur_shader_name == "Custom/mb_flowalphablendmask_transparentculloff" or cur_shader_name == "Custom/mb_flowalphablendmaskui" then self.modelMask_shader = ShaderTools.GetShader("mb_flowalphablendmask_mask") --波塞冬的水波纹材质 elseif cur_shader_name == "Custom/mb_uvrolladd_culloff" then self.modelMask_shader = ShaderTools.GetShader("mb_uvrolladd_culloff_mask") elseif cur_shader_name == "Custom/mb_uvrollalphablend_culloff" or cur_shader_name == "Custom/mb_uvrollalphablend" then self.modelMask_shader = ShaderTools.GetShader("mb_uvrollalphablend_culloff_mask") elseif cur_shader_name == "Particles/Additive" or cur_shader_name == "Mobile/Particles/Additive" or cur_shader_name == "NoFog/Particles/Additive" then self.modelMask_shader = ShaderTools.GetShader("ParticleAdd_mask") elseif cur_shader_name == "Particles/Blend" then self.modelMask_shader = ShaderTools.GetShader("ParticleBlend_mask") elseif cur_shader_name == "Particles/Alpha Blended" or cur_shader_name == "Mobile/Particles/Alpha Blended" or cur_shader_name == "NoFog/Particles/Alpha Blended"or cur_shader_name == "NoFog/Mobile/Particles/Alpha Blended" then self.modelMask_shader = ShaderTools.GetShader("ParticleAlphaBlend_mask") elseif cur_shader_name == "Custom/mb_uvrolladd" then self.modelMask_shader = ShaderTools.GetShader("mb_uvrolladd_mask") else return nil end return self.modelMask_shader end --设置UI遮罩模型 -- mask_img ui遮罩 -- model_root 需要遮罩的模型根对象 -- part_name 需要遮罩的模型部件,因为有些模型是有很多挂件的,比如武器,翅膀,可以针对模型的部件进行遮罩 -- mask_Tex 遮罩的mask,如果不传,默认用 mask_img 的sprite function SceneManager:SetModelMaskShader(mask_img,model_root,part_name,mask_Tex) if not model_root or not model_root.gameObject or not mask_img then -- print("参数错误 mask_img: "..mask_img.." model_root: ",model_root.gameObject) return end local target_root if part_name then target_root = model_root.gameObject.transform:Find(part_name) --rhand else target_root = model_root.transform --rhand end if target_root then self:SetModelMaskShaderInEveryChild(target_root,mask_img,mask_Tex) else print("没有找到对应的挂件 ",part_name) end end function SceneManager:SetModelMaskShaderInEveryChild(root,mask_img,mask_Tex) self:SetSingleModelMaskShader(root,mask_img,mask_Tex) if root.childCount > 0 then for i=0,root.childCount - 1 do self:SetModelMaskShaderInEveryChild(root:GetChild(i),mask_img,mask_Tex) end end end function SceneManager:SetSingleModelMaskShader(target,mask_img,mask_Tex) local coms = target.gameObject:GetComponent(typeof(UnityEngine.Renderer)) self:SetSingleModelMaskShaderWithCom(coms,mask_img,mask_Tex) end function SceneManager:SetSingleModelMaskShaderWithCom(com,mask_img,mask_Tex) if not com then return end for i = 0, com.materials.Length - 1 do local material = com.materials[i] --这里不能用 sharedMaterial 不能改变他原有的shader,只是临时改变 local shader = self:GetModelMaskShader(material.shader.name) -- print("寻找对应的shader "..material.shader.name,shader.name) if string.find (material.shader.name,"UIMask") then return end if not shader then print("没有找到对应的Shader "..material.shader.name) return end local rectTran = mask_img:GetComponent("RectTransform") local img = mask_img:GetComponent("Image") if not img then print("没有找到遮罩组件 Image") return end material.shader = shader local corners = ToVector3Array({Vector3,Vector3,Vector3,Vector3}) if not corners then print("Vector3返回空值,请更新版本") return end rectTran:GetWorldCorners(corners) local minX = corners[0].x; local minY = corners[0].y; local maxX = corners[2].x; local maxY = corners[2].y; material:SetTexture("_MaskTex",mask_Tex or img.sprite.texture); material:SetFloat("_MinX", minX); material:SetFloat("_MinY", minY); material:SetFloat("_MaxX", maxX); material:SetFloat("_MaxY", maxY); end end ]] -----------------------------------------场景判断--------------------------------- function SceneManager:GetCacheSceneType( ) if rawget(self, "cache_scene_type") then return self.cache_scene_type, self.cache_scene_broadcast end local info = self:GetSceneInfo() if not info then return end self.cache_scene_type = info.type self.cache_scene_broadcast = info.broadcast and info.broadcast == 1 return self.cache_scene_type, self.cache_scene_broadcast end function SceneManager:ResetCacheSceneType( ) self.cache_scene_type = false self.cache_scene_broadcast = false end --[[ 功能:是否新手副本场景id ]] function SceneManager:IsFirstScene() return false end --[[ 功能:是否在副本 ]] function SceneManager:IsMission() return self:GetCurrDunId() ~= 0 end --[[ 功能:是否在主城或者野外或社团场景 ]] function SceneManager:IsMainCityorYieldScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1 or sceneInfo.type == 4) end --[[ 功能:是否在主城或者野外(不包括社团) ]] function SceneManager:IsMainCityorYieldSceneNotGuild(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1) end --[[ 功能:判断当前场景是否为安全场景 不能释放一切技能 ]] function SceneManager:IsSafeScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and sceneInfo.subtype == 1) end --是否安全区域 (包括安全场景和安全位置坐标) function SceneManager:IsSafeArea(scene_id, pos_x, pos_y) local sceneInfo = self:GetSceneInfo(scene_id) return self:IsSafeScene(scene_id) or (self:IsSafePos(pos_x, pos_y)) end --是否处于安全区坐标,野外场景也会有安全区的 function SceneManager:IsSafePos(pos_x, pos_y) if pos_x == nil or pos_y == nil then return false end local is_safe_area = self:IsAreaType(pos_x / SceneObj.LogicRealRatio.x, pos_y / SceneObj.LogicRealRatio.y, AreaDataIndex.SafeType) return is_safe_area end --是否有障碍区 function SceneManager:HasBolckScene(scene_id) return false end --是否处于障碍区 function SceneManager:IsBlockPos(pos_x, pos_y) return false end --pk场景 强制切换pk状态 function SceneManager:IsPKScene(scene_id) return not self:IsOnlyAttackMonsterScene(scene_id) end --不能攻击其他玩家 只能打怪的场景 function SceneManager:IsOnlyAttackMonsterScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.subtype == 1)) end function SceneManager:IsCSPvP(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 6000 end function SceneManager:IsAutoFindWayScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 10003 or scene_id == 10003 or scene_id == 10000 end function SceneManager:IsAutoFindWayDun(dun_id) dun_id = dun_id or self:GetCurrDunId() return dun_id == 1003 end --Pk场景准备阶段 function SceneManager:IsNotBlockMonsterScene() return self:IsPkBattleScene() end --Pk场景准备阶段 function SceneManager:IsNotShowOtherHeadScene() return self:IsPkBattleScene() or self:IsCSPvP() end --星界试炼场景 function SceneManager:IsStarFightScene(scene_id) -- if scene_id == nil and self.temp_check_list["IsStarFightScene"] ~= nil then -- return self.temp_check_list["IsStarFightScene"] -- end -- local save = false -- if scene_id == nil then -- save = true -- end -- scene_id = scene_id or self:GetSceneId() -- for k,v in pairs(Config.Pokemonwarbirth) do -- if tonumber(scene_id) == v.id then -- if save then -- self.temp_check_list["IsStarFightScene"] = true -- end -- return true -- end -- end -- if save then -- self.temp_check_list["IsStarFightScene"] = false -- end -- return false end --Pk场景准备阶段 function SceneManager:IsPkSceneReadyStep() if self:IsPkBattleScene() then if PkBattleModel:getInstance():IsInReadyStep() then return true end end return false end function SceneManager:IsOvnWaitingScene(scene_id) scene_id = scene_id or self:GetSceneId() if scene_id == 7112 then return 1 elseif scene_id == 7113 then return 2 else return false end end function SceneManager:IsOvnFightingScene(scene_id) scene_id = scene_id or self:GetSceneId() if scene_id == 7110 then return 1 elseif scene_id == 7111 then return 2 else return false end end --显示pk模式ui的场景 function SceneManager:ShowPKStatusUI(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.subtype == 0) and RoleManager.Instance.mainRoleInfo.warGroup == 0) end --能否切换PK模式的场景 function SceneManager:IsCanChangePKStatusScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.subtype == 0)) end function SceneManager:ShowPkTipsScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.pkstate == 1 or sceneInfo.pkstate == 2) and not self:IsDiamondFightScene() and not self:IsOvnFightingScene()) end --显示跟随npc的场景 function SceneManager:ShowFollowNpc(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1) ) end --不能跳跃障碍点的场景 function SceneManager:CannotJumpCrossBlockScene() local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.type == 3)) end --任务可以加速的场景 function SceneManager:TaskCanAddSpeedBuffScene() return self:IsMainCityorYieldScene() end --在主城安全区 function SceneManager:IsMainCity(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.type == 0 and sceneInfo.subtype == 1)) end --没有操作cd的场景 function SceneManager:NoOperateCDScene() if self:IsMainCity() or ((self:IsOnlyAttackMonsterScene() or self:IsSafeScene()) and self:IsOutdoorScene()) then return true end end --是否可以使用飞鞋的场景(主城,野外场景中的子类型为0和1的场景) function SceneManager:IsCanUseFlyShoeScene() return self:IsMainCityAndFieldScene() or self:IsRefineDungeon() or self:IsCSPvP() or self:IsPkBattleScene() or self:IsHomeBuildScene() end --隐藏连击效果的场景 function SceneManager:HideLianjiScene(scene_id) return true end --是否野外场景 function SceneManager:IsOutdoorScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and sceneInfo.type == 1) end function SceneManager:IsBeachScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == BeachModel:GetInstance():GetKeyValue("kf_scene") or scene_id == BeachModel:GetInstance():GetKeyValue("bf_scene") end function SceneManager:IsPkRankFightScene(scene_id) -- local sceneInfo = self:GetSceneInfo(scene_id) -- return (sceneInfo and sceneInfo.type == 9) return self:IsMirrorPkRankScene() end function SceneManager:IsTopPkScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id >= 4053 and scene_id <= 4054 end function SceneManager:IsStarDungeonScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 5502 end --是否副本场景 function SceneManager:IsDungeonScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) if sceneInfo then return sceneInfo.type == 2 and self:IsMirrorDungeonScene() else return false end end --是否沙盘副本场景 function SceneManager:IsSandTableDungeonScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) if sceneInfo then for k,v in pairs(Config.Dungeoncfg) do if v.scene_id == scene_id then return v.type == BaseDungeonModel.DUN_TYPE.SandTable end end end return false end --是否镜像竞技场 function SceneManager:IsMirrorPkRankScene() return self.mirror_scene_id == SceneActivityMirrorSceneId.PkRank end --是否是镜像场景 function SceneManager:IsMirrorScene() return self.mirror_scene_id ~= SceneActivityMirrorSceneId.None end --上一个场景是否是镜像场景 function SceneManager:IsLastMirrorScene() return self.last_mirror_scene_id ~= SceneActivityMirrorSceneId.None end --是否镜像副本 function SceneManager:IsMirrorDungeonScene() return self.mirror_scene_id == SceneActivityMirrorSceneId.Dungeon or self.mirror_scene_id == SceneActivityMirrorSceneId.None or self.mirror_scene_id == SceneActivityMirrorSceneId.DungeonMany end --设置镜像镜像场景 function SceneManager:SetMirrorSceneId(mirror_scene_id) self.last_mirror_scene_id = self.mirror_scene_id self.mirror_scene_id = mirror_scene_id end --获取镜像场景id function SceneManager:GetMirrorSceneId(mirror_scene_id) return self.mirror_scene_id end --退出副本场景的时候是否弹出结算界面(默认不弹出) function SceneManager:IsShowDungeonResultOnExit(dun_id) local show = false local resultData = BaseDungeonModel:getInstance():GetDunResultInfo() if resultData.result == 1 or (self:IsGuardianThreeDun(dun_id) and DunManyModel:getInstance().is_support_state == 1 and resultData.wave and resultData.wave > 5) then--场景外只有胜利弹 if self:IsCrusadeDun(dun_id) or self:IsGuardianThreeDun(dun_id) then show = true end elseif resultData.result == 2 then--多人副本场景外如果是失败了也要弹 if self:IsCrusadeDun(dun_id) or self:IsGuardianThreeDun(dun_id) then show = true end end return show end --退出副本场景内的时候是否弹出结算界面 function SceneManager:ShowDungeonResultOnDun(dun_id) local show = true local resultData = BaseDungeonModel:getInstance():GetDunResultInfo() local exit_by_hand = BaseDungeonModel:getInstance().exit_by_hand -- --无尽回廊只有失败的时候才在副本场景外面弹结算界面 -- if self:IsOneTowerDungeon(dun_id) and BaseDungeonModel:getInstance():GetDunResultInfo().result ~= 2 then -- show = false -- --主线副本默认不弹结算界面 -- else -- print("huangcong:SceneManager [start:1799] :", resultData) -- PrintTable(resultData) -- print("huangcong:SceneManager [end]") if self:IsThreadDungeon(dun_id) or self:IsNomalDungeon(dun_id) or self:IsEscortDungeon() then--主线副本不弹结算界面 show = false elseif resultData and resultData.result == 2 and resultData.result_subtype ~= 1 then--失败结算 if exit_by_hand and ( self:IsMaterialDungeon(dun_id) or self:IsVIPDungeon(dun_id) or self:IsOneTowerDungeon(dun_id) ) then show = false end end return show end --是否跨服入侵场景 function SceneManager:IsIntrusionScene(scene_id) -- local sceneInfo = self:GetSceneInfo(scene_id) -- if sceneInfo then -- return sceneInfo.type == 16 -- else -- return false -- end end --是否是在跨服场景 .加入会自动添加 区服 攻击模式、在名字前加服务器标识 function SceneManager:InServerScene(scene_id) return self:IsCrusadeScene(scene_id) or self:IsCSEndlessScene(scene_id) or self:IsBeachScene(scene_id) or self:IsKfWordScene(scene_id) or self:IsGuildCSGRScene(scene_id) or self:IsCSGWarScene(scene_id) or self:IsCSWastelandScene(scene_id) or self:IsRageWarCrossServerScene(scene_id) or self:IsDesertedBossCrossScene(scene_id) or self:IsJumpOneScene(scene_id) end --是否跨服入侵 世界主城 场景 function SceneManager:IsIntrusionWorldHoneScene(scene_id) -- scene_id = scene_id or self:GetSceneId() -- local sceneInfo = self:GetSceneInfo(scene_id) -- if sceneInfo then -- return sceneInfo.type == 17 -- else -- return false -- end end --是否彩钻大战战斗 function SceneManager:IsDiamondFightScene(scene_id) -- local scene_id = scene_id or self:GetSceneId() -- local config = Config.Drumwarkv[5] -- local list = ErlangParser:GetInstance():Parse(config.val) -- scene_id = tostring(scene_id) -- for i,v in pairs(list) do -- if v == scene_id then -- return true -- end -- end return false end --是否彩钻大战等待 function SceneManager:IsDiamondFightWaitingScene(scene_id) -- local scene_id = scene_id or self:GetSceneId() -- local config = Config.Drumwarkv[4] -- local list = ErlangParser:GetInstance():Parse(config.val) -- scene_id = tostring(scene_id) -- for i,v in pairs(list) do -- if v == scene_id then -- return true -- end -- end return false end --是否是彩钻大战任意一个场景(等待或者战斗) function SceneManager:IsAnyDiamonScene(scene_id) return self:IsDiamondFightWaitingScene(scene_id) or self:IsDiamondFightScene(scene_id) end --是否星灵争霸战斗 function SceneManager:IsSpiritWarScene(scene_id) -- local scene_id = scene_id or self:GetSceneId() -- local config = Config.Pokemondrumkv[8] -- if config then -- local list = ErlangParser:GetInstance():Parse(config.val) -- scene_id = tostring(scene_id) -- for i,v in pairs(list) do -- if v == scene_id then -- return true -- end -- end -- end return false end --是否星灵争霸等待 function SceneManager:IsSpiritWarWaitingScene(scene_id) -- local scene_id = scene_id or self:GetSceneId() -- local config = Config.Pokemondrumkv[7] -- if config then -- local list = ErlangParser:GetInstance():Parse(config.val) -- scene_id = tostring(scene_id) -- for i,v in pairs(list) do -- if v == scene_id then -- return true -- end -- end -- end return false end --是否是星灵争霸任意一个场景(等待或者战斗) function SceneManager:IsAnySpiritWarScene(scene_id) return self:IsSpiritWarScene(scene_id) or self:IsSpiritWarWaitingScene(scene_id) end --是否是能获得经验的副本 function SceneManager:CanGetExpDungeonScene(scene_id) return self:IsExpScene(scene_id)--[[ or self:IsGuildGuardDungeon(scene_id)--]] end --普通副本 function SceneManager:IsNomalDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.MORMAL or dunConfig.type == BaseDungeonModel.DUN_TYPE.PSIONIC end end --是否是经验跑环副本副本 function SceneManager:IsDailyCircleDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.MORMAL and dunConfig.sub_type == BaseDungeonModel.DUN_SUB_TYPE.DAILY_CIRCLE_DUN end end --护送副本 function SceneManager:IsEscortDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.Escort end end --主线副本 function SceneManager:IsThreadDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.THREAD end end --进阶副本 function SceneManager:IsMaterialDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.MATERIAL end end --VIP副本 function SceneManager:IsVIPDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.VIP end end --爬塔副本 function SceneManager:IsOneTowerDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER end end --简单爬塔副本 function SceneManager:IsOneTowerNormalDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then if dunConfig.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER and not Config.Towerdundiffcult[dun_id] then return true end end return false end --爬塔副本 function SceneManager:IsOneTowerScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 7001 end --主线材料副本 function SceneManager:IsMainPlotDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.MAINPLOT end end --守卫幼宠(宠物副本) function SceneManager:IsPetDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.PET end end --唤神副本 function SceneManager:IsGodDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.GOD end end function SceneManager:IsEliteAssessDun(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.EliteAssess end end -- 是否是古神灭世神座体验副本 function SceneManager:IsGAExperienceDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() return dun_id >= 3600 and dun_id <= 3604 -- 暂时写死 end --沙盘副本 function SceneManager:IsSandTableDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.SandTable end end function SceneManager:IsEquipScene(dun_id) -- local dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.EQUIP -- end return false end --普通副本 function SceneManager:IsNormalDungeonScene(dun_id) -- local dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == 0 -- end return false end function SceneManager:IsRebuildDungeon(dun_id) -- local dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.REBUILD -- end return false end function SceneManager:IsExpScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 3001 end -- 是否是经验副本 function SceneManager:IsExpDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.EXP end end -- 是否是讨伐小队 function SceneManager:IsCrusadeDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.Crusade end end -- 是否是多人副本场景 function SceneManager:IsCrusadeScene( scene_id ) scene_id = scene_id or self:GetSceneId() return (scene_id >= 8000 and scene_id <= 8010) or scene_id == 3100 end -- 是否是绝地守卫 function SceneManager:IsGuardianThreeDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.GuardianThree end end -- 是否是幻光副本 function SceneManager:IsIllusoryLightDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.IllusoryLight end end -- 是否是宝宝副本 function SceneManager:IsBabyDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.BABY end end -- 是否是专属副本 function SceneManager:IsBossPersonDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.PersonBoss end end function SceneManager:IsBabyScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 2300 end -- 是否是星辰副本 function SceneManager:IsGalaxyDun( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.GALAXY end end -- 是否是星辰副本 function SceneManager:IsSupportGuildBoss( dun_id ) local dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.SupportGuildBoss end end function SceneManager:IsTeamDungeonScene(scene_id) -- local dun_id = scene_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.EQUIP -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.REFINE -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.LOVE -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.REBUILD -- else -- return false -- end end --是否需要鼓舞技能的场景 function SceneManager:IsInspireScene(scene_id) return self:IsTeamDungeonScene() or self:IsExpScene() or self:IsStarDungeon() end function SceneManager:IsSingleDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return -- dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GOD -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GEM -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.EXP -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.NEWIE_EXP -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.STAR_FIGHT -- or dunConfig.type == 24 -- or dunConfig.type == 16 -- or dunConfig.type == 15 -- or dunConfig.type == 25 -- or dunConfig.type == 0 -- or self:IsBossPersonScene() -- else -- return false -- end end function SceneManager:IsCoinDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN -- else -- return false -- end end --新手降神副本 function SceneManager:IsNewbieGodDungeon(dun_id) dun_id = dun_id or self:GetCurrDunId() return dun_id == 5405 end --新手副本 function SceneManager:IsNewbieDungeon(dun_id) dun_id = dun_id or self:GetCurrDunId() return dun_id == 1002 end function SceneManager:IsGemDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GEM -- else -- return false -- end end function SceneManager:IsRefineDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.REFINE -- else -- return false -- end end function SceneManager:IsStarDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN -- else -- return false -- end end function SceneManager:IsGuildBossDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GUILD_BOSS -- else -- return false -- end end function SceneManager:IsGuildGuardDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GUARD -- else -- return false -- end end --死亡是否是幽灵模式的场景 function SceneManager:IsGhostModeScene(scene_id) return false end --显示所有伤害飘字的场景 function SceneManager:ShowAllDamageScene() return self:IsPkRankFightScene() or self:IsTopPkScene() or self:IsMirrorPkRankScene() end --是否在不能点击超链接寻路的场景 function SceneManager:IsClickFindScene(cur_scene_id, target_scene_id) -- if cur_scene_id == target_scene_id then return true end -- local cur_scene_info = self:GetSceneInfo(cur_scene_id) -- local tar_scene_info = self:GetSceneInfo(target_scene_id) -- if not cur_scene_info or not tar_scene_info then return false end -- local function check(scene_type) -- for i,v in ipairs(Config.LinkClickScene) do -- if scene_type == 4 then --社团场景 -- return RoleManager:getInstance():GetMainRoleVo().guild_id > 0 -- elseif scene_type == v then -- return true -- end -- end -- return false -- end -- local cur_can_click = check(cur_scene_info.type) -- local tar_can_click = check(tar_scene_info.type) -- return cur_can_click and tar_can_click end --每个场景的复活类型 function SceneManager:GetReliveType(scene_id) if self:IsDungeonScene(scene_id) then return 9 elseif self:IsCSPvP(scene_id) then return 10 else return 1 end end function SceneManager:GetModuleId(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id end function SceneManager:IsPreChangeSceneState() return self.pre_change_scene_state end --切换场景预读条 function SceneManager:ClearPreChangeSceneHandle() if self.pre_change_scene_handle then GlobalTimerQuest:CancelQuest(self.pre_change_scene_handle) self.pre_change_scene_handle = nil end end --切换场景预读条 function SceneManager:PreChangeScene( change_func) self.pre_change_scene_state = true Scene.Instance:GetMainRole():PreChangeScene() local check_finish = function(state) self.pre_change_scene_state = false if change_func then change_func( state ) change_func = nil end self.pre_change_scene_handle = nil end if self.pre_change_scene_handle then GlobalTimerQuest:CancelQuest(self.pre_change_scene_handle) self.pre_change_scene_handle = nil end local last_time = Config.ConfigDungeonClient.change_scene_transfer_time self.pre_change_scene_handle = setTimeout(check_finish, last_time) self:ShowPreChangeSceneView( check_finish, last_time) end function SceneManager:ShowPreChangeSceneView( callback,last_time ) local check_view = function() if self.pre_change_scene then self.pre_change_scene:Close() self.pre_change_scene = nil end end local finish_func = function( succeed ) check_view() callback( not succeed ) end check_view() if self.pre_change_scene == nil then self.pre_change_scene = PreChangeSceneView.New( finish_func, last_time ) end self.pre_change_scene:Open() end --是否正在读条切换场景 function SceneManager:IsPreparingChangeScene() return self.pre_change_scene end --判断两个角色是否友方 function SceneManager:IsFriendlyRole(vo1, vo2) vo2 = vo2 or RoleManager.Instance.mainRoleInfo local is_friendly = false if vo1.role_id == vo2.role_id then is_friendly = true elseif vo1.warGroup == vo2.warGroup and vo1.warGroup > 0 then is_friendly = true elseif vo1.warGroup == vo2.warGroup and vo1.warGroup == 0 then if vo1.team_id == vo2.team_id and vo1.team_id > 0 then is_friendly = true elseif vo1.guild_id == vo2.guild_id and vo1.guild_id > 0 then is_friendly = true end end return is_friendly end --attacker_vo是否能通过pkstatus的验证 攻击defender_vo function SceneManager:CanPKByPKStatus(attacker_vo,defender_vo) if attacker_vo and defender_vo then if attacker_vo == defender_vo then return false end -- if attacker_vo.hp == 0 or defender_vo.hp == 0 then if defender_vo.hp == 0 then return false end if defender_vo.boss_type then --怪物 if defender_vo.warGroup == attacker_vo.warGroup and attacker_vo.warGroup > 0 then return false else return true end end if (attacker_vo.pk_status == RoleVo.PK_STATUS.ForcePeace) and (defender_vo.vo_type == SceneBaseType.Role) then --强制和平状态下不可以攻击人 return false end if attacker_vo.pk_status and ((attacker_vo.warGroup == 0 and defender_vo.warGroup == 0) or (attacker_vo.warGroup ~= defender_vo.warGroup)) then if attacker_vo.pk_status == RoleVo.PK_STATUS.Peace then --和平模式:只会攻击怪物和红名状态下的非同队和同社团的玩家 if (attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0) or (attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0) then return false elseif defender_vo.hatred and defender_vo.hatred > 0 then return true end return false elseif attacker_vo.pk_status == RoleVo.PK_STATUS.Force then --强制模式:不能攻击同队和同社团的玩家(红名也不可攻击),可以攻击其他玩家 if (attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0) or (attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0) then return false end elseif attacker_vo.pk_status == RoleVo.PK_STATUS.Local then if attacker_vo.server_id ~= defender_vo.server_id then return true else return false end elseif attacker_vo.pk_status == RoleVo.PK_STATUS.All then return true elseif attacker_vo.pk_status == RoleVo.PK_STATUS.GUILD then if attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0 then return false elseif attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0 then return false else return true end end end end return true end --主角是否能被attack_vo攻击,战斗分组不同 and --safe_area_state 1角色处于安全区域状态 2角色处于非安全区域状态 3角色切场景进入安全区域状态 --not_check_safe_area 不考虑安全区域 function SceneManager:IsMainRoleCanBeAttack(attacker_vo, not_check_safe_area) local defender_vo = RoleManager.Instance.mainRoleInfo if attacker_vo == nil or defender_vo == nil or attacker_vo.hp == 0 or defender_vo.hp == 0 then return false end --是否要检测场景的安全区域 if not not_check_safe_area then if self:IsSafeArea(nil, attacker_vo.pos_x, attacker_vo.pos_y) then return false elseif defender_vo.safe_area_state == 1 or defender_vo.safe_area_state == 3 or (defender_vo.safe_area_state ~= 2 and self:IsSafeArea(nil, defender_vo.pos_x, defender_vo.pos_y)) then return false end end if attacker_vo.vo_type == SceneBaseType.MainRole then return false end local war_group1 = attacker_vo.warGroup local war_group2 = defender_vo.warGroup local same_group = war_group2 == war_group1 and war_group1 > 0 if attacker_vo.vo_type == SceneBaseType.Monster then if attacker_vo.guild_id > 0 and attacker_vo.guild_id == defender_vo.guild_id then --defender_vo.type == 3 return false elseif attacker_vo.guild_id > 0 and attacker_vo.guild_id ~= defender_vo.guild_id then return true elseif attacker_vo.guaji_flag == 1 or attacker_vo.can_attack == 0 or attacker_vo.type == MonsterType.COLLECT or attacker_vo.type == MonsterType.TASK_COLLECT or attacker_vo.type == MonsterType.PICK or attacker_vo.type == MonsterType.UD_COLLECT then return false end end if attacker_vo.vo_type ~= SceneBaseType.Role then return not same_group end -- if not self:IsPKScene() then -- return false -- end local canpkByPkStatus = true if war_group1 == 0 and war_group2 == 0 then canpkByPkStatus = self:CanPKByPKStatus(attacker_vo, defender_vo) end return canpkByPkStatus and not same_group end --主角是否能攻击defender_vo --safe_area_state 0未设置 1角色处于安全区域状态 2角色处于非安全区域状态 --check_safe_area 考虑安全区域 function SceneManager:IsCanAttackByMainRole(defender_vo, check_safe_area, not_check_hp) local attacker_vo = RoleManager.Instance.mainRoleInfo if not attacker_vo or not defender_vo or (not not_check_hp and attacker_vo.hp == 0) or defender_vo.hp == 0 then return false end if check_safe_area then if attacker_vo.safe_area_state == 1 or (attacker_vo.safe_area_state == 0 and self:IsSafePos(attacker_vo.pos_x, attacker_vo.pos_y)) then return false elseif defender_vo.safe_area_state == 1 or (defender_vo.safe_area_state == 0 and self:IsSafePos(defender_vo.pos_x, defender_vo.pos_y)) then return false end end local war_group1 = attacker_vo.warGroup local war_group2 = defender_vo.warGroup local same_group = war_group2 == war_group1 and war_group1 > 0 --同社团车队,非社团成员看见的血是红色 if defender_vo.vo_type == SceneBaseType.Monster then if defender_vo.guild_id > 0 and defender_vo.guild_id == attacker_vo.guild_id then --defender_vo.type == 3 return false elseif defender_vo.guild_id > 0 and defender_vo.guild_id ~= attacker_vo.guild_id then return true elseif defender_vo.guaji_flag == 1 or defender_vo.can_attack == 0 or defender_vo.type == MonsterType.COLLECT or defender_vo.type == MonsterType.TASK_COLLECT or defender_vo.type == MonsterType.PICK or defender_vo.type == MonsterType.UD_COLLECT or defender_vo.type == MonsterType.ESCORT then return false end end if defender_vo.vo_type == SceneBaseType.MainRole then return false end if defender_vo.vo_type ~= SceneBaseType.Role then return not same_group end -- if not self:IsPKScene() then -- return false -- end local canpkByPkStatus = true if war_group1 == 0 and war_group2 == 0 then canpkByPkStatus = self:CanPKByPKStatus(attacker_vo, defender_vo) end return canpkByPkStatus and not same_group end --设置收到场景跳转协议时是否立即跳转 function SceneManager:DelayToChangeScene() self.delay_change_scene = true end --获取是否需要延迟跳转 function SceneManager:CheckDirectly() return not self.delay_change_scene end function SceneManager:CancelDelay() self.delay_change_scene = nil end function SceneManager:CheckDisplayAddExpAvailable() return true end --是否客户端隐身npc, 创建npc但不显示,用于触发任务 function SceneManager:IsClientHideNpc( npcid ) return npcid == 100499 end -- --是否在社团篝火宴会场景 -- function SceneManager:IsGuildScene(scene_id) -- if scene_id == nil and self.temp_check_list["IsGuildScene"] ~= nil then -- return self.temp_check_list["IsGuildScene"] -- end -- local save = false -- if scene_id == nil then -- save = true -- end -- scene_id = scene_id or self:GetSceneId() -- for k,v in pairs(Config.Gfeast) do -- if Trim(v.key) == "scene_id" then -- if save then -- self.temp_check_list["IsGuildScene"] = scene_id == v.value -- end -- return scene_id == v.value -- end -- end -- if save then -- self.temp_check_list["IsGuildScene"] = false -- end -- return false -- end --是否在社团驻地场景 function SceneManager:IsGuildScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 4063 or scene_id == 4064 end -- 是否是本国团战场景 function SceneManager:IsGuildCSGRScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 4200 -- 跨服模式场景 or scene_id == 4201 -- 本服模式场景 end --新手虚构的赏金BOSS,实际是一个副本 function SceneManager:IsFakeBossMoneyScene(scene_id) local scene_id = scene_id or self:GetSceneId() return scene_id == BossModel.FAKE_MONEY_BOSS_SCENE_ID end function SceneManager:IsBossMoneyScene( scene_id ) scene_id = scene_id or self:GetSceneId() local scene_typt = self:GetSceneType(scene_id) return scene_typt == 7 or self:IsFakeBossMoneyScene(scene_id) end function SceneManager:IsBossWorldScene( scene_id ) scene_id = scene_id or self:GetSceneId() local scene_typt = self:GetSceneType(scene_id) return scene_typt == 3 end --是否在个人boss场景 function SceneManager:IsBossPersonScene( scene_id ) scene_id = scene_id or self:GetSceneId() for k,v in pairs(Config.Dungeoncfg) do if v.scene_id == scene_id then return v.type == BaseDungeonModel.DUN_TYPE.PersonBoss end end return false end --是否在个人boss场景 function SceneManager:IsBossPersonDun( dun_id ) dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then return dunConfig.type == BaseDungeonModel.DUN_TYPE.PersonBoss else return false end end --是否在幻魔星域场景 function SceneManager:IsBossDesertedScene( scene_id ) scene_id = scene_id or self:GetSceneId() local scene_typt = self:GetSceneType(scene_id) return scene_typt == SCENE_TYPE.DESERTED end --是否在boss场景 function SceneManager:IsBossScene( scene_id ) scene_id = scene_id or self:GetSceneId() return self:IsBossPersonScene(scene_id) or self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) or self:IsBossDesertedScene() or self:IsBossHomeScene() end --是否在boss之家场景 function SceneManager:IsBossHomeScene(scene_id) scene_id = scene_id or self:GetSceneId() local scene_typt = self:GetSceneType(scene_id) return scene_typt == SCENE_TYPE.BOSSHOME end --是否在副本, boss场景等不可跳转的地方 function SceneManager:IsOnDunOrBossScene( ) return self:IsDungeonScene() or self:IsTeamDungeonScene() or self:IsBossPersonScene() end --是否定点挂机场景 function SceneManager:IsFixedPointFightScene( ) return self:IsPetDungeon() or self:IsDunExpSeaScene() end --是否显示主界面boss列表 function SceneManager:IsShowMainUIMonsterView( ) return false end --显示怪物怒气的场景 function SceneManager:IsShowAngerScene( ) scene_id = scene_id or self:GetSceneId() return false end --复活疲劳生效的场景 function SceneManager:IsReliveTiredScene( ) return false end --是否在幻兽之域场景(返回层数) function SceneManager:IsWorldBeastScene(scene_id) scene_id = scene_id or self:GetSceneId() return ((scene_id == 1501) and 1) or ((scene_id == 1502) and 2) or nil end --是否是跨服场景 function SceneManager:IsCrossScene(scene_id) scene_id = scene_id or self:GetSceneId() return self:IsWorldBeastScene(scene_id) end --是否是神格副本 function SceneManager:IsContinueChangeGodScene() return self:IsGodHoodDungeon() or self:GetSceneId() == 5405 end --是否是将神塔副本 function SceneManager:IsGodHoodTowerDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD_TOWER -- else -- return false -- end end --是否是神格副本 function SceneManager:IsGodHoodDungeon(dun_id) -- dun_id = dun_id or self:GetCurrDunId() -- local dunConfig = Config.Dungeoncfg[dun_id] -- if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD -- else -- return false -- end end --是否在跳一跳场景 function SceneManager:IsJumpOneScene(scene_id ) scene_id = scene_id or self:GetSceneId() return scene_id == 20010 end --是否在单服社团战场景 function SceneManager:IsGuildWarScene(scene_id ) scene_id = scene_id or self:GetSceneId() return scene_id == 4100 end --跨服社团战场景(无尽海域) function SceneManager:IsKFGuildWarFightScene(scene_id) -- scene_id = scene_id or self:GetSceneId() -- return scene_id and scene_id == KFGuildWarModel:getInstance():GetKFGuildWarConfig(4) end --是否是庭院场景 function SceneManager:IsHomeBuildScene( scene_id ) -- scene_id = scene_id or self:GetSceneId() -- -- return scene_id == 11001 -- return scene_id and scene_id == HomeModel:getInstance():GetRoleHomeKVCfg(1) end --是否是房屋场景 function SceneManager:IsHomeRoomScene( scene_id ) -- if scene_id == nil and self.temp_check_list["IsHomeRoomScene"] ~= nil then -- return self.temp_check_list["IsHomeRoomScene"] -- end -- local save = false -- if scene_id == nil then -- save = true -- end -- scene_id = scene_id or self:GetSceneId() -- for i,v in pairs(Config.Rolehome) do -- if scene_id == v.home_scene then -- if save then -- self.temp_check_list["IsHomeRoomScene"] = true -- end -- return true -- end -- end -- if save then -- self.temp_check_list["IsHomeRoomScene"] = false -- end -- return false end --是否在婚礼的场景 function SceneManager:IsWeddingScene(scene_id) scene_id = scene_id or self:GetSceneId() local target_scene_id = tonumber(Config.Marriageconstant[13].constant) return scene_id == target_scene_id end --是否在大乱斗场景 function SceneManager:IsPkBattleScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 5801 or scene_id == 5802 end --是否显示坐骑场景,默认大世界才显示,战场玩法中要下坐骑,个别需要显示坐骑的场景可以添加进去 function SceneManager:IsShowHorseScene() local is_show_horse = false if (self:IsMainCityorYieldScene() or self:IsBossDesertedScene() or self:IsBossHomeScene()) and not self:IsUnderWaterScene() then is_show_horse = true end return is_show_horse end --需要显示|屏蔽玩家宠物的场景 function SceneManager:showPetScene() return not (self:IsNoonQuizScene() or self:IsBeachScene() or self:IsTopPkScene() or self:IsCSPvP() or self:IsOvnFightingScene() or self:IsStarDungeonScene() or self:IsKFGuildWarFightScene() or self:IsBabyScene()) --or self:IsEscortScene() end --需要显示|屏蔽玩家宠物的场景 function SceneManager:showPokemonScene() return not (self:IsDiamondFightScene() or self:IsPkRankFightScene() or self:IsJumpOneScene() or self:IsCSPvP() or self:IsOvnFightingScene() or self:IsStarDungeonScene() or self:IsStarFightScene() or self:IsSpiritWarScene() or self:IsBeachScene() or self:IsKFGuildWarFightScene() or self:IsNoonQuizScene() or self:IsTopPkScene() or self:IsOvnWaitingScene() or self:IsBabyScene()) end --需要显示|屏蔽玩家称号的场景 function SceneManager:showDsgtScene() return not (--[[self:IsBossScene() or--]] self:IsWorldBeastScene() or self:IsStarDungeonScene() or self:IsGodDungeon() or self:IsRageWarScene()) end --需要显示|屏蔽玩家宝宝的场景 function SceneManager:showBabyScene() return not (self:IsDiamondFightScene() or self:IsBeachScene() or self:IsJumpOneScene() or self:IsNoonQuizScene() or self:IsCSPvP() or self:IsOvnFightingScene() or self:IsStarDungeonScene() or self:IsKFGuildWarFightScene() or self:IsTopPkScene() or self:IsPkRankFightScene() or self:IsOvnWaitingScene() or self:IsBabyScene())--or self:IsEscortScene() end --需要显示|屏蔽玩家守护的场景 function SceneManager:showSpriteScene() return not (self:IsBeachScene() or self:IsBabyScene() or self:IsJumpOneScene()) end --需要显示|屏蔽玩家翅膀的场景 function SceneManager:showWingScene() return not (self:IsNoonQuizScene() or self:IsStarDungeonScene() or self:IsJumpOneScene()) end --需要显示|屏蔽玩家武器的场景[人物动作会根据这个改动] function SceneManager:showWeaponScene() return not (self:IsStarDungeonScene())-- or self:IsBeachScene())--暂时先屏蔽这个沙滩场景 end function SceneManager:maskReliveViewScene()--不展示复活界面 if self:IsThreadDungeon() or self:IsNomalDungeon() then--主线副本和普通副本要判断复活次数 local dun_cfg = BaseDungeonModel:GetInstance():GetDunCfg(self:GetCurrDunId()) if dun_cfg and dun_cfg.revive_count == 0 then return true end elseif self:IsPetDungeon() then--宠物副本判断复活次数 local left_pet_dun_relive_times = BaseDungeonModel:GetInstance():GetDunPetReliveTimes() if left_pet_dun_relive_times <= 0 then return true else return false end else return self:IsExpDun() or self:IsOneTowerDungeon() or self:IsIllusoryLightDun() or self:IsGodDungeon() or self:IsGalaxyDun() or self:IsNomalDungeon() or self:IsSandTableDungeon() end return false end -- 是否智慧达人(中午答题)场景 function SceneManager:IsNoonQuizScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 5171 end function SceneManager:IsShowCollectBtnScene() return (self:IsPkBattleScene() or self:IsGuildWarScene() or self:IsCSPvP() or self:IsWeddingScene() or self:IsLeagueWarScene()) end -- 是否为强制隐藏挂机按钮场景 function SceneManager:IsHideAutoBtnScene(scene_id) scene_id = scene_id or self:GetSceneId() return self:IsNoonQuizScene() end -- 是否为强制隐藏跳跃按钮场景 function SceneManager:IsHideJumpBtnScene(scene_id) scene_id = scene_id or self:GetSceneId() return self:IsStarDungeonScene() end function SceneManager:IsDelayAutoFightScene(scene_id) return self:IsPkBattleScene() end function SceneManager:CanAutoFightScene(scene_id) return not self:IsCSPvP() end --是否是情缘副本 function SceneManager:IsLoveDungeon(dun_id) dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.LOVE else return false end end function SceneManager:IsEudemonsAttackFightScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 4401 end --是否是勇者副本 function SceneManager:IsYongZheDungeon(dun_id) dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.YONGZHE else return false end end --是否在捕蝶场景 function SceneManager:IsOnButterflyScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 3010 end --设置是否在采集 function SceneManager:SetCollectFlag( is_collect ) self.is_collect = is_collect end --设置是否在采集 function SceneManager:GetCollectFlag( ) return self.is_collect end --是否护送场景 function SceneManager:IsEscortScene( scene_id ) scene_id = scene_id or self:GetSceneId() local scene_data = stringtotable(Config.Convoykv["convoy_pk_scene"].value_content) return scene_id == scene_data[1] or scene_id == scene_data[2] end function SceneManager:IsEscortAllScene( scene_id ) scene_id = scene_id or self:GetSceneId() local scene_data1 = stringtotable(Config.Convoykv["convoy_pk_scene"].value_content) local scene_data2 = stringtotable(Config.Convoykv["convoy_safe_scene"].value_content) return scene_id == scene_data1[1] or scene_id == scene_data1[2] or scene_id == scene_data2[1] or scene_id == scene_data2[2] end --已经没有这个副本了 function SceneManager:IsEscortPVEDunScene( dun_id ) return false end --是否展示主界面出口按钮 function SceneManager:IsShowMainExitScene( ) return SceneManager:getInstance():IsWorldBeastScene() or self:IsIntrusionWorldHoneScene() end --显示结婚预告图标的场景 function SceneManager:IsShowMarriageScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1)) end --不显示危险警告特效场景 function SceneManager:IsShowDangerWarnScene(scene_id) return not self:IsStarFightScene() and not self:IsStarDungeonScene() end --是否限制其他玩家外观的场景(目前只在创建这些对象的时候生效:AI娘,宝具,宠物,宝宝) function SceneManager:IsModelLimited( ) local is_limited = false --大世界不屏蔽 local scene_id = self:GetSceneId() if self:IsMainCityAndFieldScene(scene_id) then return false end --多人战场玩法需要屏蔽 if self:IsBossScene() --BOSS or self:IsRageWarScene() --狂战 or self:IsWastelandScene() --废土 or self:IsEndlessScene() --无尽 or self:IsGuildWarScene() --本服团战 or self:IsGuildCSGRScene() --跨国团战 then is_limited = true end return is_limited end --是否特效全开的场景 function SceneManager:IsFullEffectScene( scene_id ) -- if SystemMemoryLevel.Cur == SystemMemoryLevel.Low then -- return false -- end if self:IsMirrorPkRankScene(scene_id) or self:IsCrusadeScene(scene_id) then return true end return false end --是否显示所有小怪血条的副本,压力本中需要(经验副本、爬塔副本、幻光副本、宠物副本) function SceneManager:IsShowMonsterBloodDun( dun_id ) return self:IsExpDun(dun_id) or self:IsOneTowerDungeon(dun_id) or self:IsIllusoryLightDun(dun_id) or self:IsPetDungeon(dun_id) end function SceneManager:CheckSceneFightSoundAvaliable(scene_id) return self:IsStarFightScene() or self:IsSpiritWarScene() end function SceneManager:IsShowLiveEffectScene(scene_id) return not self:IsBeachScene() and not self:IsStarDungeonScene() end --隐藏其他人小头像的场景 function SceneManager:HideOtherHeadScene( scene_id ) scene_id = scene_id or self:GetSceneId() return false end --是否需要预加载将神资源的副本 function SceneManager:IsNeedPreloadGodResScene( ) -- local sceneInfo = self:GetSceneInfo(scene_id) -- if sceneInfo and (sceneInfo.type == 3 or sceneInfo.type == 5 or sceneInfo.type == 7 or sceneInfo.type == 8 or -- sceneInfo.type == 9 or sceneInfo.type == 11 or sceneInfo.type == 12 or sceneInfo.type == 13 or -- sceneInfo.type == 14 or sceneInfo.type == 15 or sceneInfo.type == 16 or sceneInfo.type == 19) then -- return true -- elseif sceneInfo and sceneInfo.type == 2 then -- return not self:IsStarDungeon() and not self:IsStarFightScene() and not self:IsPkRankFightScene() -- end return true end --显示墓碑的场景 function SceneManager:IsShowGraveScene() return self:IsBossDesertedScene() or self:IsBossHomeScene() end function SceneManager:AddGraveVo(grave_vo) self.grave_vo_list[grave_vo.instance_id] = grave_vo GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_ADD, grave_vo.instance_id, grave_vo) end function SceneManager:GetGraveVo(ins_id) return self.grave_vo_list[ins_id] end function SceneManager:DeleteGraveVo(ins_id) local vo = self:GetGraveVo(ins_id) if vo then self.grave_vo_list[ins_id] = nil GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_REMOVE, ins_id, vo) return vo end end function SceneManager:ClearAllGraveVo() if not (self:IsShowGraveScene() or self:IsWorldBeastScene()) then for k, vo in pairs(self.grave_vo_list) do GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_REMOVE, vo.instance_id, vo) end self.grave_vo_list = {} end end --主城和野外场景 function SceneManager:IsMainCityAndFieldScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1)) end --是否全场景,1为全场景 0为九宫格 function SceneManager:IsBroadCastScene(scene_id) local sceneInfo = self:GetSceneInfo(scene_id) return (sceneInfo and sceneInfo.broadcast and sceneInfo.broadcast == 1) end --是否屏蔽传闻和公告的场景 function SceneManager:IsNoHornAndNoticeScene(scene_id) return self:IsNoonQuizScene() end function SceneManager:IsSwingScene(scene_id) return self:IsBeachScene() or self:IsKFGuildWarFightScene() end --boss特殊选中光环 function SceneManager:ShowSpecialLightScene( scene_id ) return self:IsBossScene(scene_id) or self:IsWorldBeastScene(scene_id) end --觉醒之门场景 function SceneManager:IsAwakeScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 2401 end --新手引导经验副本 function SceneManager:IsGuideExpDungeon(dun_id) local dun_id = dun_id or self:GetCurrDunId() return dun_id == 3002 end --觉醒之门 function SceneManager:IsAwakeDungeon(dun_id) dun_id = dun_id or self:GetCurrDunId() local dunConfig = Config.Dungeoncfg[dun_id] if dunConfig then -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.AWAKE else return false end end -- 荣耀战神 function SceneManager:IsHonourFightScene(scene_id) -- scene_id = scene_id or self:GetSceneId() -- local bf_k = 4 -- local kf_k = 5 -- if Config.Wargodkv[bf_k].val == scene_id or Config.Wargodkv[kf_k].val == scene_id then -- return true -- end return false end function SceneManager:IsLeagueWarScene(scene_id) local bool = false -- scene_id = scene_id or self:GetSceneId() -- if scene_id == Config.Leaguewarconstcfg[6].value or scene_id == Config.Leaguewarconstcfg[11].value then -- bool = true -- end return bool end -- function SceneManager:NeedEnterSceneAction(force_show_action) -- if not force_show_action and RoleManager.Instance.mainRoleInfo.level < 150 then -- return false -- end -- local scene_id = SceneController.Instance.request_scene_id -- if scene_id then -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id] -- if not config_data then -- return Config.ConfigChangeSceneEffect.default_action -- end -- return config_data.pre_action -- end -- return false -- end function SceneManager:IsEnterSameScene() do return false end -- local scene_id = SceneController.Instance.request_scene_id -- if scene_id then -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id] -- if config_data and config_data.load_type == 3 then -- return true -- end -- end -- return Config.ConfigChangeSceneEffect.default_load == 3 end function SceneManager:NeedEnterSceneEffect() -- local config_data = Config.ConfigChangeSceneEffect.data[self.curr_scene_id] -- if not config_data then -- return Config.ConfigChangeSceneEffect.default_effect -- end -- if config_data.enter_effect then -- return true -- end return false end function SceneManager:SetCacheMainRolePos( ) local main_role = Scene.Instance:GetMainRole() if main_role then self.cache_main_role_pos_x = main_role.real_pos.x self.cache_main_role_pos_y = main_role.real_pos.y self.cache_main_role_birth_angle = main_role:GetDirectionAngle() end end function SceneManager:ResetCacheMainRolePos( ) self.cache_main_role_pos_x = 0 self.cache_main_role_pos_y = 0 self.cache_main_role_birth_angle = nil end function SceneManager:GetCacheMainRolePos( ) if self.cache_main_role_pos_x then self.cache_main_role_pos_x = self.cache_main_role_pos_x + 1 end return self.cache_main_role_pos_x, self.cache_main_role_pos_y, self.cache_main_role_birth_angle end --不需要加载场景进度条 function SceneManager:NoLoadingViewScene(next_scene_id) if not next_scene_id then return self.is_no_loading_scene end local cur_scene_id = self:GetSceneId() local next_scene_id = next_scene_id self.is_no_loading_scene = false local temp_cfg = Config.ConfigChangeSceneEffect.data[cur_scene_id] if temp_cfg then for k,v in pairs(temp_cfg) do if v == next_scene_id then self.is_no_loading_scene = true break end end end return self.is_no_loading_scene -- local bool = self:IsSpecialSceneLoadEffect(dungeon_id)--有些副本场景切换动画要特殊处理 -- if bool == false then -- return false -- end -- if BaseDungeonModel:getInstance().exit_by_hand2 then--副本退出的时候也不要无缝切换 -- BaseDungeonModel:getInstance().exit_by_hand2 = false -- self.is_no_loading_scene = false -- return false -- end -- if scene_id then -- if Scene.Instance.is_first_enter_scene then -- self.is_no_loading_scene = false -- Scene.Instance.is_first_enter_scene = false -- return false -- end -- local default_loadtype = Config.ConfigChangeSceneEffect.default_load -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id] -- local no_loading_state = false -- if default_loadtype ~= 1 then -- no_loading_state = true -- end -- if config_data then -- if config_data.load_type == 1 then -- no_loading_state = false -- else -- no_loading_state = true -- end -- end -- if not no_loading_state then -- config_data = Config.ConfigChangeSceneEffect.data[self:GetSceneId()] -- if config_data and config_data.load_type ~= 1 then -- no_loading_state = true -- end -- end -- self.is_no_loading_scene = no_loading_state -- else -- if Scene.Instance.is_first_enter_scene then -- return false -- end -- end -- return self.is_no_loading_scene end --是否在无尽领域 function SceneManager:IsEndlessScene(scene_id) scene_id = scene_id or self:GetSceneId() return ((scene_id >= 7100 and scene_id <= 7108) or (scene_id >= 7110 and scene_id <= 7118)) end --是否在无尽领域跨服场景 function SceneManager:IsCSEndlessScene( scene_id ) scene_id = scene_id or self:GetSceneId() return (scene_id >= 7110 and scene_id <= 7118) end --是否在无尽领域顶层 function SceneManager:IsEndlessLastScene( scene_id ) scene_id = scene_id or self:GetSceneId() return (scene_id == EndlessConst.CSENDLESS_NINE_FLOOR_ID or scene_id == EndlessConst.ENDLESS_NINE_FLOOR_ID) end --是否显示伤害第一标识 function SceneManager:IsShowAttFirstScene( scene_id ) return self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) or self:IsBossDesertedScene() or self:IsBossHomeScene() end --是否显示boss疲劳 function SceneManager:IsShowBossTireScene( scene_id ) return self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) end --是否显示协助者标识 function SceneManager:IsShowHelperScene( scene_id ) return self:IsBossMoneyScene(scene_id) or self:IsGuildScene(scene_id) or self:IsBossDesertedScene() end --是否显示受击tip function SceneManager:IsShowBeenAttackTips( scene_id ) return self:IsBossMoneyScene(scene_id) or self:IsMainCityAndFieldScene() or self:IsBossDesertedScene() or self:IsBossHomeScene() end function SceneManager:IsHideMainVipIcon( ) return self:IsDungeonScene() or self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) or self:IsGuildScene() or self:IsEscortScene() or self:IsRageWarScene() or self:IsBossDesertedScene() or self:IsGuildCSGRScene() or self:IsGuildWarScene() or self:IsBossHomeScene() end --是否跨服世界场景(是否需要显示跨服世界分区预告的场景) function SceneManager:IsKfWordScene( scene_id ) local scene_id = scene_id or self:GetSceneId() return scene_id == 1016 --跨服主城 or scene_id == 1017 --跨服护送 end --是否多人战斗场景(是的话会调高同场景人数) function SceneManager:IsMultiPlayerBattleScene( ) return self:IsGuildWarScene() or self:IsCSGWarScene() end --是否是跨国团战场景 function SceneManager:IsCSGWarScene( scene_id ) scene_id = scene_id or self:GetSceneId() return Config.Crossguildwarconfig[11].value == scene_id end -- 是否是狂战领域活动场景 function SceneManager:IsRageWarScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 7800 -- 本服阶段 or scene_id == 7810 -- 开服未开启跨服的本服第二阶段 or scene_id == 7820 -- 跨服阶段 end -- 是否是狂战领域第二阶段场景 function SceneManager:IsRageWarRound2Scene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 7810 -- 开服未开启跨服的本服第二阶段 or scene_id == 7820 -- 跨服阶段 end function SceneManager:IsRageWarCrossServerScene(scene_id) scene_id = scene_id or self:GetSceneId() return scene_id == 7820 end --是否是特殊场景加载场景切换特效 function SceneManager:IsSpecialSceneLoadEffect( dungeon_id ) if self:IsOneTowerDungeon(dungeon_id) then --爬塔副本,在第一次进去的时候,不要无缝切换,第二次开始才无缝切换 if not self.is_first_enter_tower_dun then self.is_first_enter_tower_dun = true return false end else self.is_first_enter_tower_dun = false end end --是否在废土战场 function SceneManager:IsWastelandScene(scene_id) local scene_id = scene_id or self:GetSceneId() return ((scene_id >= 7600 and scene_id <= 7621) or scene_id == 7630 or scene_id == 7631) end --是否在废土战场跨服场景 function SceneManager:IsCSWastelandScene( scene_id ) local scene_id = scene_id or self:GetSceneId() return (scene_id == 7601 or scene_id == 7611 or scene_id == 7621 or scene_id == 7631) end --废土准备场景 function SceneManager:IsWastelandPrepareScene( ) local scene_id = scene_id or self:GetSceneId() return scene_id == 7630 or scene_id == 7631 end --是否展示左侧的动态轮播信息场景 function SceneManager:IsShowDynamicInfoScene(scene_id) local scene_id = scene_id or self:GetSceneId() if self:IsWastelandPrepareScene(scene_id) -- 废土准备场景 or self:IsGuildScene(scene_id) -- 社团驻地场景 or BeachModel:GetInstance():IsShowDynamicInfo(scene_id) -- 温泉场景 or self:IsGuildWarScene(scene_id) --本服团战 or self:IsEndlessScene(scene_id)--无尽领域 or self:IsGuildCSGRScene(scene_id) -- 本国团战 then return true end return false end --得到道具假掉落位置单位是80(掉落的数量) function SceneManager:GetGoodsFakerDropPosList( goods_len, per_interval ) if not goods_len or goods_len == 0 then return end local per_interval = per_interval or 80 local pos_list = {} local dot_list = nil for k,v in ipairs(self.drop_pos_cfg) do if k <= goods_len then pos_list[#pos_list + 1] = {pos_x = per_interval*v[1],pos_y = per_interval*v[2]} else break end end return pos_list end --初始化掉落随机位置列表 function SceneManager:InitDropPosCfg( ) self.drop_pos_cfg = {} local cfg = DeepCopy(Config.Dropdotrule) for k,v in ipairs(cfg) do local dot_list = stringtotable(v.dot_list) for ii,vv in ipairs(dot_list) do self.drop_pos_cfg[#self.drop_pos_cfg + 1] = vv end end end --设置当前攻击主角的目标数据(右下角头像显示) function SceneManager:SetAttackHeadVo( vo, role_id, force ) --手动点击角色,要覆盖目标 if force then self.target_head_vo = vo GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, true, vo, 2) return end --战斗那边不知道vo,只有role_id,需要去场景上拿 if not self.target_head_vo then if role_id then vo = self:GetRoleVo(role_id) end self.target_head_vo = vo if vo then GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, true, vo, 2) end end end function SceneManager:ResetAttackHeadVo(hide_head) if hide_head then if self.target_head_vo then GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, false) end end self.target_head_vo = false end function SceneManager:GetAttackHeadVo( ) return self.target_head_vo end function SceneManager:GetScenObjDepth(y) return SceneDepth.Obj + y * 0.5 end function SceneManager:GetCameraRotateConfig( ) -- if not self:IsMainCityAndFieldScene() then -- return -- end local scene_id = self:GetSceneId() local temp_cfg = self.camera_rotate_cfg[scene_id] if temp_cfg then return temp_cfg end temp_cfg = Config.ConfigSceneCamera[scene_id] or Config.ConfigSceneCamera["default"] if temp_cfg and temp_cfg.area_list then self.camera_rotate_cfg[scene_id] = temp_cfg return temp_cfg end end function SceneManager:GetCameraRotateAngle( angle ) local cfg = self:GetCameraRotateConfig() if not cfg then return end local area_list = cfg.area_list or {} local area_index, camera_angle for k,v in pairs(area_list) do local is_turn_around = false if v[1] > v[2] then is_turn_around = true end if is_turn_around and (angle > v[1] or angle <= v[2]) then area_index = k camera_angle = v[3] break elseif angle > v[1] and angle <= v[2] then area_index = k camera_angle = v[3] break end end if area_index and camera_angle then return area_index, camera_angle end end function SceneManager:IsDesertedBossCrossScene( scene_id ) local scene_id = scene_id or self:GetSceneId() return BossModel:GetInstance():CheckIsCrossDesertedScene(scene_id) end function SceneManager:IsUnderWaterScene( scene_id ) local scene_id = scene_id or self:GetSceneId() return scene_id == 1005 or scene_id == 2209 or scene_id == 2210 or scene_id == 10051 end function SceneManager:IsMappingToSameScene( cur_id, tar_id ) self.scene_mapping_cfg = self.scene_mapping_cfg or { [1003] = 1, [1016] = 1, [4063] = 2, [4064] = 2, } if self.scene_mapping_cfg[cur_id] and self.scene_mapping_cfg[cur_id] == self.scene_mapping_cfg[tar_id] then return true end return false end function SceneManager:CheckMatchLoadingRes( ) local res_list = {} local role_lev = RoleManager.Instance.mainRoleInfo.level if role_lev == 0 then role_lev = LoginModel:getInstance():GetSelectRoleLevel() or 0 end local open_serevr_time = ServerTimeModel:getInstance():GetOpenServerDay() local cur_server_time = TimeUtil:getServerTime() local create_role_time = ServerTimeModel:getInstance():GetCreateRoleDay() local level_match, server_match, time_match, create_match,week_match --匹配标示 local level_item, server_item, create_item,week_item local max_ran = 0 for k,v in pairs(Config.Sceneload) do level_match, server_match, time_match, create_match, week_match = true, true, true, true,true if v.lv then level_item = stringtotable(v.lv) if not IsTableEmpty(level_item) and (role_lev < level_item[1] or role_lev > level_item[2]) then if (role_lev < level_item[1] or level_item[2] ~= 0 ) then level_match = false end end end if v.server_open then server_item = stringtotable(v.server_open) if not IsTableEmpty(server_item) and (open_serevr_time < server_item[1] or open_serevr_time > server_item[2]) then if (open_serevr_time < server_item[1] or server_item[2] ~= 0 ) then server_match = false end end end if v.start_time and tonumber(v.start_time) > 0 and v.end_time and tonumber(v.end_time) > 0 then if cur_server_time < tonumber(v.start_time) or cur_server_time > tonumber(v.end_time)then time_match = false end end if v.create_day then if v.create_day then create_item = stringtotable(v.create_day) if not IsTableEmpty(create_item) and (create_role_time < create_item[1] or create_role_time > create_item[2]) then if (create_role_time < create_item[1] or create_item[2] ~= 0 ) then create_match = false end end end end if v.week then create_week = stringtotable(v.week) local cur_date = os.date("*t", cur_server_time) local cur_week_day = cur_date and cur_date.wday cur_week_day = cur_week_day - 1 == 0 and 7 or cur_week_day - 1 --os.date周日是1,但是配置1是周一 if cur_week_day and not IsTableEmpty(create_week) then week_match = false for k,v in pairs(create_week) do if tonumber(v) == tonumber(cur_week_day) then week_match = true break end end end end --全部条件满足的才放到列表里 if level_match and server_match and time_match and create_match and week_match and v.weight then max_ran = max_ran + v.weight table.insert(res_list, v.id) end end --按权重随机 local cur_res_id = 1 if #res_list >= 1 then math.randomseed(os.clock() * 100000000) local random_index = math.random(1, max_ran) local temp_cfg local cur_weight = 0 for i=1, #res_list do temp_cfg = Config.Sceneload[res_list[i]] if temp_cfg and temp_cfg.weight then cur_weight = cur_weight + temp_cfg.weight if cur_weight >= random_index then cur_res_id = temp_cfg.res_id break end end end end return cur_res_id end function SceneManager:IsDunExpSeaScene( scene_id ) local scene_id = scene_id or self:GetSceneId() return scene_id == Config.Expseafloor[1].scene end