源战役客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

3742 lignes
110 KiB

  1. require("game.scene.MainCamera")
  2. require("game.scene.Scene")
  3. require("game.scene.SceneConfig")
  4. require("operation.OperateManager")
  5. require("game.mainUI.PreChangeSceneView")
  6. SceneManager = SceneManager or BaseClass(BaseModel)
  7. local SceneManager = SceneManager
  8. local GlobalEventSystem = GlobalEventSystem
  9. local SceneEventType = SceneEventType
  10. local table_remove = table.remove
  11. local table_insert = table.insert
  12. local math_sqrt = math.sqrt
  13. local math_pow = math.pow
  14. local math_acos = math.acos
  15. local math_floor = math.floor
  16. local math_pi = math.pi
  17. SceneManager.START = "SceneManager_event_start"
  18. SceneManager.DISPOSE ="SceneManager_event_dispose"
  19. function SceneManager:__init()
  20. if SceneManager.Instance ~= nil then
  21. LogError("SceneManager is a singleton class")
  22. end
  23. SceneManager.Instance = self
  24. self.client_role_num = 0 -- 当前客户端显示的角色数量
  25. self.server_role_num = 0 -- 当前服务器显示的角色数量
  26. self.role_limit_num = Config.otherFightInfo.scene_max_role_count -- 最大显示人数
  27. self.scene_Info = nil --当前场景数据
  28. self.last_scene_id = 0 --上一个场景ID
  29. self.curr_scene_id = 0 --当前场景ID
  30. self.next_scene_id = 0 --下一个场景ID
  31. self.last_dun_id = 0 --上一个副本id
  32. self.curr_dun_id = 0 --副本,0代表不是副本场景
  33. self.npc_doors_loaded = false
  34. self.jumppoint_loaded = false
  35. self.isStart = false --场景是否加载完成
  36. self.role_vo_list = {} --其他玩家 Vo列表
  37. self.partner_vo_list = {} --伙伴Vo列表
  38. self.monster_vo_list = {} --怪物 Vo列表(怪物的instance_id作为key)
  39. self.npc_vo_list = {} --Npc Vo列表(Npc的instance_id作为key)
  40. self.sceneNpcList = {} --当前场景的NPC,12100协议列表数据
  41. self.door_vo_list = {} --门点 Vo列表(enter_scene_id作为key)
  42. self.monster_type_list = {} --怪物类型列表
  43. self.monster_type_in_scenes = {} -- 每个场景里的所有怪物类型
  44. self.jump_vo_list = {} --跳点对象列表
  45. self.other_vo_list = {} --除了以上以外的一般场景对象
  46. self.grave_vo_list = {} --怪物死亡墓碑vo列表
  47. self.monster_vo_pool = Array.New()
  48. self.role_vo_pool = Array.New()
  49. self.delay_role_vo_list = {} -- 延迟创建角色
  50. self.delay_monster_list = Array.New() --延迟加载的怪物列表
  51. --主角中的嘲讽buff的发起者
  52. self.chaofeng_attacker_compress_id = nil
  53. --被主角攻击过的玩家id
  54. self.mainRole_attacker_list = {}
  55. self.mainRole_attacker_count = 0
  56. --攻击过主角的玩家id
  57. self.mainRole_defender_list = {}
  58. self.mainRole_defender_count = 0
  59. --被主角杀死的怪物数量,当前只用于经验副本
  60. self.mainRole_kill_monster_count = 0
  61. --记录最近一次和其他玩家战斗的时间
  62. self.last_role_attact_time = 0
  63. --主角释放技能成功 服务端返回后的技能列表 记录每个主角技能等服务端返回后的时间
  64. self.main_role_server_back_skill_list = {}
  65. self.clone_role_id_count = 0
  66. self.clone_role_start_id = 274877906944 -- 2的38次方
  67. self.killerName = "" --凶手名字
  68. self.killerGuildName = "" --凶手社团名字
  69. self.killerType = 0 --凶手的类型 1怪 2人
  70. self.killerRoleId = 0
  71. self.killerVo = nil --杀手信息
  72. self.can_relive = 1 --是否能复活
  73. self.next_relive_time = 0 --下次能复活的时间戳
  74. self.last_fight_msg = {} --上一次给服务端发送的20001对象,副技能用
  75. self.is_collect = false --是否在采集
  76. self.is_no_loading_scene = false
  77. self.temp_check_list = {} --缓存的当前场景的判断列表
  78. self.mat_prop_blocks = {}
  79. self.curr_frame_rate = FINAL_FRAMERATE --当前计算的平均帧频
  80. self:InitPropBlocks()
  81. self.temp_monster_bounds_size = {} --缓存当前场景怪物模型的包围盒高度
  82. self.set_model_limit_flag = true --部分多人玩法要开启外观限制
  83. self.is_first_enter_tower_dun = false--爬塔副本第一次进入不需要无缝切换
  84. self.curr_req_scene_id = false --当前正在请求切换场景的id
  85. self.record_pre_monster_data={}
  86. self.drop_pos_unit = 80--掉落位置单位数
  87. self.mirror_scene_id = SceneActivityMirrorSceneId.None
  88. self.last_mirror_scene_id = SceneActivityMirrorSceneId.None
  89. self:InitDropPosCfg()--初始化掉落随机位置列表
  90. self.camera_rotate_cfg = {} --场景摄像机旋转参数
  91. end
  92. function SceneManager:getInstance()
  93. if SceneManager.Instance == nil then
  94. SceneManager.New()
  95. end
  96. return SceneManager.Instance
  97. end
  98. function SceneManager:InitPropBlocks( )
  99. local blocks = Optimizer.CreateMatPropertyBlocks(20)
  100. for i=0, blocks.Length-1 do
  101. table.insert(self.mat_prop_blocks, blocks[i])
  102. end
  103. end
  104. function SceneManager:PushPorpBlock( prop_block )
  105. if self.mat_prop_blocks and prop_block then
  106. table.insert(self.mat_prop_blocks, prop_block)
  107. end
  108. end
  109. function SceneManager:PopPorpBlock()
  110. local prop_block = false
  111. if self.mat_prop_blocks then
  112. prop_block = table.remove(self.mat_prop_blocks)
  113. end
  114. if not prop_block then
  115. prop_block = Optimizer.CreateMatPropertyBlock()
  116. end
  117. return prop_block
  118. end
  119. function SceneManager:GetMonsterBoundsSize( type_id )
  120. return self.temp_monster_bounds_size[type_id]
  121. end
  122. function SceneManager:SetMonsterBoundsSize( type_id, size_y )
  123. self.temp_monster_bounds_size[type_id] = size_y
  124. end
  125. function SceneManager:SetLastPkTime( )
  126. self.last_role_attact_time = TimeUtil:getServerTime()
  127. end
  128. function SceneManager:SetLastFightMsg(type,msg,att_object_id)
  129. self.last_fight_msg[type] = self.last_fight_msg[type] or {}
  130. if type == SceneBaseType.MainRole then
  131. self.last_fight_msg[type] = msg
  132. elseif type == SceneBaseType.Pokemon then
  133. self.last_fight_msg[type][att_object_id] = msg
  134. end
  135. end
  136. function SceneManager:GetLastFightMsg(type,att_object_id)
  137. if type == SceneBaseType.MainRole then
  138. return self.last_fight_msg[type]
  139. elseif type == SceneBaseType.Pokemon then
  140. if self.last_fight_msg[type] and self.last_fight_msg[type][att_object_id] then
  141. return self.last_fight_msg[type][att_object_id]
  142. end
  143. end
  144. end
  145. function SceneManager:SetKillerInfo(type, killerId)
  146. end
  147. function SceneManager:AddMainRoleBackSkill(skill_id)
  148. self.main_role_server_back_skill_list[skill_id] = Status.NowTime
  149. end
  150. function SceneManager:GetMainRoleBackSkillTime(skill_id)
  151. return self.main_role_server_back_skill_list[skill_id]
  152. end
  153. function SceneManager:RemoveMainRoleBackSkill(skill_id)
  154. self.main_role_server_back_skill_list[skill_id] = nil
  155. end
  156. function SceneManager:ClearMainRoleBackSkill()
  157. self.main_role_server_back_skill_list = {}
  158. end
  159. function SceneManager:AddMainRoleAttacker(role_id, skill_id)
  160. -- local attacker_info = self.mainRole_attacker_list[role_id]
  161. -- if attacker_info == nil then
  162. -- attacker_info = {start_time = Status.NowTime, skill_id = skill_id, attack_count = 1}
  163. -- self.mainRole_attacker_list[role_id] = attacker_info
  164. -- self.mainRole_attacker_count = self.mainRole_attacker_count + 1
  165. -- local max_count = Config.otherFightInfo.mainRole_attacker_max_count
  166. -- if self.mainRole_attacker_count > max_count then
  167. -- local min_start_time = 99999
  168. -- local min_role_id = nil
  169. -- for id, vo in pairs(self.mainRole_attacker_list) do
  170. -- if min_start_time > vo.start_time then
  171. -- min_start_time = vo.start_time
  172. -- min_role_id = id
  173. -- end
  174. -- end
  175. -- if min_role_id then
  176. -- self.mainRole_attacker_list[min_role_id] = nil
  177. -- end
  178. -- end
  179. -- else
  180. -- attacker_info.start_time = Status.NowTime
  181. -- if attacker_info.skill_id == skill_id then
  182. -- attacker_info.attack_count = attacker_info.attack_count + 1
  183. -- else
  184. -- attacker_info.skill_id = skill_id
  185. -- attacker_info.attack_count = 1
  186. -- end
  187. -- end
  188. end
  189. function SceneManager:AddMainRoleDefender(role_id)
  190. local defender_info = self.mainRole_defender_list[role_id]
  191. if defender_info == nil then
  192. defender_info = {start_time = Status.NowTime}
  193. self.mainRole_defender_list[role_id] = defender_info
  194. self.mainRole_defender_count = self.mainRole_defender_count + 1
  195. local max_count = Config.otherFightInfo.mainRole_defender_max_count
  196. if self.mainRole_defender_count > max_count then
  197. local min_start_time = 99999
  198. local min_role_id = nil
  199. for id, vo in pairs(self.mainRole_defender_list) do
  200. if min_start_time > vo.start_time then
  201. min_start_time = vo.start_time
  202. min_role_id = id
  203. end
  204. end
  205. if min_role_id then
  206. self.mainRole_defender_list[min_role_id] = nil
  207. end
  208. end
  209. -- if RoleManager.Instance.mainRoleInfo.pk_status == RoleVo.PK_STATUS.Peace then
  210. -- local role_vo = self:GetRoleVo(role_id)
  211. -- if role_vo then
  212. -- role_vo:ChangeVar("pk_status", role_vo.pk_status, nil, true)
  213. -- end
  214. -- end
  215. else
  216. defender_info.start_time = Status.NowTime
  217. end
  218. end
  219. function SceneManager:ClearMainRoleAttacker()
  220. self.mainRole_attacker_list = {}
  221. self.mainRole_attacker_count = 0
  222. end
  223. function SceneManager:ResetMainRoleAttackerAttackCount()
  224. for id, info in pairs(self.mainRole_attacker_list) do
  225. info.attack_count = 0
  226. end
  227. end
  228. function SceneManager:ClearMainRoleDefender()
  229. self.mainRole_defender_list = {}
  230. self.mainRole_defender_count = 0
  231. end
  232. --被主角击杀的obj数量,用于经验副本和虚空秘境
  233. function SceneManager:AddMainRoleKillCount(obj_type)
  234. if (SceneManager.Instance:IsAwakeScene() or SceneManager.Instance:IsExpScene()) and obj_type == SceneBaseType.Monster then
  235. self.mainRole_kill_monster_count = self.mainRole_kill_monster_count + 1
  236. end
  237. end
  238. function SceneManager:ResetMainRoleKillMonsterCount()
  239. self.mainRole_kill_monster_count = 0
  240. end
  241. --返回登录,清空一下数据
  242. function SceneManager:GameStartClearCache()
  243. self.last_scene_id = 0
  244. self.curr_scene_id = 0
  245. self:SetCurrentReqChangeSceneId(false)
  246. self.curr_dun_id = 0
  247. self:SetLastDunId( 0 )
  248. end
  249. function SceneManager:SetCurrDunId(dun_id)
  250. self:SetLastDunId( self.curr_dun_id )
  251. self.curr_dun_id = dun_id
  252. -- BaseDungeonModel:getInstance():InitDungeonInfo(self.curr_dun_id)
  253. -- if not (self.last_dun_id == self.curr_dun_id and self.last_dun_id > 0) then --不是同一个副本的切场景情况就要重置怒气
  254. -- RoleManager.Instance.mainRoleInfo:ChangeVar("anger", 0, nil, true)
  255. -- end
  256. end
  257. function SceneManager:GetCurrDunId()
  258. return self.curr_dun_id or 0
  259. end
  260. function SceneManager:SetCurrentSceneId(sceneId)
  261. self.last_scene_id = self.curr_scene_id
  262. self.curr_scene_id = sceneId
  263. self.scene_Info = self:GetSceneInfo(sceneId)
  264. self:SetCurrentReqChangeSceneId(false)
  265. self.temp_check_list = {}
  266. self.role_limit_num = 40 -- 最大显示人数
  267. if self:IsMainCityAndFieldScene() then
  268. self.role_limit_num = 30
  269. elseif self:IsGuildScene() then
  270. self.role_limit_num = 45
  271. end
  272. end
  273. function SceneManager:SetCurrentReqChangeSceneId(sceneId)
  274. self.curr_req_scene_id = sceneId
  275. end
  276. function SceneManager:IsReqChangeScene()
  277. return self.curr_req_scene_id ~= false
  278. end
  279. function SceneManager:GetLastSceneId()
  280. return self.last_scene_id
  281. end
  282. function SceneManager:SetLastDunId( dun_id )
  283. self.last_dun_id = dun_id or 0
  284. --2020.4.27新增一个针对副本类任务的补充处理
  285. --[[
  286. 61003
  287. --]]
  288. end
  289. function SceneManager:GetLastDunId()
  290. return self.last_dun_id
  291. end
  292. function SceneManager:GetSceneId()
  293. return self.curr_scene_id
  294. end
  295. function SceneManager:GetSceneName(sceneId)
  296. if sceneId then
  297. local data = self:GetSceneInfo(sceneId)
  298. if data then
  299. return data.name
  300. end
  301. else
  302. if self.scene_Info then
  303. return self.scene_Info.name
  304. end
  305. end
  306. return ""
  307. end
  308. function SceneManager:GetSceneType(sceneId)
  309. local scene_Info = self:GetSceneInfo(sceneId)
  310. return scene_Info and scene_Info.type or 0
  311. end
  312. function SceneManager:GetSceneBirthPos(sceneId)
  313. local scene_Info = self:GetSceneInfo(sceneId)
  314. if scene_Info then
  315. return scene_Info.x, scene_Info.y
  316. end
  317. end
  318. function SceneManager:GetSceneInfo(sceneId)
  319. sceneId = sceneId or self:GetSceneId()
  320. if self.scene_Info and self.scene_Info.id == sceneId then
  321. return self.scene_Info
  322. end
  323. local data = ConfigItemMgr.Instance:GetSceneItem(sceneId)
  324. if not data and sceneId > 0 then
  325. Message.show("场景DB文件缺失数据,ID:" .. sceneId)
  326. end
  327. return data
  328. end
  329. function SceneManager:GetSceneNpcInfo(npcId, sceneId)
  330. local sceneId = sceneId or self:GetSceneId()
  331. local sceneInfo = self:GetSceneInfo(sceneId)
  332. if sceneInfo and type(sceneInfo.Npcs) == "table" then
  333. for npc_id, npc_info in pairs(sceneInfo.Npcs) do
  334. if tonumber(npc_id) == tonumber(npcId) then
  335. return npc_info
  336. end
  337. end
  338. end
  339. end
  340. --获取场景内的跳点配置
  341. function SceneManager:GetSceneJumpPoints()
  342. if self.scene_Info == nil then
  343. return {}
  344. end
  345. local scene_id = self:GetSceneId()
  346. local jump_info = Config.JumpSceneInfo[scene_id]
  347. if jump_info == nil then
  348. return {}
  349. end
  350. return jump_info
  351. end
  352. function SceneManager:GetSceneDoors()
  353. if self.scene_Info == nil or self.scene_Info.Doors == nil then
  354. return {}
  355. end
  356. return self.scene_Info.Doors
  357. end
  358. function SceneManager:GetSceneDoorInfo(id, sceneId)
  359. sceneId = sceneId or self:GetSceneId()
  360. local sceneInfo = self:GetSceneInfo(sceneId)
  361. if sceneInfo == nil or sceneInfo.Doors == nil then
  362. return nil
  363. end
  364. return sceneInfo.Doors[id]
  365. end
  366. function SceneManager:ClearAllVo()
  367. self.isStart = false
  368. self:ClearMainRoleDefender()
  369. self:ClearMainRoleAttacker()
  370. self:ClearMainRoleBackSkill()
  371. self:ClearAllRoleVo()
  372. self:ClearAllMonsterVo()
  373. self:ClearAllPartnerVo()
  374. self:ClearAllOtherVo()
  375. self:ClearAllGraveVo()
  376. --场景有变化时才清空传送门和NPC
  377. if self:GetSceneId() ~= self.last_scene_id then
  378. self:ClearAllNpcVo()
  379. self:ClearAllDoorVo()
  380. self:ClearAllJumpPointVo()
  381. self.npc_doors_loaded = false
  382. self.jumppoint_loaded = false
  383. end
  384. self.monster_type_list = {}
  385. SceneManager.ResetCacheSceneType(self)
  386. GlobalEventSystem:Fire(SceneManager.DISPOSE)
  387. end
  388. function SceneManager:LoadJumpPoints()
  389. if self.jumppoint_loaded then
  390. return
  391. end
  392. local jumppoints = self:GetSceneJumpPoints()
  393. if jumppoints then
  394. for id, info in ipairs(jumppoints) do
  395. local jumppoint_vo = JumpPointVo.New()
  396. jumppoint_vo:CreateJumpPointInfo(id,info)
  397. self:AddJumpPointVo(jumppoint_vo)
  398. end
  399. end
  400. self.jumppoint_loaded = true
  401. end
  402. function SceneManager:LoadNpcsAndDoors()
  403. if self.npc_doors_loaded then
  404. return
  405. end
  406. local doors = self:GetSceneDoors()
  407. local doorId = 1
  408. if doors then
  409. if SceneManager.Instance:IsIntrusionWorldHoneScene() then
  410. for id, info in pairs(doors) do
  411. local door_vo = DoorVo.New()
  412. door_vo:CreateDoorInfo(info)
  413. door_vo.id = doorId --流水id
  414. if IntrusionModel:getInstance().default_server_rank_list[door_vo.index] then
  415. doorId = doorId + 1
  416. self:AddDoorVo(door_vo)
  417. end
  418. end
  419. else
  420. for id, info in pairs(doors) do
  421. local door_vo = DoorVo.New()
  422. door_vo:CreateDoorInfo(info)
  423. door_vo.id = doorId --流水id
  424. doorId = doorId + 1
  425. self:AddDoorVo(door_vo)
  426. end
  427. local info = Config.ConfigDoorInSameScene[SceneManager.Instance:GetSceneId()]
  428. if info then
  429. for id, info in pairs(Config.ConfigDoorInSameScene[SceneManager.Instance:GetSceneId()]) do --在同一个场景里的传送门
  430. local door_vo = DoorVo.New()
  431. door_vo:CreateDoorInfo(info)
  432. door_vo.id = doorId --流水id
  433. -- print("创建传送门 ",door_vo.id)
  434. -- door_vo.enter_scene_id = door_vo.enter_scene_id.."-"..door_vo.index
  435. door_vo.is_same_scene = true
  436. door_vo.enter_scene_name = info.name
  437. doorId = doorId + 1
  438. self:AddDoorVo(door_vo)
  439. end
  440. end
  441. end
  442. end
  443. local npcs = self:GetNpcList()
  444. for id, info in pairs(npcs) do
  445. local npc_id = info.instance_id or info.npc_id
  446. if npc_id ~= 0 then
  447. if info.is_show == 0 then
  448. if self.npc_vo_list[npc_id] then
  449. self:DeleteNpcVo(npc_id)
  450. end
  451. else
  452. local npc_info = NpcVo.New()
  453. npc_info:CreateNpcInfo(info)
  454. self:AddNpcVo(npc_info)
  455. end
  456. end
  457. end
  458. self.npc_doors_loaded = true
  459. end
  460. function SceneManager:SceneStart()
  461. self.isStart = true
  462. self:TryFireStartEvent()
  463. end
  464. function SceneManager:TryFireStartEvent()
  465. if not self.isStart or GlobalEventSystem == nil then
  466. return
  467. end
  468. GlobalEventSystem:Fire(SceneManager.START)
  469. end
  470. function SceneManager:IsSceneStart()
  471. return self.isStart
  472. end
  473. function SceneManager:AddJumpPointVo( jump_vo)
  474. self.jump_vo_list[jump_vo.instance_id] = jump_vo
  475. GlobalEventSystem:Fire(SceneEventType.JUMPPOINT_VO_ADD, jump_vo)
  476. end
  477. function SceneManager:ClearAllJumpPointVo( )
  478. for k, _ in pairs(self.jump_vo_list) do
  479. GlobalEventSystem:Fire(SceneEventType.JUMPPOINT_VO_REMOVE, k)
  480. end
  481. self.jump_vo_list = {}
  482. end
  483. --[[@
  484. : VoManager
  485. :
  486. enter_scene_id ID int32
  487. door_vo Vo结构体 Vo
  488. :
  489. :
  490. ]]
  491. function SceneManager:AddDoorVo( door_vo)
  492. local id = door_vo.enter_scene_id
  493. if door_vo.is_same_scene then
  494. id = door_vo.enter_scene_id.."-"..door_vo.index
  495. end
  496. self.door_vo_list[id] = door_vo
  497. GlobalEventSystem:Fire(SceneEventType.DOOR_VO_ADD, id, door_vo)
  498. end
  499. --[[@
  500. :
  501. ]]
  502. function SceneManager:GetTheDoorVo( )
  503. for k,v in pairs(self.door_vo_list) do
  504. return v
  505. end
  506. end
  507. --[[@
  508. : ID获取一个门点信息
  509. :
  510. enter_scene_id ID int32
  511. :
  512. Vo
  513. :
  514. ]]
  515. function SceneManager:GetDoorVo( enter_scene_id )
  516. return self.door_vo_list[enter_scene_id]
  517. end
  518. function SceneManager:GetDoorVoList()
  519. return self.door_vo_list
  520. end
  521. function SceneManager:ClearAllDoorVo( )
  522. for k,vo in pairs(self.door_vo_list) do
  523. -- local id = k
  524. -- if vo.is_same_scene then
  525. -- id = vo.enter_scene_id.."-"..vo.index
  526. -- end
  527. GlobalEventSystem:Fire(SceneEventType.DOOR_VO_REMOVE, k)
  528. end
  529. self.door_vo_list = {}
  530. end
  531. function SceneManager:GetNpcList()
  532. return self.sceneNpcList
  533. end
  534. function SceneManager:SetNpcList(list)
  535. self.sceneNpcList = list
  536. end
  537. function SceneManager:UpdateNpcListPos(npc_id, real_x, real_y)
  538. if self.sceneNpcList[npc_id] then
  539. self.sceneNpcList[npc_id].pos_x = real_x
  540. self.sceneNpcList[npc_id].pos_y = real_y
  541. end
  542. end
  543. function SceneManager:GetSceneNpcInfoByID( npc_id )
  544. return self.sceneNpcList[npc_id]
  545. end
  546. --[[@
  547. : Npc信息到Manger
  548. :
  549. npc_ins_id Npc实例ID int32
  550. npc_vo NpcVo信息 object
  551. :
  552. :
  553. ]]
  554. function SceneManager:AddNpcVo(npc_vo)
  555. self.npc_vo_list[npc_vo.instance_id] = npc_vo
  556. self.sceneNpcList[npc_vo.instance_id] = npc_vo
  557. GlobalEventSystem:Fire(SceneEventType.NPC_VO_ADD, npc_vo.instance_id, npc_vo)
  558. end
  559. function SceneManager:DynamicAddNpc(npcid,npc_x,npc_y, args)
  560. if npcid and npc_x and npc_y then
  561. local npc_info = NpcVo.New()
  562. local info = {npc_id = npcid, pos_x = npc_x, pos_y = npc_y, args = args}
  563. npc_info:CreateNpcInfo(info)
  564. npc_info.pos_x = npc_x --X坐标(int16)
  565. npc_info.pos_y = npc_y --Y坐标(int16)
  566. npc_info.logic_x = npc_info.pos_x / SceneObj.LogicRealRatio.x
  567. npc_info.logic_y = npc_info.pos_y / SceneObj.LogicRealRatio.y
  568. print("= = =添加NPC:", npc_info.pos_x, npc_info.pos_y)
  569. self:AddNpcVo(npc_info)
  570. end
  571. end
  572. --[[@
  573. : Npc
  574. :
  575. :
  576. :
  577. : deadline
  578. ]]
  579. function SceneManager:DynamicDelNpc(npcid)
  580. if self.npc_vo_list[npcid] then
  581. self:DeleteNpcVo(npcid)
  582. end
  583. end
  584. --[[@
  585. : Npc信息
  586. :
  587. npc_ins_id Npc实例ID int32
  588. :
  589. Npc信息
  590. :
  591. ]]
  592. function SceneManager:GetNpcVo( npc_ins_id )
  593. return self.npc_vo_list[npc_ins_id]
  594. end
  595. --[[@
  596. : Npc Vo信息
  597. :
  598. :
  599. :
  600. ]]
  601. function SceneManager:ClearAllNpcVo( )
  602. for k,_ in pairs(self.npc_vo_list) do
  603. GlobalEventSystem:Fire(SceneEventType.NPC_VO_REMOVE, k)
  604. end
  605. self.npc_vo_list = {}
  606. end
  607. --[[
  608. npc
  609. .
  610. ]]
  611. function SceneManager:DeleteNpcVo(id)
  612. if self.npc_vo_list[id] ~= nil then
  613. GlobalEventSystem:Fire(SceneEventType.NPC_VO_REMOVE, id)
  614. end
  615. self.sceneNpcList[id] = nil
  616. self.npc_vo_list[id] = nil
  617. end
  618. --添加怪物类型
  619. function SceneManager:AddMonsterType(monsterTypeVo)
  620. self.monster_type_list[monsterTypeVo.type_id] = monsterTypeVo
  621. end
  622. --[[
  623. vo
  624. .
  625. ]]
  626. -- function SceneManager:GetMonsterType(type_id)
  627. -- return self.monster_type_list[type_id]
  628. -- end
  629. -- function SceneManager:GetAllMonsterTypes()
  630. -- return self.monster_type_list
  631. -- end
  632. --获取指定场景中的所有怪物类型
  633. -- function SceneManager:GetMonsterTypeInScene(scene_id)
  634. -- self.monster_type_in_scenes = self.monster_type_in_scenes or {}
  635. -- local monster_types = self.monster_type_in_scenes[scene_id]
  636. -- return monster_types
  637. -- end
  638. -- function SceneManager:AddMonsterTypeInScene(scene_id, types)
  639. -- self.monster_type_in_scenes[scene_id] = types
  640. -- end
  641. --[[@
  642. : Vo信息到Manager
  643. :
  644. ins_id ID int32
  645. monster_vo Vo信息 MonsterVo
  646. isdelay
  647. :
  648. :
  649. ]]
  650. function SceneManager:AddMonsterVo( monster_vo, isdelay )
  651. -- if self:GetMonsterType(monster_vo.type_id) == nil then
  652. -- local monsterTypeVo = MonsterTypeVo.New()
  653. -- monsterTypeVo.type_id = monster_vo.type_id
  654. -- monsterTypeVo.name = monster_vo.name
  655. -- monsterTypeVo.type = monster_vo.type
  656. -- monsterTypeVo.pos_x = monster_vo.pos_x
  657. -- monsterTypeVo.pos_y = monster_vo.pos_y
  658. -- monsterTypeVo.level = monster_vo.level
  659. -- monsterTypeVo.guaji_flag = monster_vo.guaji_flag
  660. -- monsterTypeVo.boss_type = monster_vo.boss_type
  661. -- monsterTypeVo.res_id = monster_vo.monster_res
  662. -- self:AddMonsterType(monsterTypeVo)
  663. -- end
  664. if self:IsInRecordPreMonsterData(monster_vo.instance_id) then
  665. if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].name then
  666. monster_vo.name = self.record_pre_monster_data[monster_vo.instance_id].name
  667. end
  668. if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].level then
  669. monster_vo.level = self.record_pre_monster_data[monster_vo.instance_id].level
  670. end
  671. if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].hp then
  672. monster_vo.hp = self.record_pre_monster_data[monster_vo.instance_id].hp
  673. end
  674. if self.record_pre_monster_data[monster_vo.instance_id] and self.record_pre_monster_data[monster_vo.instance_id].maxHp then
  675. monster_vo.maxHp = self.record_pre_monster_data[monster_vo.instance_id].maxHp
  676. end
  677. end
  678. isdelay = isdelay or false
  679. if isdelay == true and monster_vo.load_immediately ~= 1 then --延迟加载
  680. self.delay_monster_list:PushBack(monster_vo)
  681. else
  682. self.monster_vo_list[monster_vo.instance_id] = monster_vo
  683. GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_ADD, monster_vo.instance_id, monster_vo)
  684. end
  685. end
  686. --12090 怪物改名,改名可能比创怪完毕更早来,没找到对象时先记录一下 ,创怪时再重新赋值
  687. function SceneManager:RecordPreMonsterData(instance_id,data)
  688. self.record_pre_monster_data[instance_id] = self.record_pre_monster_data[instance_id] or {}
  689. self.record_pre_monster_data[instance_id].id = instance_id
  690. if data.name then
  691. self.record_pre_monster_data[instance_id].name = data.name
  692. end
  693. if data.level then
  694. self.record_pre_monster_data[instance_id].level = data.level
  695. end
  696. if data.hp then
  697. self.record_pre_monster_data[instance_id].hp = data.hp
  698. end
  699. if data.maxHp then
  700. self.record_pre_monster_data[instance_id].maxHp = data.maxHp
  701. end
  702. end
  703. function SceneManager:IsInRecordPreMonsterData(instance_id)
  704. for k,v in pairs(self.record_pre_monster_data) do
  705. if instance_id == v.id then
  706. return true
  707. end
  708. end
  709. return false
  710. end
  711. function SceneManager:ClearRecordPreMonsterData(instance_id)
  712. if self.record_pre_monster_data and self.record_pre_monster_data[instance_id] then
  713. self.record_pre_monster_data[instance_id] = nil
  714. end
  715. end
  716. --[[@
  717. : ID获取怪物Vo信息
  718. :
  719. ins_id ID int32
  720. :
  721. Vo信息 MonsterVo
  722. :
  723. ]]
  724. function SceneManager:GetMonsterVo( ins_id )
  725. return self.monster_vo_list[ins_id]
  726. end
  727. --删除指定类型的怪物
  728. function SceneManager:DeleteMonstersByType(type_id)
  729. for i, v in pairs(self.monster_vo_list) do
  730. if v.type_id == type_id and not v.is_client_monster then
  731. self:DeleteMonsterVo(v.instance_id, SceneManager.DELETE_MONSTER_BY_TYPE)
  732. end
  733. end
  734. end
  735. --根据唯一id 获取客户端剧情怪物
  736. function SceneManager:GetClientMonsterVoByInstanceId(ins_id)
  737. local monster_vo = self.monster_vo_list[ins_id]
  738. if monster_vo and monster_vo.is_client_monster then
  739. return monster_vo
  740. end
  741. return nil
  742. end
  743. --删除指定类型的怪物,用于剧情
  744. function SceneManager:DeleteClientMonstersByInstanceId(ins_id)
  745. local monster_vo = self.monster_vo_list[ins_id]
  746. if monster_vo and monster_vo.is_client_monster then
  747. self:DeleteMonsterVo(ins_id, SceneManager.DELETE_MONSTER_BY_TYPE)
  748. end
  749. end
  750. --删除指定类型的怪物,用于剧情
  751. function SceneManager:DeleteClientMonstersByType(type_id)
  752. for i, v in pairs(self.monster_vo_list) do
  753. if v.type_id == type_id and v.is_client_monster then
  754. self:DeleteMonsterVo(v.instance_id, SceneManager.DELETE_MONSTER_BY_TYPE)
  755. end
  756. end
  757. end
  758. function SceneManager:GetClientMonsterVoByTypeId(type_id)
  759. for id, monster_vo in pairs(self.monster_vo_list) do
  760. if monster_vo.type_id == type_id and monster_vo.is_client_monster then
  761. return monster_vo
  762. end
  763. end
  764. return nil
  765. end
  766. function SceneManager:GetMonsterVoByTypeId(type_id)
  767. for id, monster_vo in pairs(self.monster_vo_list) do
  768. if monster_vo.type_id == type_id then
  769. return monster_vo
  770. end
  771. end
  772. local size = self.delay_monster_list:GetSize()
  773. if size > 0 then
  774. for index = 0, size - 1 do
  775. local monster_vo = self.delay_monster_list:Get(index)
  776. if monster_vo.type_id == type_id then
  777. return monster_vo
  778. end
  779. end
  780. end
  781. return nil
  782. end
  783. --获取随机一个不等于not_instance_id的怪物
  784. function SceneManager:GetRandomMonsterVoByTypeId(type_id, not_instance_id)
  785. local tb = {}
  786. for id, monster_vo in pairs(self.monster_vo_list) do
  787. if monster_vo.type_id == type_id then
  788. table_insert(tb, monster_vo)
  789. end
  790. end
  791. if #tb > 1 then
  792. local times = 0
  793. while times<1000 do
  794. times = times + 1
  795. local rand = math.random(1, #tb)
  796. if tb[rand] and tb[rand].instance_id~=not_instance_id then
  797. return tb[rand]
  798. end
  799. end
  800. elseif #tb==1 and tb[1].instance_id~=not_instance_id then --只有一只怪物
  801. return tb[1]
  802. end
  803. return nil
  804. end
  805. function SceneManager:GetDelayMonsterVo(ins_id)
  806. local size = self.delay_monster_list:GetSize()
  807. if size > 0 then
  808. for index = 0, size - 1 do
  809. local info = self.delay_monster_list:Get(index)
  810. if info and ins_id == info.instance_id then
  811. return info
  812. end
  813. end
  814. end
  815. end
  816. function SceneManager:GetDelayMonsterNum()
  817. local size = self.delay_monster_list:GetSize()
  818. return size
  819. end
  820. --从延迟加载列表中取一个vo并创建
  821. function SceneManager:AddDelaydMonsterVo()
  822. local size = self.delay_monster_list:GetSize()
  823. if size > 0 then
  824. local vo = self.delay_monster_list:PopFront()
  825. self:AddMonsterVo(vo)
  826. end
  827. end
  828. --[[@
  829. : ID移除一个怪物Vo信息
  830. :
  831. ins_id ID int32
  832. :
  833. :
  834. ]]
  835. SceneManager.DELETE_MONSTER_WAVE_RESET = 1
  836. SceneManager.DELETE_MONSTER_BATTLE_GROUND = 2
  837. SceneManager.DELETE_MONSTER_OUTLAND_WAR = 3
  838. SceneManager.DELETE_MONSTER_RESULT_VIEW = 4
  839. SceneManager.DELETE_MONSTER_DEAD = 5
  840. SceneManager.DELETE_MONSTER_12006 = 6
  841. SceneManager.DELETE_MONSTER_BY_TYPE = 7
  842. SceneManager.DELETE_MONSTER_FIGHT_ERROR = 8
  843. SceneManager.DELETE_MONSTER_AI = 9
  844. function SceneManager:DeleteMonsterVo( ins_id , delete_type)
  845. local size = self.delay_monster_list:GetSize()
  846. local vo = self.monster_vo_list[ins_id]
  847. local type_id = vo and vo.type_id
  848. if vo == nil then
  849. if size > 0 then
  850. for index = 0, size - 1 do
  851. local info = self.delay_monster_list:Get(index)
  852. if info and ins_id == info.instance_id then
  853. type_id = info.type_id
  854. self.delay_monster_list:Erase(index)
  855. break
  856. end
  857. end
  858. end
  859. else
  860. self:ClearRecordPreMonsterData(ins_id)
  861. self.monster_vo_list[ins_id] = nil
  862. end
  863. if vo then
  864. GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_REMOVE, ins_id, type_id,vo)
  865. end
  866. return vo
  867. end
  868. function SceneManager:GetAllMonsterVo()
  869. return self.monster_vo_list
  870. end
  871. function SceneManager:ClearAllMonsterVo()
  872. for k, vo in pairs(self.monster_vo_list) do
  873. GlobalEventSystem:Fire(SceneEventType.MONSTER_VO_REMOVE, vo.instance_id, vo.type_id,vo)
  874. end
  875. self.delay_monster_list = Array.New() --延迟加载的怪物列表
  876. self.monster_vo_list = {}
  877. end
  878. function SceneManager:AddMonsterVoPool(vo)
  879. if self.monster_vo_pool:GetSize() < 40 then
  880. vo:ResetData()
  881. self.monster_vo_pool:PushBack(vo)
  882. end
  883. end
  884. function SceneManager:CreateMonsterVo()
  885. if self.monster_vo_pool:GetSize() > 0 then
  886. return self.monster_vo_pool:PopFront()
  887. end
  888. return MonsterVo.New()
  889. end
  890. function SceneManager:AddRoleVoPool(vo)
  891. if self.role_vo_pool:GetSize() < 40 then
  892. vo:ResetData()
  893. self.role_vo_pool:PushBack(vo)
  894. end
  895. end
  896. function SceneManager:CreateRoleVo()
  897. if self.role_vo_pool:GetSize() > 0 then
  898. return self.role_vo_pool:PopFront()
  899. end
  900. return RoleVo.New()
  901. end
  902. function SceneManager:AddOtherVo(other_vo)
  903. self.other_vo_list[other_vo.instance_id] = other_vo
  904. GlobalEventSystem:Fire(SceneEventType.OTHER_VO_ADD, other_vo.instance_id, other_vo)
  905. end
  906. function SceneManager:GetOtherVo( ins_id )
  907. return self.other_vo_list[ins_id]
  908. end
  909. function SceneManager:DeleteOtherVo( ins_id)
  910. local vo = self:GetOtherVo(ins_id)
  911. if vo then
  912. self.other_vo_list[ins_id] = nil
  913. GlobalEventSystem:Fire(SceneEventType.OTHER_VO_REMOVE, ins_id, vo)
  914. return vo
  915. end
  916. end
  917. function SceneManager:GetAllOtherVo()
  918. return self.other_vo_list
  919. end
  920. function SceneManager:ClearAllOtherVo()
  921. for k, vo in pairs(self.other_vo_list) do
  922. GlobalEventSystem:Fire(SceneEventType.OTHER_VO_REMOVE, vo.instance_id, vo)
  923. end
  924. self.other_vo_list = {}
  925. end
  926. function SceneManager:getMonsterList()
  927. local ret = {}
  928. for _, vo in pairs(self.monster_vo_list) do
  929. table_insert(ret, vo)
  930. end
  931. local size = self.delay_monster_list:GetSize()
  932. if size > 0 then
  933. for index = 0, size - 1 do
  934. local vo = self.delay_monster_list:Get(index)
  935. table_insert(ret, vo)
  936. end
  937. end
  938. return ret
  939. end
  940. --重置缓存角色vo的队列
  941. function SceneManager:ResetCachedRoleList()
  942. self:ClearDelayAllRoleVo() -- 清空 延迟加载的玩家数据
  943. end
  944. function SceneManager:AddRoleVo(role_vo, is_from_server)
  945. local role_id = role_vo.role_id
  946. local main_role_id = RoleManager.Instance:GetMainRoleId()
  947. if role_id == main_role_id then
  948. RoleManager.Instance.mainRoleInfo:ChangeFromVo(role_vo)
  949. self.server_role_num = self.server_role_num + 1
  950. return
  951. end
  952. --如果是从服务端发来的角色信息,就把角色vo缓存起来,分帧创建,切换场景清空
  953. if is_from_server then
  954. if self.role_vo_list[role_id] == nil then --新增的情况数量加一
  955. self.server_role_num = self.server_role_num + 1
  956. self:AddDelayRoleTable(role_vo)
  957. return
  958. end
  959. end
  960. if self.role_vo_list[role_id] == nil then --新增的情况数量加一
  961. self.client_role_num = self.client_role_num + 1
  962. end
  963. self.role_vo_list[role_id] = role_vo
  964. EventSystem.Fire(GlobalEventSystem,SceneEventType.ROLE_VO_ADD, role_id, role_vo)
  965. role_vo.particle_priority = 2
  966. end
  967. --[[@
  968. : ID获取一个角色信息
  969. :
  970. role_id ID int32
  971. :
  972. RoleVo
  973. :
  974. : deadline
  975. ]]
  976. function SceneManager:GetRoleVo( role_id )
  977. if role_id == RoleManager.Instance:GetMainRoleId() then
  978. return RoleManager.Instance.mainRoleInfo
  979. else
  980. return self.role_vo_list[role_id]
  981. end
  982. end
  983. --[[
  984. :
  985. xinyy
  986. ]]
  987. function SceneManager:GetAllRoleVos( )
  988. return self.role_vo_list
  989. end
  990. --[[@
  991. : ID从Manager中移除一个角色信息
  992. :
  993. role_id ID int32
  994. :
  995. :
  996. : deadline
  997. ]]
  998. function SceneManager:DeleteRoleVo( role_id )
  999. if role_id == RoleManager.Instance:GetMainRoleId() then
  1000. return
  1001. end
  1002. --删除延迟加载列表
  1003. self:DeleteDelayRoleVo(role_id)
  1004. if self.role_vo_list[role_id] ~= nil then
  1005. self.server_role_num = self.server_role_num - 1
  1006. self.client_role_num = self.client_role_num - 1
  1007. self.role_vo_list[role_id] = nil
  1008. GlobalEventSystem:Fire(SceneEventType.ROLE_VO_REMOVE, role_id)
  1009. end
  1010. end
  1011. --[[@
  1012. :
  1013. :
  1014. :
  1015. :
  1016. : deadline
  1017. ]]
  1018. function SceneManager:ClearAllRoleVo( )
  1019. for k, _ in pairs(self.role_vo_list) do
  1020. GlobalEventSystem:Fire(SceneEventType.ROLE_VO_REMOVE, k)
  1021. end
  1022. self.role_vo_list = {}
  1023. self.client_role_num = 0
  1024. self.server_role_num = 0
  1025. end
  1026. --立马加载角色
  1027. function SceneManager:ImmeAddRoleVo(role_id)
  1028. local delay_role_len = #self.delay_role_vo_list
  1029. local vo = nil
  1030. for i = 1, delay_role_len do
  1031. vo = self.delay_role_vo_list[i]
  1032. if vo.role_id == role_id then
  1033. table_remove(self.delay_role_vo_list, i)
  1034. self:AddRoleVo(vo)
  1035. return
  1036. end
  1037. end
  1038. end
  1039. -- 分帧加载玩家
  1040. function SceneManager:AddDelayRoleTable( role )
  1041. table_insert(self.delay_role_vo_list, role)
  1042. end
  1043. function SceneManager:AddDelayRoleVo()
  1044. --限制场景最大数量
  1045. if self.client_role_num >= self.role_limit_num then
  1046. return
  1047. end
  1048. local n = #self.delay_role_vo_list
  1049. if n > 0 then
  1050. local role_vo = self.delay_role_vo_list[n]
  1051. self.delay_role_vo_list[n] = nil
  1052. self:AddRoleVo(role_vo)
  1053. end
  1054. end
  1055. --删除延迟加载列表
  1056. function SceneManager:DeleteDelayRoleVo(role_id)
  1057. local delay_role_len = #self.delay_role_vo_list
  1058. local vo = nil
  1059. for i = 1, delay_role_len do
  1060. vo = self.delay_role_vo_list[i]
  1061. if vo.role_id == role_id then
  1062. table_remove(self.delay_role_vo_list,i)
  1063. break
  1064. end
  1065. end
  1066. end
  1067. -- 2020年9月12日新增 某些状态改变的逻辑要获取到未加载的vo
  1068. function SceneManager:GetDelayRoleVo(role_id)
  1069. local delay_role_len = #self.delay_role_vo_list
  1070. local vo = nil
  1071. for i = 1, delay_role_len do
  1072. vo = self.delay_role_vo_list[i]
  1073. if vo.role_id == role_id then
  1074. return vo
  1075. end
  1076. end
  1077. return nil
  1078. end
  1079. function SceneManager:GetDelayRoleNum()
  1080. return #self.delay_role_vo_list
  1081. end
  1082. function SceneManager:ClearDelayAllRoleVo()
  1083. self.delay_role_vo_list = {}
  1084. end
  1085. --获取除了主角以外的场景对象
  1086. function SceneManager:GetSceneObjVo(instance_id)
  1087. local vo = SceneManager.Instance:GetMonsterVo(instance_id)
  1088. if vo then
  1089. return vo, SceneBaseType.Monster
  1090. end
  1091. vo = SceneManager.Instance:GetRoleVo(instance_id)
  1092. or SceneManager.Instance:GetOtherVo(instance_id)
  1093. return vo
  1094. end
  1095. --创建分身
  1096. function SceneManager:CreateCloneRole(role_id, x, y, horse_id, birth_angle, name, head_wear_id)
  1097. local mvo = self:GetRoleVo(role_id)
  1098. if mvo == nil then
  1099. print("分身的主体死了,不能再创建分身")
  1100. return
  1101. end
  1102. local vo = RoleVo.New()
  1103. self.clone_role_id_count = self.clone_role_id_count + 1
  1104. vo.role_id = self.clone_role_start_id + self.clone_role_id_count --用户ID(int32)
  1105. vo.plat_name = mvo.plat_name --平台名(string)
  1106. vo.server_id = mvo.server_id --服ID(int16)
  1107. vo.name = name or "" --玩家名(string)
  1108. vo.pos_x = x or mvo.pos_x --X像素坐标(int16)
  1109. vo.pos_y = y or mvo.pos_y --Y像素坐标(int16)
  1110. vo.level = 1
  1111. vo.hp = mvo.hp
  1112. vo.maxHp = mvo.maxHp
  1113. vo.career = mvo.career
  1114. vo.move_speed = mvo.move_speed
  1115. vo.vip_flag = mvo.vip_flag
  1116. vo.fighting = mvo.fighting
  1117. vo.imageId = mvo.imageId
  1118. vo.warGroup = mvo.warGroup
  1119. vo.head_wear_id = mvo.head_wear_id
  1120. vo.birth_angle = birth_angle or 0
  1121. vo.fashion_model_list = mvo.fashion_model_list
  1122. vo.level_model_list = mvo.level_model_list
  1123. vo.horse_id = horse_id
  1124. vo.is_ride = 1
  1125. vo.is_virtual_friend = true
  1126. vo.create_time = Status.NowTime
  1127. self:AddRoleVo(vo)
  1128. return vo.role_id
  1129. end
  1130. function SceneManager:AddPartnerVo(partner_vo)
  1131. local partner_id = partner_vo.partner_id
  1132. self.partner_vo_list[partner_id] = partner_vo
  1133. GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_ADD, partner_id, partner_vo)
  1134. partner_vo.particle_priority = 2
  1135. end
  1136. function SceneManager:GetPartnerVo( partner_id )
  1137. return self.partner_vo_list[partner_id]
  1138. end
  1139. function SceneManager:GetAllPartnerVos( )
  1140. return self.partner_vo_list
  1141. end
  1142. function SceneManager:DeletePartnerVo( partner_id )
  1143. local vo = self:GetPartnerVo(partner_id)
  1144. if vo ~= nil then
  1145. self.partner_vo_list[partner_id] = nil
  1146. GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_REMOVE, partner_id)
  1147. return vo
  1148. end
  1149. end
  1150. function SceneManager:ClearAllPartnerVo( )
  1151. for k, _ in pairs(self.partner_vo_list) do
  1152. GlobalEventSystem:Fire(SceneEventType.PARTNER_VO_REMOVE, k)
  1153. end
  1154. self.partner_vo_list = {}
  1155. end
  1156. function SceneManager:IsBlockXY(x, y, jump_state)
  1157. local state = MapView:getInstance():IsBlockXY(x,y,jump_state)
  1158. return state
  1159. end
  1160. function SceneManager:IsAreaType(x, y, area_type)
  1161. local state = MapView:getInstance():IsAreaType(x,y,area_type)
  1162. return state
  1163. end
  1164. function SceneManager:CheckIsInScreen(x, y)
  1165. local camera_pos = MainCamera.Instance:GetCameraPos()
  1166. local ratio = MainCamera.Instance:GetCameraRatio()
  1167. -- 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)
  1168. 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
  1169. return false
  1170. end
  1171. return true
  1172. end
  1173. function SceneManager:GetAngle(pos1, pos2, real_pos)
  1174. local x = 0
  1175. local y = 0
  1176. if real_pos then
  1177. x = pos2.x - pos1.x
  1178. y = pos2.y - pos1.y
  1179. else
  1180. x = pos1
  1181. y = pos2
  1182. end
  1183. local hyp = math_sqrt(math_pow(x, 2) + math_pow(y, 2))
  1184. if hyp == 0 then
  1185. return 0
  1186. end
  1187. local cos = x / hyp
  1188. local radian = math_acos(cos)
  1189. if radian == 0 then
  1190. return 0
  1191. end
  1192. local angle = 180 / (math_pi / radian)
  1193. if y < 0 then
  1194. angle = 360 - angle
  1195. end
  1196. return math_floor(angle + 0.5)
  1197. end
  1198. --得到textureshader 普通模型的默认shader 无alpha透明通道
  1199. function SceneManager:GetTextureShader()
  1200. if self.texture_shader == nil then
  1201. self.texture_shader = Shader.Find( "Unlit/Texture")
  1202. end
  1203. return self.texture_shader
  1204. end
  1205. --得到Alphatextureshader 有alpha透明通道 已经可以更改颜色
  1206. function SceneManager:GetColorTextureShader()
  1207. if self.color_texture_shader == nil then
  1208. self.color_texture_shader = ShaderTools.GetShader("Alpha_shader")
  1209. end
  1210. return self.color_texture_shader
  1211. end
  1212. --变灰shader
  1213. function SceneManager:GetGrayShader()
  1214. if self.gray_shader == nil then
  1215. self.gray_shader = ShaderTools.GetShader("Gray_level_shader")
  1216. end
  1217. return self.gray_shader
  1218. end
  1219. function SceneManager:SetGrayShader(monster_id,material,shader)
  1220. shader = shader or self:GetGrayShader()
  1221. if monster_id and material then
  1222. material.shader = shader
  1223. local config = Config.ConfigModelGray.info[monster_id] or Config.ConfigModelGray.info.default
  1224. if config then
  1225. --Unlit - Texture 自带一个灰度颜色,要重置
  1226. material:SetColor("_Color",Color(1,1,1,1))
  1227. material:SetFloat("_inBlack",config.input_black)
  1228. material:SetFloat("_inGamma",config.input_gamma)
  1229. material:SetFloat("_inWhite",config.input_white)
  1230. material:SetFloat("_outWhite",config.output_white)
  1231. material:SetFloat("_outBlack",config.output_black)
  1232. end
  1233. end
  1234. end
  1235. --[[
  1236. --模型UI遮罩Shader 根据本身shader,获取对应的遮罩shader
  1237. function SceneManager:GetModelMaskShader(cur_shader_name)
  1238. if cur_shader_name == "Unlit/Texture" or cur_shader_name == "Unlit/AlphaTexture" then
  1239. self.modelMask_shader = ShaderTools.GetShader("Unlit_Texture_Mask") --普通无光材质
  1240. elseif cur_shader_name == "Custom/mb_flowalphablendmask" or cur_shader_name == "Custom/mb_flowalphablendmask_transparentculloff" or cur_shader_name == "Custom/mb_flowalphablendmaskui" then
  1241. self.modelMask_shader = ShaderTools.GetShader("mb_flowalphablendmask_mask") --波塞冬的水波纹材质
  1242. elseif cur_shader_name == "Custom/mb_uvrolladd_culloff" then
  1243. self.modelMask_shader = ShaderTools.GetShader("mb_uvrolladd_culloff_mask")
  1244. elseif cur_shader_name == "Custom/mb_uvrollalphablend_culloff" or cur_shader_name == "Custom/mb_uvrollalphablend" then
  1245. self.modelMask_shader = ShaderTools.GetShader("mb_uvrollalphablend_culloff_mask")
  1246. elseif cur_shader_name == "Particles/Additive" or cur_shader_name == "Mobile/Particles/Additive" or cur_shader_name == "NoFog/Particles/Additive" then
  1247. self.modelMask_shader = ShaderTools.GetShader("ParticleAdd_mask")
  1248. elseif cur_shader_name == "Particles/Blend" then
  1249. self.modelMask_shader = ShaderTools.GetShader("ParticleBlend_mask")
  1250. 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
  1251. self.modelMask_shader = ShaderTools.GetShader("ParticleAlphaBlend_mask")
  1252. elseif cur_shader_name == "Custom/mb_uvrolladd" then
  1253. self.modelMask_shader = ShaderTools.GetShader("mb_uvrolladd_mask")
  1254. else
  1255. return nil
  1256. end
  1257. return self.modelMask_shader
  1258. end
  1259. --设置UI遮罩模型
  1260. -- mask_img ui遮罩
  1261. -- model_root 需要遮罩的模型根对象
  1262. -- part_name 需要遮罩的模型部件,因为有些模型是有很多挂件的,比如武器,翅膀,可以针对模型的部件进行遮罩
  1263. -- mask_Tex 遮罩的mask,如果不传,默认用 mask_img 的sprite
  1264. function SceneManager:SetModelMaskShader(mask_img,model_root,part_name,mask_Tex)
  1265. if not model_root or not model_root.gameObject or not mask_img then
  1266. -- print("参数错误 mask_img: "..mask_img.." model_root: ",model_root.gameObject)
  1267. return
  1268. end
  1269. local target_root
  1270. if part_name then
  1271. target_root = model_root.gameObject.transform:Find(part_name) --rhand
  1272. else
  1273. target_root = model_root.transform --rhand
  1274. end
  1275. if target_root then
  1276. self:SetModelMaskShaderInEveryChild(target_root,mask_img,mask_Tex)
  1277. else
  1278. print("没有找到对应的挂件 ",part_name)
  1279. end
  1280. end
  1281. function SceneManager:SetModelMaskShaderInEveryChild(root,mask_img,mask_Tex)
  1282. self:SetSingleModelMaskShader(root,mask_img,mask_Tex)
  1283. if root.childCount > 0 then
  1284. for i=0,root.childCount - 1 do
  1285. self:SetModelMaskShaderInEveryChild(root:GetChild(i),mask_img,mask_Tex)
  1286. end
  1287. end
  1288. end
  1289. function SceneManager:SetSingleModelMaskShader(target,mask_img,mask_Tex)
  1290. local coms = target.gameObject:GetComponent(typeof(UnityEngine.Renderer))
  1291. self:SetSingleModelMaskShaderWithCom(coms,mask_img,mask_Tex)
  1292. end
  1293. function SceneManager:SetSingleModelMaskShaderWithCom(com,mask_img,mask_Tex)
  1294. if not com then
  1295. return
  1296. end
  1297. for i = 0, com.materials.Length - 1 do
  1298. local material = com.materials[i] --这里不能用 sharedMaterial 不能改变他原有的shader,只是临时改变
  1299. local shader = self:GetModelMaskShader(material.shader.name)
  1300. -- print("寻找对应的shader "..material.shader.name,shader.name)
  1301. if string.find (material.shader.name,"UIMask") then
  1302. return
  1303. end
  1304. if not shader then
  1305. print("没有找到对应的Shader "..material.shader.name)
  1306. return
  1307. end
  1308. local rectTran = mask_img:GetComponent("RectTransform")
  1309. local img = mask_img:GetComponent("Image")
  1310. if not img then
  1311. print("没有找到遮罩组件 Image")
  1312. return
  1313. end
  1314. material.shader = shader
  1315. local corners = ToVector3Array({Vector3,Vector3,Vector3,Vector3})
  1316. if not corners then
  1317. print("Vector3返回空值,请更新版本")
  1318. return
  1319. end
  1320. rectTran:GetWorldCorners(corners)
  1321. local minX = corners[0].x;
  1322. local minY = corners[0].y;
  1323. local maxX = corners[2].x;
  1324. local maxY = corners[2].y;
  1325. material:SetTexture("_MaskTex",mask_Tex or img.sprite.texture);
  1326. material:SetFloat("_MinX", minX);
  1327. material:SetFloat("_MinY", minY);
  1328. material:SetFloat("_MaxX", maxX);
  1329. material:SetFloat("_MaxY", maxY);
  1330. end
  1331. end
  1332. ]]
  1333. -----------------------------------------场景判断---------------------------------
  1334. function SceneManager:GetCacheSceneType( )
  1335. if rawget(self, "cache_scene_type") then
  1336. return self.cache_scene_type, self.cache_scene_broadcast
  1337. end
  1338. local info = self:GetSceneInfo()
  1339. if not info then
  1340. return
  1341. end
  1342. self.cache_scene_type = info.type
  1343. self.cache_scene_broadcast = info.broadcast and info.broadcast == 1
  1344. return self.cache_scene_type, self.cache_scene_broadcast
  1345. end
  1346. function SceneManager:ResetCacheSceneType( )
  1347. self.cache_scene_type = false
  1348. self.cache_scene_broadcast = false
  1349. end
  1350. --[[
  1351. id
  1352. ]]
  1353. function SceneManager:IsFirstScene()
  1354. return false
  1355. end
  1356. --[[
  1357. ]]
  1358. function SceneManager:IsMission()
  1359. return self:GetCurrDunId() ~= 0
  1360. end
  1361. --[[
  1362. ]]
  1363. function SceneManager:IsMainCityorYieldScene(scene_id)
  1364. local sceneInfo = self:GetSceneInfo(scene_id)
  1365. return sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1 or sceneInfo.type == 4)
  1366. end
  1367. --[[
  1368. ()
  1369. ]]
  1370. function SceneManager:IsMainCityorYieldSceneNotGuild(scene_id)
  1371. local sceneInfo = self:GetSceneInfo(scene_id)
  1372. return sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1)
  1373. end
  1374. --[[
  1375. ]]
  1376. function SceneManager:IsSafeScene(scene_id)
  1377. local sceneInfo = self:GetSceneInfo(scene_id)
  1378. return (sceneInfo and sceneInfo.subtype == 1)
  1379. end
  1380. --是否安全区域 (包括安全场景和安全位置坐标)
  1381. function SceneManager:IsSafeArea(scene_id, pos_x, pos_y)
  1382. local sceneInfo = self:GetSceneInfo(scene_id)
  1383. return self:IsSafeScene(scene_id) or (self:IsSafePos(pos_x, pos_y))
  1384. end
  1385. --是否处于安全区坐标,野外场景也会有安全区的
  1386. function SceneManager:IsSafePos(pos_x, pos_y)
  1387. if pos_x == nil or pos_y == nil then
  1388. return false
  1389. end
  1390. local is_safe_area = self:IsAreaType(pos_x / SceneObj.LogicRealRatio.x, pos_y / SceneObj.LogicRealRatio.y, AreaDataIndex.SafeType)
  1391. return is_safe_area
  1392. end
  1393. --是否有障碍区
  1394. function SceneManager:HasBolckScene(scene_id)
  1395. return false
  1396. end
  1397. --是否处于障碍区
  1398. function SceneManager:IsBlockPos(pos_x, pos_y)
  1399. return false
  1400. end
  1401. --pk场景 强制切换pk状态
  1402. function SceneManager:IsPKScene(scene_id)
  1403. return not self:IsOnlyAttackMonsterScene(scene_id)
  1404. end
  1405. --不能攻击其他玩家 只能打怪的场景
  1406. function SceneManager:IsOnlyAttackMonsterScene(scene_id)
  1407. local sceneInfo = self:GetSceneInfo(scene_id)
  1408. return (sceneInfo and (sceneInfo.subtype == 1))
  1409. end
  1410. function SceneManager:IsCSPvP(scene_id)
  1411. scene_id = scene_id or self:GetSceneId()
  1412. return scene_id == 6000
  1413. end
  1414. function SceneManager:IsAutoFindWayScene(scene_id)
  1415. scene_id = scene_id or self:GetSceneId()
  1416. return scene_id == 10003
  1417. or scene_id == 10003
  1418. or scene_id == 10000
  1419. end
  1420. function SceneManager:IsAutoFindWayDun(dun_id)
  1421. dun_id = dun_id or self:GetCurrDunId()
  1422. return dun_id == 1003
  1423. end
  1424. --Pk场景准备阶段
  1425. function SceneManager:IsNotBlockMonsterScene()
  1426. return self:IsPkBattleScene()
  1427. end
  1428. --Pk场景准备阶段
  1429. function SceneManager:IsNotShowOtherHeadScene()
  1430. return self:IsPkBattleScene() or self:IsCSPvP()
  1431. end
  1432. --星界试炼场景
  1433. function SceneManager:IsStarFightScene(scene_id)
  1434. -- if scene_id == nil and self.temp_check_list["IsStarFightScene"] ~= nil then
  1435. -- return self.temp_check_list["IsStarFightScene"]
  1436. -- end
  1437. -- local save = false
  1438. -- if scene_id == nil then
  1439. -- save = true
  1440. -- end
  1441. -- scene_id = scene_id or self:GetSceneId()
  1442. -- for k,v in pairs(Config.Pokemonwarbirth) do
  1443. -- if tonumber(scene_id) == v.id then
  1444. -- if save then
  1445. -- self.temp_check_list["IsStarFightScene"] = true
  1446. -- end
  1447. -- return true
  1448. -- end
  1449. -- end
  1450. -- if save then
  1451. -- self.temp_check_list["IsStarFightScene"] = false
  1452. -- end
  1453. -- return false
  1454. end
  1455. --Pk场景准备阶段
  1456. function SceneManager:IsPkSceneReadyStep()
  1457. if self:IsPkBattleScene() then
  1458. if PkBattleModel:getInstance():IsInReadyStep() then
  1459. return true
  1460. end
  1461. end
  1462. return false
  1463. end
  1464. function SceneManager:IsOvnWaitingScene(scene_id)
  1465. scene_id = scene_id or self:GetSceneId()
  1466. if scene_id == 7112 then
  1467. return 1
  1468. elseif scene_id == 7113 then
  1469. return 2
  1470. else
  1471. return false
  1472. end
  1473. end
  1474. function SceneManager:IsOvnFightingScene(scene_id)
  1475. scene_id = scene_id or self:GetSceneId()
  1476. if scene_id == 7110 then
  1477. return 1
  1478. elseif scene_id == 7111 then
  1479. return 2
  1480. else
  1481. return false
  1482. end
  1483. end
  1484. --显示pk模式ui的场景
  1485. function SceneManager:ShowPKStatusUI(scene_id)
  1486. local sceneInfo = self:GetSceneInfo(scene_id)
  1487. return (sceneInfo and (sceneInfo.subtype == 0)
  1488. and RoleManager.Instance.mainRoleInfo.warGroup == 0)
  1489. end
  1490. --能否切换PK模式的场景
  1491. function SceneManager:IsCanChangePKStatusScene(scene_id)
  1492. local sceneInfo = self:GetSceneInfo(scene_id)
  1493. return (sceneInfo and (sceneInfo.subtype == 0))
  1494. end
  1495. function SceneManager:ShowPkTipsScene(scene_id)
  1496. local sceneInfo = self:GetSceneInfo(scene_id)
  1497. return (sceneInfo and (sceneInfo.pkstate == 1 or sceneInfo.pkstate == 2) and not self:IsDiamondFightScene() and not self:IsOvnFightingScene())
  1498. end
  1499. --显示跟随npc的场景
  1500. function SceneManager:ShowFollowNpc(scene_id)
  1501. local sceneInfo = self:GetSceneInfo(scene_id)
  1502. return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1) )
  1503. end
  1504. --不能跳跃障碍点的场景
  1505. function SceneManager:CannotJumpCrossBlockScene()
  1506. local sceneInfo = self:GetSceneInfo(scene_id)
  1507. return (sceneInfo and (sceneInfo.type == 3))
  1508. end
  1509. --任务可以加速的场景
  1510. function SceneManager:TaskCanAddSpeedBuffScene()
  1511. return self:IsMainCityorYieldScene()
  1512. end
  1513. --在主城安全区
  1514. function SceneManager:IsMainCity(scene_id)
  1515. local sceneInfo = self:GetSceneInfo(scene_id)
  1516. return (sceneInfo and (sceneInfo.type == 0 and sceneInfo.subtype == 1))
  1517. end
  1518. --没有操作cd的场景
  1519. function SceneManager:NoOperateCDScene()
  1520. if self:IsMainCity() or ((self:IsOnlyAttackMonsterScene() or self:IsSafeScene()) and self:IsOutdoorScene()) then
  1521. return true
  1522. end
  1523. end
  1524. --是否可以使用飞鞋的场景(主城,野外场景中的子类型为0和1的场景)
  1525. function SceneManager:IsCanUseFlyShoeScene()
  1526. return self:IsMainCityAndFieldScene() or self:IsRefineDungeon() or self:IsCSPvP() or self:IsPkBattleScene() or self:IsHomeBuildScene()
  1527. end
  1528. --隐藏连击效果的场景
  1529. function SceneManager:HideLianjiScene(scene_id)
  1530. return true
  1531. end
  1532. --是否野外场景
  1533. function SceneManager:IsOutdoorScene(scene_id)
  1534. local sceneInfo = self:GetSceneInfo(scene_id)
  1535. return (sceneInfo and sceneInfo.type == 1)
  1536. end
  1537. function SceneManager:IsBeachScene(scene_id)
  1538. scene_id = scene_id or self:GetSceneId()
  1539. return scene_id == BeachModel:GetInstance():GetKeyValue("kf_scene")
  1540. or scene_id == BeachModel:GetInstance():GetKeyValue("bf_scene")
  1541. end
  1542. function SceneManager:IsPkRankFightScene(scene_id)
  1543. -- local sceneInfo = self:GetSceneInfo(scene_id)
  1544. -- return (sceneInfo and sceneInfo.type == 9)
  1545. return self:IsMirrorPkRankScene()
  1546. end
  1547. function SceneManager:IsTopPkScene(scene_id)
  1548. scene_id = scene_id or self:GetSceneId()
  1549. return scene_id >= 4053 and scene_id <= 4054
  1550. end
  1551. function SceneManager:IsStarDungeonScene(scene_id)
  1552. scene_id = scene_id or self:GetSceneId()
  1553. return scene_id == 5502
  1554. end
  1555. --是否副本场景
  1556. function SceneManager:IsDungeonScene(scene_id)
  1557. local sceneInfo = self:GetSceneInfo(scene_id)
  1558. if sceneInfo then
  1559. return sceneInfo.type == 2 and self:IsMirrorDungeonScene()
  1560. else
  1561. return false
  1562. end
  1563. end
  1564. --是否沙盘副本场景
  1565. function SceneManager:IsSandTableDungeonScene(scene_id)
  1566. local sceneInfo = self:GetSceneInfo(scene_id)
  1567. if sceneInfo then
  1568. for k,v in pairs(Config.Dungeoncfg) do
  1569. if v.scene_id == scene_id then
  1570. return v.type == BaseDungeonModel.DUN_TYPE.SandTable
  1571. end
  1572. end
  1573. end
  1574. return false
  1575. end
  1576. --是否镜像竞技场
  1577. function SceneManager:IsMirrorPkRankScene()
  1578. return self.mirror_scene_id == SceneActivityMirrorSceneId.PkRank
  1579. end
  1580. --是否是镜像场景
  1581. function SceneManager:IsMirrorScene()
  1582. return self.mirror_scene_id ~= SceneActivityMirrorSceneId.None
  1583. end
  1584. --上一个场景是否是镜像场景
  1585. function SceneManager:IsLastMirrorScene()
  1586. return self.last_mirror_scene_id ~= SceneActivityMirrorSceneId.None
  1587. end
  1588. --是否镜像副本
  1589. function SceneManager:IsMirrorDungeonScene()
  1590. return self.mirror_scene_id == SceneActivityMirrorSceneId.Dungeon or self.mirror_scene_id == SceneActivityMirrorSceneId.None or self.mirror_scene_id == SceneActivityMirrorSceneId.DungeonMany
  1591. end
  1592. --设置镜像镜像场景
  1593. function SceneManager:SetMirrorSceneId(mirror_scene_id)
  1594. self.last_mirror_scene_id = self.mirror_scene_id
  1595. self.mirror_scene_id = mirror_scene_id
  1596. end
  1597. --获取镜像场景id
  1598. function SceneManager:GetMirrorSceneId(mirror_scene_id)
  1599. return self.mirror_scene_id
  1600. end
  1601. --退出副本场景的时候是否弹出结算界面(默认不弹出)
  1602. function SceneManager:IsShowDungeonResultOnExit(dun_id)
  1603. local show = false
  1604. local resultData = BaseDungeonModel:getInstance():GetDunResultInfo()
  1605. if resultData.result == 1 or (self:IsGuardianThreeDun(dun_id) and DunManyModel:getInstance().is_support_state == 1 and resultData.wave and resultData.wave > 5) then--场景外只有胜利弹
  1606. if self:IsCrusadeDun(dun_id) or self:IsGuardianThreeDun(dun_id) then
  1607. show = true
  1608. end
  1609. elseif resultData.result == 2 then--多人副本场景外如果是失败了也要弹
  1610. if self:IsCrusadeDun(dun_id) or self:IsGuardianThreeDun(dun_id) then
  1611. show = true
  1612. end
  1613. end
  1614. return show
  1615. end
  1616. --退出副本场景内的时候是否弹出结算界面
  1617. function SceneManager:ShowDungeonResultOnDun(dun_id)
  1618. local show = true
  1619. local resultData = BaseDungeonModel:getInstance():GetDunResultInfo()
  1620. local exit_by_hand = BaseDungeonModel:getInstance().exit_by_hand
  1621. -- --无尽回廊只有失败的时候才在副本场景外面弹结算界面
  1622. -- if self:IsOneTowerDungeon(dun_id) and BaseDungeonModel:getInstance():GetDunResultInfo().result ~= 2 then
  1623. -- show = false
  1624. -- --主线副本默认不弹结算界面
  1625. -- else
  1626. -- print("huangcong:SceneManager [start:1799] :", resultData)
  1627. -- PrintTable(resultData)
  1628. -- print("huangcong:SceneManager [end]")
  1629. if self:IsThreadDungeon(dun_id) or self:IsNomalDungeon(dun_id) or self:IsEscortDungeon() then--主线副本不弹结算界面
  1630. show = false
  1631. elseif resultData and resultData.result == 2 and resultData.result_subtype ~= 1 then--失败结算
  1632. if exit_by_hand and (
  1633. self:IsMaterialDungeon(dun_id) or self:IsVIPDungeon(dun_id) or self:IsOneTowerDungeon(dun_id)
  1634. ) then
  1635. show = false
  1636. end
  1637. end
  1638. return show
  1639. end
  1640. --是否跨服入侵场景
  1641. function SceneManager:IsIntrusionScene(scene_id)
  1642. -- local sceneInfo = self:GetSceneInfo(scene_id)
  1643. -- if sceneInfo then
  1644. -- return sceneInfo.type == 16
  1645. -- else
  1646. -- return false
  1647. -- end
  1648. end
  1649. --是否是在跨服场景 .加入会自动添加 区服 攻击模式、在名字前加服务器标识
  1650. function SceneManager:InServerScene(scene_id)
  1651. return self:IsCrusadeScene(scene_id)
  1652. or self:IsCSEndlessScene(scene_id)
  1653. or self:IsBeachScene(scene_id)
  1654. or self:IsKfWordScene(scene_id)
  1655. or self:IsGuildCSGRScene(scene_id)
  1656. or self:IsCSGWarScene(scene_id)
  1657. or self:IsCSWastelandScene(scene_id)
  1658. or self:IsRageWarCrossServerScene(scene_id)
  1659. or self:IsDesertedBossCrossScene(scene_id)
  1660. or self:IsJumpOneScene(scene_id)
  1661. end
  1662. --是否跨服入侵 世界主城 场景
  1663. function SceneManager:IsIntrusionWorldHoneScene(scene_id)
  1664. -- scene_id = scene_id or self:GetSceneId()
  1665. -- local sceneInfo = self:GetSceneInfo(scene_id)
  1666. -- if sceneInfo then
  1667. -- return sceneInfo.type == 17
  1668. -- else
  1669. -- return false
  1670. -- end
  1671. end
  1672. --是否彩钻大战战斗
  1673. function SceneManager:IsDiamondFightScene(scene_id)
  1674. -- local scene_id = scene_id or self:GetSceneId()
  1675. -- local config = Config.Drumwarkv[5]
  1676. -- local list = ErlangParser:GetInstance():Parse(config.val)
  1677. -- scene_id = tostring(scene_id)
  1678. -- for i,v in pairs(list) do
  1679. -- if v == scene_id then
  1680. -- return true
  1681. -- end
  1682. -- end
  1683. return false
  1684. end
  1685. --是否彩钻大战等待
  1686. function SceneManager:IsDiamondFightWaitingScene(scene_id)
  1687. -- local scene_id = scene_id or self:GetSceneId()
  1688. -- local config = Config.Drumwarkv[4]
  1689. -- local list = ErlangParser:GetInstance():Parse(config.val)
  1690. -- scene_id = tostring(scene_id)
  1691. -- for i,v in pairs(list) do
  1692. -- if v == scene_id then
  1693. -- return true
  1694. -- end
  1695. -- end
  1696. return false
  1697. end
  1698. --是否是彩钻大战任意一个场景(等待或者战斗)
  1699. function SceneManager:IsAnyDiamonScene(scene_id)
  1700. return self:IsDiamondFightWaitingScene(scene_id) or self:IsDiamondFightScene(scene_id)
  1701. end
  1702. --是否星灵争霸战斗
  1703. function SceneManager:IsSpiritWarScene(scene_id)
  1704. -- local scene_id = scene_id or self:GetSceneId()
  1705. -- local config = Config.Pokemondrumkv[8]
  1706. -- if config then
  1707. -- local list = ErlangParser:GetInstance():Parse(config.val)
  1708. -- scene_id = tostring(scene_id)
  1709. -- for i,v in pairs(list) do
  1710. -- if v == scene_id then
  1711. -- return true
  1712. -- end
  1713. -- end
  1714. -- end
  1715. return false
  1716. end
  1717. --是否星灵争霸等待
  1718. function SceneManager:IsSpiritWarWaitingScene(scene_id)
  1719. -- local scene_id = scene_id or self:GetSceneId()
  1720. -- local config = Config.Pokemondrumkv[7]
  1721. -- if config then
  1722. -- local list = ErlangParser:GetInstance():Parse(config.val)
  1723. -- scene_id = tostring(scene_id)
  1724. -- for i,v in pairs(list) do
  1725. -- if v == scene_id then
  1726. -- return true
  1727. -- end
  1728. -- end
  1729. -- end
  1730. return false
  1731. end
  1732. --是否是星灵争霸任意一个场景(等待或者战斗)
  1733. function SceneManager:IsAnySpiritWarScene(scene_id)
  1734. return self:IsSpiritWarScene(scene_id) or self:IsSpiritWarWaitingScene(scene_id)
  1735. end
  1736. --是否是能获得经验的副本
  1737. function SceneManager:CanGetExpDungeonScene(scene_id)
  1738. return self:IsExpScene(scene_id)--[[ or self:IsGuildGuardDungeon(scene_id)--]]
  1739. end
  1740. --普通副本
  1741. function SceneManager:IsNomalDungeon(dun_id)
  1742. local dun_id = dun_id or self:GetCurrDunId()
  1743. local dunConfig = Config.Dungeoncfg[dun_id]
  1744. if dunConfig then
  1745. return dunConfig.type == BaseDungeonModel.DUN_TYPE.MORMAL or dunConfig.type == BaseDungeonModel.DUN_TYPE.PSIONIC
  1746. end
  1747. end
  1748. --是否是经验跑环副本副本
  1749. function SceneManager:IsDailyCircleDungeon(dun_id)
  1750. local dun_id = dun_id or self:GetCurrDunId()
  1751. local dunConfig = Config.Dungeoncfg[dun_id]
  1752. if dunConfig then
  1753. return dunConfig.type == BaseDungeonModel.DUN_TYPE.MORMAL and dunConfig.sub_type == BaseDungeonModel.DUN_SUB_TYPE.DAILY_CIRCLE_DUN
  1754. end
  1755. end
  1756. --护送副本
  1757. function SceneManager:IsEscortDungeon(dun_id)
  1758. local dun_id = dun_id or self:GetCurrDunId()
  1759. local dunConfig = Config.Dungeoncfg[dun_id]
  1760. if dunConfig then
  1761. return dunConfig.type == BaseDungeonModel.DUN_TYPE.Escort
  1762. end
  1763. end
  1764. --主线副本
  1765. function SceneManager:IsThreadDungeon(dun_id)
  1766. local dun_id = dun_id or self:GetCurrDunId()
  1767. local dunConfig = Config.Dungeoncfg[dun_id]
  1768. if dunConfig then
  1769. return dunConfig.type == BaseDungeonModel.DUN_TYPE.THREAD
  1770. end
  1771. end
  1772. --进阶副本
  1773. function SceneManager:IsMaterialDungeon(dun_id)
  1774. local dun_id = dun_id or self:GetCurrDunId()
  1775. local dunConfig = Config.Dungeoncfg[dun_id]
  1776. if dunConfig then
  1777. return dunConfig.type == BaseDungeonModel.DUN_TYPE.MATERIAL
  1778. end
  1779. end
  1780. --VIP副本
  1781. function SceneManager:IsVIPDungeon(dun_id)
  1782. local dun_id = dun_id or self:GetCurrDunId()
  1783. local dunConfig = Config.Dungeoncfg[dun_id]
  1784. if dunConfig then
  1785. return dunConfig.type == BaseDungeonModel.DUN_TYPE.VIP
  1786. end
  1787. end
  1788. --爬塔副本
  1789. function SceneManager:IsOneTowerDungeon(dun_id)
  1790. local dun_id = dun_id or self:GetCurrDunId()
  1791. local dunConfig = Config.Dungeoncfg[dun_id]
  1792. if dunConfig then
  1793. return dunConfig.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER
  1794. end
  1795. end
  1796. --简单爬塔副本
  1797. function SceneManager:IsOneTowerNormalDungeon(dun_id)
  1798. local dun_id = dun_id or self:GetCurrDunId()
  1799. local dunConfig = Config.Dungeoncfg[dun_id]
  1800. if dunConfig then
  1801. if dunConfig.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER and not Config.Towerdundiffcult[dun_id] then
  1802. return true
  1803. end
  1804. end
  1805. return false
  1806. end
  1807. --爬塔副本
  1808. function SceneManager:IsOneTowerScene(scene_id)
  1809. scene_id = scene_id or self:GetSceneId()
  1810. return scene_id == 7001
  1811. end
  1812. --主线材料副本
  1813. function SceneManager:IsMainPlotDungeon(dun_id)
  1814. local dun_id = dun_id or self:GetCurrDunId()
  1815. local dunConfig = Config.Dungeoncfg[dun_id]
  1816. if dunConfig then
  1817. return dunConfig.type == BaseDungeonModel.DUN_TYPE.MAINPLOT
  1818. end
  1819. end
  1820. --守卫幼宠(宠物副本)
  1821. function SceneManager:IsPetDungeon(dun_id)
  1822. local dun_id = dun_id or self:GetCurrDunId()
  1823. local dunConfig = Config.Dungeoncfg[dun_id]
  1824. if dunConfig then
  1825. return dunConfig.type == BaseDungeonModel.DUN_TYPE.PET
  1826. end
  1827. end
  1828. --唤神副本
  1829. function SceneManager:IsGodDungeon(dun_id)
  1830. local dun_id = dun_id or self:GetCurrDunId()
  1831. local dunConfig = Config.Dungeoncfg[dun_id]
  1832. if dunConfig then
  1833. return dunConfig.type == BaseDungeonModel.DUN_TYPE.GOD
  1834. end
  1835. end
  1836. function SceneManager:IsEliteAssessDun(dun_id)
  1837. local dun_id = dun_id or self:GetCurrDunId()
  1838. local dunConfig = Config.Dungeoncfg[dun_id]
  1839. if dunConfig then
  1840. return dunConfig.type == BaseDungeonModel.DUN_TYPE.EliteAssess
  1841. end
  1842. end
  1843. -- 是否是古神灭世神座体验副本
  1844. function SceneManager:IsGAExperienceDungeon(dun_id)
  1845. local dun_id = dun_id or self:GetCurrDunId()
  1846. return dun_id >= 3600 and dun_id <= 3604 -- 暂时写死
  1847. end
  1848. --沙盘副本
  1849. function SceneManager:IsSandTableDungeon(dun_id)
  1850. local dun_id = dun_id or self:GetCurrDunId()
  1851. local dunConfig = Config.Dungeoncfg[dun_id]
  1852. if dunConfig then
  1853. return dunConfig.type == BaseDungeonModel.DUN_TYPE.SandTable
  1854. end
  1855. end
  1856. function SceneManager:IsEquipScene(dun_id)
  1857. -- local dun_id = dun_id or self:GetCurrDunId()
  1858. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1859. -- if dunConfig then
  1860. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.EQUIP
  1861. -- end
  1862. return false
  1863. end
  1864. --普通副本
  1865. function SceneManager:IsNormalDungeonScene(dun_id)
  1866. -- local dun_id = dun_id or self:GetCurrDunId()
  1867. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1868. -- if dunConfig then
  1869. -- return dunConfig.type == 0
  1870. -- end
  1871. return false
  1872. end
  1873. function SceneManager:IsRebuildDungeon(dun_id)
  1874. -- local dun_id = dun_id or self:GetCurrDunId()
  1875. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1876. -- if dunConfig then
  1877. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.REBUILD
  1878. -- end
  1879. return false
  1880. end
  1881. function SceneManager:IsExpScene(scene_id)
  1882. scene_id = scene_id or self:GetSceneId()
  1883. return scene_id == 3001
  1884. end
  1885. -- 是否是经验副本
  1886. function SceneManager:IsExpDun( dun_id )
  1887. local dun_id = dun_id or self:GetCurrDunId()
  1888. local dunConfig = Config.Dungeoncfg[dun_id]
  1889. if dunConfig then
  1890. return dunConfig.type == BaseDungeonModel.DUN_TYPE.EXP
  1891. end
  1892. end
  1893. -- 是否是讨伐小队
  1894. function SceneManager:IsCrusadeDun( dun_id )
  1895. local dun_id = dun_id or self:GetCurrDunId()
  1896. local dunConfig = Config.Dungeoncfg[dun_id]
  1897. if dunConfig then
  1898. return dunConfig.type == BaseDungeonModel.DUN_TYPE.Crusade
  1899. end
  1900. end
  1901. -- 是否是多人副本场景
  1902. function SceneManager:IsCrusadeScene( scene_id )
  1903. scene_id = scene_id or self:GetSceneId()
  1904. return (scene_id >= 8000 and scene_id <= 8010) or scene_id == 3100
  1905. end
  1906. -- 是否是绝地守卫
  1907. function SceneManager:IsGuardianThreeDun( dun_id )
  1908. local dun_id = dun_id or self:GetCurrDunId()
  1909. local dunConfig = Config.Dungeoncfg[dun_id]
  1910. if dunConfig then
  1911. return dunConfig.type == BaseDungeonModel.DUN_TYPE.GuardianThree
  1912. end
  1913. end
  1914. -- 是否是幻光副本
  1915. function SceneManager:IsIllusoryLightDun( dun_id )
  1916. local dun_id = dun_id or self:GetCurrDunId()
  1917. local dunConfig = Config.Dungeoncfg[dun_id]
  1918. if dunConfig then
  1919. return dunConfig.type == BaseDungeonModel.DUN_TYPE.IllusoryLight
  1920. end
  1921. end
  1922. -- 是否是宝宝副本
  1923. function SceneManager:IsBabyDun( dun_id )
  1924. local dun_id = dun_id or self:GetCurrDunId()
  1925. local dunConfig = Config.Dungeoncfg[dun_id]
  1926. if dunConfig then
  1927. return dunConfig.type == BaseDungeonModel.DUN_TYPE.BABY
  1928. end
  1929. end
  1930. -- 是否是专属副本
  1931. function SceneManager:IsBossPersonDun( dun_id )
  1932. local dun_id = dun_id or self:GetCurrDunId()
  1933. local dunConfig = Config.Dungeoncfg[dun_id]
  1934. if dunConfig then
  1935. return dunConfig.type == BaseDungeonModel.DUN_TYPE.PersonBoss
  1936. end
  1937. end
  1938. function SceneManager:IsBabyScene(scene_id)
  1939. scene_id = scene_id or self:GetSceneId()
  1940. return scene_id == 2300
  1941. end
  1942. -- 是否是星辰副本
  1943. function SceneManager:IsGalaxyDun( dun_id )
  1944. local dun_id = dun_id or self:GetCurrDunId()
  1945. local dunConfig = Config.Dungeoncfg[dun_id]
  1946. if dunConfig then
  1947. return dunConfig.type == BaseDungeonModel.DUN_TYPE.GALAXY
  1948. end
  1949. end
  1950. -- 是否是星辰副本
  1951. function SceneManager:IsSupportGuildBoss( dun_id )
  1952. local dun_id = dun_id or self:GetCurrDunId()
  1953. local dunConfig = Config.Dungeoncfg[dun_id]
  1954. if dunConfig then
  1955. return dunConfig.type == BaseDungeonModel.DUN_TYPE.SupportGuildBoss
  1956. end
  1957. end
  1958. function SceneManager:IsTeamDungeonScene(scene_id)
  1959. -- local dun_id = scene_id or self:GetCurrDunId()
  1960. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1961. -- if dunConfig then
  1962. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.EQUIP
  1963. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.REFINE
  1964. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.LOVE
  1965. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.REBUILD
  1966. -- else
  1967. -- return false
  1968. -- end
  1969. end
  1970. --是否需要鼓舞技能的场景
  1971. function SceneManager:IsInspireScene(scene_id)
  1972. return self:IsTeamDungeonScene() or self:IsExpScene() or self:IsStarDungeon()
  1973. end
  1974. function SceneManager:IsSingleDungeon(dun_id)
  1975. -- dun_id = dun_id or self:GetCurrDunId()
  1976. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1977. -- if dunConfig then
  1978. -- return
  1979. -- dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN
  1980. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD
  1981. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GOD
  1982. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.GEM
  1983. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.EXP
  1984. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.NEWIE_EXP
  1985. -- or dunConfig.type == BaseDungeonModel.DUN_TYPE.STAR_FIGHT
  1986. -- or dunConfig.type == 24
  1987. -- or dunConfig.type == 16
  1988. -- or dunConfig.type == 15
  1989. -- or dunConfig.type == 25
  1990. -- or dunConfig.type == 0
  1991. -- or self:IsBossPersonScene()
  1992. -- else
  1993. -- return false
  1994. -- end
  1995. end
  1996. function SceneManager:IsCoinDungeon(dun_id)
  1997. -- dun_id = dun_id or self:GetCurrDunId()
  1998. -- local dunConfig = Config.Dungeoncfg[dun_id]
  1999. -- if dunConfig then
  2000. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN
  2001. -- else
  2002. -- return false
  2003. -- end
  2004. end
  2005. --新手降神副本
  2006. function SceneManager:IsNewbieGodDungeon(dun_id)
  2007. dun_id = dun_id or self:GetCurrDunId()
  2008. return dun_id == 5405
  2009. end
  2010. --新手副本
  2011. function SceneManager:IsNewbieDungeon(dun_id)
  2012. dun_id = dun_id or self:GetCurrDunId()
  2013. return dun_id == 1002
  2014. end
  2015. function SceneManager:IsGemDungeon(dun_id)
  2016. -- dun_id = dun_id or self:GetCurrDunId()
  2017. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2018. -- if dunConfig then
  2019. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GEM
  2020. -- else
  2021. -- return false
  2022. -- end
  2023. end
  2024. function SceneManager:IsRefineDungeon(dun_id)
  2025. -- dun_id = dun_id or self:GetCurrDunId()
  2026. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2027. -- if dunConfig then
  2028. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.REFINE
  2029. -- else
  2030. -- return false
  2031. -- end
  2032. end
  2033. function SceneManager:IsStarDungeon(dun_id)
  2034. -- dun_id = dun_id or self:GetCurrDunId()
  2035. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2036. -- if dunConfig then
  2037. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.COIN
  2038. -- else
  2039. -- return false
  2040. -- end
  2041. end
  2042. function SceneManager:IsGuildBossDungeon(dun_id)
  2043. -- dun_id = dun_id or self:GetCurrDunId()
  2044. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2045. -- if dunConfig then
  2046. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GUILD_BOSS
  2047. -- else
  2048. -- return false
  2049. -- end
  2050. end
  2051. function SceneManager:IsGuildGuardDungeon(dun_id)
  2052. -- dun_id = dun_id or self:GetCurrDunId()
  2053. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2054. -- if dunConfig then
  2055. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GUARD
  2056. -- else
  2057. -- return false
  2058. -- end
  2059. end
  2060. --死亡是否是幽灵模式的场景
  2061. function SceneManager:IsGhostModeScene(scene_id)
  2062. return false
  2063. end
  2064. --显示所有伤害飘字的场景
  2065. function SceneManager:ShowAllDamageScene()
  2066. return self:IsPkRankFightScene() or self:IsTopPkScene() or self:IsMirrorPkRankScene()
  2067. end
  2068. --是否在不能点击超链接寻路的场景
  2069. function SceneManager:IsClickFindScene(cur_scene_id, target_scene_id)
  2070. -- if cur_scene_id == target_scene_id then return true end
  2071. -- local cur_scene_info = self:GetSceneInfo(cur_scene_id)
  2072. -- local tar_scene_info = self:GetSceneInfo(target_scene_id)
  2073. -- if not cur_scene_info or not tar_scene_info then return false end
  2074. -- local function check(scene_type)
  2075. -- for i,v in ipairs(Config.LinkClickScene) do
  2076. -- if scene_type == 4 then --社团场景
  2077. -- return RoleManager:getInstance():GetMainRoleVo().guild_id > 0
  2078. -- elseif scene_type == v then
  2079. -- return true
  2080. -- end
  2081. -- end
  2082. -- return false
  2083. -- end
  2084. -- local cur_can_click = check(cur_scene_info.type)
  2085. -- local tar_can_click = check(tar_scene_info.type)
  2086. -- return cur_can_click and tar_can_click
  2087. end
  2088. --每个场景的复活类型
  2089. function SceneManager:GetReliveType(scene_id)
  2090. if self:IsDungeonScene(scene_id) then
  2091. return 9
  2092. elseif self:IsCSPvP(scene_id) then
  2093. return 10
  2094. else
  2095. return 1
  2096. end
  2097. end
  2098. function SceneManager:GetModuleId(scene_id)
  2099. scene_id = scene_id or self:GetSceneId()
  2100. return scene_id
  2101. end
  2102. function SceneManager:IsPreChangeSceneState()
  2103. return self.pre_change_scene_state
  2104. end
  2105. --切换场景预读条
  2106. function SceneManager:ClearPreChangeSceneHandle()
  2107. if self.pre_change_scene_handle then
  2108. GlobalTimerQuest:CancelQuest(self.pre_change_scene_handle)
  2109. self.pre_change_scene_handle = nil
  2110. end
  2111. end
  2112. --切换场景预读条
  2113. function SceneManager:PreChangeScene( change_func)
  2114. self.pre_change_scene_state = true
  2115. Scene.Instance:GetMainRole():PreChangeScene()
  2116. local check_finish = function(state)
  2117. self.pre_change_scene_state = false
  2118. if change_func then
  2119. change_func( state )
  2120. change_func = nil
  2121. end
  2122. self.pre_change_scene_handle = nil
  2123. end
  2124. if self.pre_change_scene_handle then
  2125. GlobalTimerQuest:CancelQuest(self.pre_change_scene_handle)
  2126. self.pre_change_scene_handle = nil
  2127. end
  2128. local last_time = Config.ConfigDungeonClient.change_scene_transfer_time
  2129. self.pre_change_scene_handle = setTimeout(check_finish, last_time)
  2130. self:ShowPreChangeSceneView( check_finish, last_time)
  2131. end
  2132. function SceneManager:ShowPreChangeSceneView( callback,last_time )
  2133. local check_view = function()
  2134. if self.pre_change_scene then
  2135. self.pre_change_scene:Close()
  2136. self.pre_change_scene = nil
  2137. end
  2138. end
  2139. local finish_func = function( succeed )
  2140. check_view()
  2141. callback( not succeed )
  2142. end
  2143. check_view()
  2144. if self.pre_change_scene == nil then
  2145. self.pre_change_scene = PreChangeSceneView.New( finish_func, last_time )
  2146. end
  2147. self.pre_change_scene:Open()
  2148. end
  2149. --是否正在读条切换场景
  2150. function SceneManager:IsPreparingChangeScene()
  2151. return self.pre_change_scene
  2152. end
  2153. --判断两个角色是否友方
  2154. function SceneManager:IsFriendlyRole(vo1, vo2)
  2155. vo2 = vo2 or RoleManager.Instance.mainRoleInfo
  2156. local is_friendly = false
  2157. if vo1.role_id == vo2.role_id then
  2158. is_friendly = true
  2159. elseif vo1.warGroup == vo2.warGroup and vo1.warGroup > 0 then
  2160. is_friendly = true
  2161. elseif vo1.warGroup == vo2.warGroup and vo1.warGroup == 0 then
  2162. if vo1.team_id == vo2.team_id and vo1.team_id > 0 then
  2163. is_friendly = true
  2164. elseif vo1.guild_id == vo2.guild_id and vo1.guild_id > 0 then
  2165. is_friendly = true
  2166. end
  2167. end
  2168. return is_friendly
  2169. end
  2170. --attacker_vo是否能通过pkstatus的验证 攻击defender_vo
  2171. function SceneManager:CanPKByPKStatus(attacker_vo,defender_vo)
  2172. if attacker_vo and defender_vo then
  2173. if attacker_vo == defender_vo then
  2174. return false
  2175. end
  2176. -- if attacker_vo.hp == 0 or defender_vo.hp == 0 then
  2177. if defender_vo.hp == 0 then
  2178. return false
  2179. end
  2180. if defender_vo.boss_type then --怪物
  2181. if defender_vo.warGroup == attacker_vo.warGroup and attacker_vo.warGroup > 0 then
  2182. return false
  2183. else
  2184. return true
  2185. end
  2186. end
  2187. if (attacker_vo.pk_status == RoleVo.PK_STATUS.ForcePeace) and
  2188. (defender_vo.vo_type == SceneBaseType.Role) then
  2189. --强制和平状态下不可以攻击人
  2190. return false
  2191. end
  2192. if attacker_vo.pk_status and ((attacker_vo.warGroup == 0 and defender_vo.warGroup == 0) or (attacker_vo.warGroup ~= defender_vo.warGroup)) then
  2193. if attacker_vo.pk_status == RoleVo.PK_STATUS.Peace then --和平模式:只会攻击怪物和红名状态下的非同队和同社团的玩家
  2194. if (attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0)
  2195. or (attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0)
  2196. then
  2197. return false
  2198. elseif defender_vo.hatred and defender_vo.hatred > 0 then
  2199. return true
  2200. end
  2201. return false
  2202. elseif attacker_vo.pk_status == RoleVo.PK_STATUS.Force then --强制模式:不能攻击同队和同社团的玩家(红名也不可攻击),可以攻击其他玩家
  2203. if (attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0)
  2204. or (attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0)
  2205. then
  2206. return false
  2207. end
  2208. elseif attacker_vo.pk_status == RoleVo.PK_STATUS.Local then
  2209. if attacker_vo.server_id ~= defender_vo.server_id then
  2210. return true
  2211. else
  2212. return false
  2213. end
  2214. elseif attacker_vo.pk_status == RoleVo.PK_STATUS.All then
  2215. return true
  2216. elseif attacker_vo.pk_status == RoleVo.PK_STATUS.GUILD then
  2217. if attacker_vo.guild_id == defender_vo.guild_id and attacker_vo.guild_id > 0 then
  2218. return false
  2219. elseif attacker_vo.team_id == defender_vo.team_id and attacker_vo.team_id > 0 then
  2220. return false
  2221. else
  2222. return true
  2223. end
  2224. end
  2225. end
  2226. end
  2227. return true
  2228. end
  2229. --主角是否能被attack_vo攻击,战斗分组不同 and
  2230. --safe_area_state 1角色处于安全区域状态 2角色处于非安全区域状态 3角色切场景进入安全区域状态
  2231. --not_check_safe_area 不考虑安全区域
  2232. function SceneManager:IsMainRoleCanBeAttack(attacker_vo, not_check_safe_area)
  2233. local defender_vo = RoleManager.Instance.mainRoleInfo
  2234. if attacker_vo == nil or defender_vo == nil or attacker_vo.hp == 0 or defender_vo.hp == 0 then
  2235. return false
  2236. end
  2237. --是否要检测场景的安全区域
  2238. if not not_check_safe_area then
  2239. if self:IsSafeArea(nil, attacker_vo.pos_x, attacker_vo.pos_y) then
  2240. return false
  2241. 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
  2242. return false
  2243. end
  2244. end
  2245. if attacker_vo.vo_type == SceneBaseType.MainRole then
  2246. return false
  2247. end
  2248. local war_group1 = attacker_vo.warGroup
  2249. local war_group2 = defender_vo.warGroup
  2250. local same_group = war_group2 == war_group1 and war_group1 > 0
  2251. if attacker_vo.vo_type == SceneBaseType.Monster then
  2252. if attacker_vo.guild_id > 0 and attacker_vo.guild_id == defender_vo.guild_id then --defender_vo.type == 3
  2253. return false
  2254. elseif attacker_vo.guild_id > 0 and attacker_vo.guild_id ~= defender_vo.guild_id then
  2255. return true
  2256. elseif attacker_vo.guaji_flag == 1 or attacker_vo.can_attack == 0
  2257. or attacker_vo.type == MonsterType.COLLECT or attacker_vo.type == MonsterType.TASK_COLLECT
  2258. or attacker_vo.type == MonsterType.PICK or attacker_vo.type == MonsterType.UD_COLLECT then
  2259. return false
  2260. end
  2261. end
  2262. if attacker_vo.vo_type ~= SceneBaseType.Role then
  2263. return not same_group
  2264. end
  2265. -- if not self:IsPKScene() then
  2266. -- return false
  2267. -- end
  2268. local canpkByPkStatus = true
  2269. if war_group1 == 0 and war_group2 == 0 then
  2270. canpkByPkStatus = self:CanPKByPKStatus(attacker_vo, defender_vo)
  2271. end
  2272. return canpkByPkStatus and not same_group
  2273. end
  2274. --主角是否能攻击defender_vo
  2275. --safe_area_state 0未设置 1角色处于安全区域状态 2角色处于非安全区域状态
  2276. --check_safe_area 考虑安全区域
  2277. function SceneManager:IsCanAttackByMainRole(defender_vo, check_safe_area, not_check_hp)
  2278. local attacker_vo = RoleManager.Instance.mainRoleInfo
  2279. if not attacker_vo or not defender_vo or (not not_check_hp and attacker_vo.hp == 0) or defender_vo.hp == 0 then
  2280. return false
  2281. end
  2282. if check_safe_area then
  2283. 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
  2284. return false
  2285. 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
  2286. return false
  2287. end
  2288. end
  2289. local war_group1 = attacker_vo.warGroup
  2290. local war_group2 = defender_vo.warGroup
  2291. local same_group = war_group2 == war_group1 and war_group1 > 0
  2292. --同社团车队,非社团成员看见的血是红色
  2293. if defender_vo.vo_type == SceneBaseType.Monster then
  2294. if defender_vo.guild_id > 0 and defender_vo.guild_id == attacker_vo.guild_id then --defender_vo.type == 3
  2295. return false
  2296. elseif defender_vo.guild_id > 0 and defender_vo.guild_id ~= attacker_vo.guild_id then
  2297. return true
  2298. elseif defender_vo.guaji_flag == 1 or defender_vo.can_attack == 0
  2299. or defender_vo.type == MonsterType.COLLECT or defender_vo.type == MonsterType.TASK_COLLECT
  2300. or defender_vo.type == MonsterType.PICK or defender_vo.type == MonsterType.UD_COLLECT
  2301. or defender_vo.type == MonsterType.ESCORT then
  2302. return false
  2303. end
  2304. end
  2305. if defender_vo.vo_type == SceneBaseType.MainRole then
  2306. return false
  2307. end
  2308. if defender_vo.vo_type ~= SceneBaseType.Role then
  2309. return not same_group
  2310. end
  2311. -- if not self:IsPKScene() then
  2312. -- return false
  2313. -- end
  2314. local canpkByPkStatus = true
  2315. if war_group1 == 0 and war_group2 == 0 then
  2316. canpkByPkStatus = self:CanPKByPKStatus(attacker_vo, defender_vo)
  2317. end
  2318. return canpkByPkStatus and not same_group
  2319. end
  2320. --设置收到场景跳转协议时是否立即跳转
  2321. function SceneManager:DelayToChangeScene()
  2322. self.delay_change_scene = true
  2323. end
  2324. --获取是否需要延迟跳转
  2325. function SceneManager:CheckDirectly()
  2326. return not self.delay_change_scene
  2327. end
  2328. function SceneManager:CancelDelay()
  2329. self.delay_change_scene = nil
  2330. end
  2331. function SceneManager:CheckDisplayAddExpAvailable()
  2332. return true
  2333. end
  2334. --是否客户端隐身npc, 创建npc但不显示,用于触发任务
  2335. function SceneManager:IsClientHideNpc( npcid )
  2336. return npcid == 100499
  2337. end
  2338. -- --是否在社团篝火宴会场景
  2339. -- function SceneManager:IsGuildScene(scene_id)
  2340. -- if scene_id == nil and self.temp_check_list["IsGuildScene"] ~= nil then
  2341. -- return self.temp_check_list["IsGuildScene"]
  2342. -- end
  2343. -- local save = false
  2344. -- if scene_id == nil then
  2345. -- save = true
  2346. -- end
  2347. -- scene_id = scene_id or self:GetSceneId()
  2348. -- for k,v in pairs(Config.Gfeast) do
  2349. -- if Trim(v.key) == "scene_id" then
  2350. -- if save then
  2351. -- self.temp_check_list["IsGuildScene"] = scene_id == v.value
  2352. -- end
  2353. -- return scene_id == v.value
  2354. -- end
  2355. -- end
  2356. -- if save then
  2357. -- self.temp_check_list["IsGuildScene"] = false
  2358. -- end
  2359. -- return false
  2360. -- end
  2361. --是否在社团驻地场景
  2362. function SceneManager:IsGuildScene(scene_id)
  2363. scene_id = scene_id or self:GetSceneId()
  2364. return scene_id == 4063 or scene_id == 4064
  2365. end
  2366. -- 是否是本国团战场景
  2367. function SceneManager:IsGuildCSGRScene(scene_id)
  2368. scene_id = scene_id or self:GetSceneId()
  2369. return scene_id == 4200 -- 跨服模式场景
  2370. or scene_id == 4201 -- 本服模式场景
  2371. end
  2372. --新手虚构的赏金BOSS,实际是一个副本
  2373. function SceneManager:IsFakeBossMoneyScene(scene_id)
  2374. local scene_id = scene_id or self:GetSceneId()
  2375. return scene_id == BossModel.FAKE_MONEY_BOSS_SCENE_ID
  2376. end
  2377. function SceneManager:IsBossMoneyScene( scene_id )
  2378. scene_id = scene_id or self:GetSceneId()
  2379. local scene_typt = self:GetSceneType(scene_id)
  2380. return scene_typt == 7 or self:IsFakeBossMoneyScene(scene_id)
  2381. end
  2382. function SceneManager:IsBossWorldScene( scene_id )
  2383. scene_id = scene_id or self:GetSceneId()
  2384. local scene_typt = self:GetSceneType(scene_id)
  2385. return scene_typt == 3
  2386. end
  2387. --是否在个人boss场景
  2388. function SceneManager:IsBossPersonScene( scene_id )
  2389. scene_id = scene_id or self:GetSceneId()
  2390. for k,v in pairs(Config.Dungeoncfg) do
  2391. if v.scene_id == scene_id then
  2392. return v.type == BaseDungeonModel.DUN_TYPE.PersonBoss
  2393. end
  2394. end
  2395. return false
  2396. end
  2397. --是否在个人boss场景
  2398. function SceneManager:IsBossPersonDun( dun_id )
  2399. dun_id = dun_id or self:GetCurrDunId()
  2400. local dunConfig = Config.Dungeoncfg[dun_id]
  2401. if dunConfig then
  2402. return dunConfig.type == BaseDungeonModel.DUN_TYPE.PersonBoss
  2403. else
  2404. return false
  2405. end
  2406. end
  2407. --是否在幻魔星域场景
  2408. function SceneManager:IsBossDesertedScene( scene_id )
  2409. scene_id = scene_id or self:GetSceneId()
  2410. local scene_typt = self:GetSceneType(scene_id)
  2411. return scene_typt == SCENE_TYPE.DESERTED
  2412. end
  2413. --是否在boss场景
  2414. function SceneManager:IsBossScene( scene_id )
  2415. scene_id = scene_id or self:GetSceneId()
  2416. return self:IsBossPersonScene(scene_id) or self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) or self:IsBossDesertedScene() or self:IsBossHomeScene()
  2417. end
  2418. --是否在boss之家场景
  2419. function SceneManager:IsBossHomeScene(scene_id)
  2420. scene_id = scene_id or self:GetSceneId()
  2421. local scene_typt = self:GetSceneType(scene_id)
  2422. return scene_typt == SCENE_TYPE.BOSSHOME
  2423. end
  2424. --是否在副本, boss场景等不可跳转的地方
  2425. function SceneManager:IsOnDunOrBossScene( )
  2426. return self:IsDungeonScene() or self:IsTeamDungeonScene() or self:IsBossPersonScene()
  2427. end
  2428. --是否定点挂机场景
  2429. function SceneManager:IsFixedPointFightScene( )
  2430. return self:IsPetDungeon() or self:IsDunExpSeaScene()
  2431. end
  2432. --是否显示主界面boss列表
  2433. function SceneManager:IsShowMainUIMonsterView( )
  2434. return false
  2435. end
  2436. --显示怪物怒气的场景
  2437. function SceneManager:IsShowAngerScene( )
  2438. scene_id = scene_id or self:GetSceneId()
  2439. return false
  2440. end
  2441. --复活疲劳生效的场景
  2442. function SceneManager:IsReliveTiredScene( )
  2443. return false
  2444. end
  2445. --是否在幻兽之域场景(返回层数)
  2446. function SceneManager:IsWorldBeastScene(scene_id)
  2447. scene_id = scene_id or self:GetSceneId()
  2448. return ((scene_id == 1501) and 1) or ((scene_id == 1502) and 2) or nil
  2449. end
  2450. --是否是跨服场景
  2451. function SceneManager:IsCrossScene(scene_id)
  2452. scene_id = scene_id or self:GetSceneId()
  2453. return self:IsWorldBeastScene(scene_id)
  2454. end
  2455. --是否是神格副本
  2456. function SceneManager:IsContinueChangeGodScene()
  2457. return self:IsGodHoodDungeon() or self:GetSceneId() == 5405
  2458. end
  2459. --是否是将神塔副本
  2460. function SceneManager:IsGodHoodTowerDungeon(dun_id)
  2461. -- dun_id = dun_id or self:GetCurrDunId()
  2462. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2463. -- if dunConfig then
  2464. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD_TOWER
  2465. -- else
  2466. -- return false
  2467. -- end
  2468. end
  2469. --是否是神格副本
  2470. function SceneManager:IsGodHoodDungeon(dun_id)
  2471. -- dun_id = dun_id or self:GetCurrDunId()
  2472. -- local dunConfig = Config.Dungeoncfg[dun_id]
  2473. -- if dunConfig then
  2474. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.GODHOOD
  2475. -- else
  2476. -- return false
  2477. -- end
  2478. end
  2479. --是否在跳一跳场景
  2480. function SceneManager:IsJumpOneScene(scene_id )
  2481. scene_id = scene_id or self:GetSceneId()
  2482. return scene_id == 20010
  2483. end
  2484. --是否在单服社团战场景
  2485. function SceneManager:IsGuildWarScene(scene_id )
  2486. scene_id = scene_id or self:GetSceneId()
  2487. return scene_id == 4100
  2488. end
  2489. --跨服社团战场景(无尽海域)
  2490. function SceneManager:IsKFGuildWarFightScene(scene_id)
  2491. -- scene_id = scene_id or self:GetSceneId()
  2492. -- return scene_id and scene_id == KFGuildWarModel:getInstance():GetKFGuildWarConfig(4)
  2493. end
  2494. --是否是庭院场景
  2495. function SceneManager:IsHomeBuildScene( scene_id )
  2496. -- scene_id = scene_id or self:GetSceneId()
  2497. -- -- return scene_id == 11001
  2498. -- return scene_id and scene_id == HomeModel:getInstance():GetRoleHomeKVCfg(1)
  2499. end
  2500. --是否是房屋场景
  2501. function SceneManager:IsHomeRoomScene( scene_id )
  2502. -- if scene_id == nil and self.temp_check_list["IsHomeRoomScene"] ~= nil then
  2503. -- return self.temp_check_list["IsHomeRoomScene"]
  2504. -- end
  2505. -- local save = false
  2506. -- if scene_id == nil then
  2507. -- save = true
  2508. -- end
  2509. -- scene_id = scene_id or self:GetSceneId()
  2510. -- for i,v in pairs(Config.Rolehome) do
  2511. -- if scene_id == v.home_scene then
  2512. -- if save then
  2513. -- self.temp_check_list["IsHomeRoomScene"] = true
  2514. -- end
  2515. -- return true
  2516. -- end
  2517. -- end
  2518. -- if save then
  2519. -- self.temp_check_list["IsHomeRoomScene"] = false
  2520. -- end
  2521. -- return false
  2522. end
  2523. --是否在婚礼的场景
  2524. function SceneManager:IsWeddingScene(scene_id)
  2525. scene_id = scene_id or self:GetSceneId()
  2526. local target_scene_id = tonumber(Config.Marriageconstant[13].constant)
  2527. return scene_id == target_scene_id
  2528. end
  2529. --是否在大乱斗场景
  2530. function SceneManager:IsPkBattleScene(scene_id)
  2531. scene_id = scene_id or self:GetSceneId()
  2532. return scene_id == 5801 or scene_id == 5802
  2533. end
  2534. --是否显示坐骑场景,默认大世界才显示,战场玩法中要下坐骑,个别需要显示坐骑的场景可以添加进去
  2535. function SceneManager:IsShowHorseScene()
  2536. local is_show_horse = false
  2537. if (self:IsMainCityorYieldScene() or self:IsBossDesertedScene() or self:IsBossHomeScene()) and
  2538. not self:IsUnderWaterScene() then
  2539. is_show_horse = true
  2540. end
  2541. return is_show_horse
  2542. end
  2543. --需要显示|屏蔽玩家宠物的场景
  2544. function SceneManager:showPetScene()
  2545. return not (self:IsNoonQuizScene() or self:IsBeachScene() or self:IsTopPkScene() or self:IsCSPvP() or self:IsOvnFightingScene()
  2546. or self:IsStarDungeonScene() or self:IsKFGuildWarFightScene() or self:IsBabyScene()) --or self:IsEscortScene()
  2547. end
  2548. --需要显示|屏蔽玩家宠物的场景
  2549. function SceneManager:showPokemonScene()
  2550. 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()
  2551. or self:IsBeachScene() or self:IsKFGuildWarFightScene() or self:IsNoonQuizScene() or self:IsTopPkScene() or self:IsOvnWaitingScene() or self:IsBabyScene())
  2552. end
  2553. --需要显示|屏蔽玩家称号的场景
  2554. function SceneManager:showDsgtScene()
  2555. return not (--[[self:IsBossScene() or--]] self:IsWorldBeastScene() or self:IsStarDungeonScene() or self:IsGodDungeon() or self:IsRageWarScene())
  2556. end
  2557. --需要显示|屏蔽玩家宝宝的场景
  2558. function SceneManager:showBabyScene()
  2559. return not (self:IsDiamondFightScene() or self:IsBeachScene() or self:IsJumpOneScene() or self:IsNoonQuizScene() or self:IsCSPvP()
  2560. or self:IsOvnFightingScene() or self:IsStarDungeonScene() or self:IsKFGuildWarFightScene() or self:IsTopPkScene() or self:IsPkRankFightScene() or self:IsOvnWaitingScene() or self:IsBabyScene())--or self:IsEscortScene()
  2561. end
  2562. --需要显示|屏蔽玩家守护的场景
  2563. function SceneManager:showSpriteScene()
  2564. return not (self:IsBeachScene() or self:IsBabyScene() or self:IsJumpOneScene())
  2565. end
  2566. --需要显示|屏蔽玩家翅膀的场景
  2567. function SceneManager:showWingScene()
  2568. return not (self:IsNoonQuizScene() or self:IsStarDungeonScene() or self:IsJumpOneScene())
  2569. end
  2570. --需要显示|屏蔽玩家武器的场景[人物动作会根据这个改动]
  2571. function SceneManager:showWeaponScene()
  2572. return not (self:IsStarDungeonScene())-- or self:IsBeachScene())--暂时先屏蔽这个沙滩场景
  2573. end
  2574. function SceneManager:maskReliveViewScene()--不展示复活界面
  2575. if self:IsThreadDungeon() or self:IsNomalDungeon() then--主线副本和普通副本要判断复活次数
  2576. local dun_cfg = BaseDungeonModel:GetInstance():GetDunCfg(self:GetCurrDunId())
  2577. if dun_cfg and dun_cfg.revive_count == 0 then
  2578. return true
  2579. end
  2580. elseif self:IsPetDungeon() then--宠物副本判断复活次数
  2581. local left_pet_dun_relive_times = BaseDungeonModel:GetInstance():GetDunPetReliveTimes()
  2582. if left_pet_dun_relive_times <= 0 then
  2583. return true
  2584. else
  2585. return false
  2586. end
  2587. else
  2588. return self:IsExpDun() or self:IsOneTowerDungeon() or self:IsIllusoryLightDun() or self:IsGodDungeon() or self:IsGalaxyDun() or self:IsNomalDungeon() or self:IsSandTableDungeon()
  2589. end
  2590. return false
  2591. end
  2592. -- 是否智慧达人(中午答题)场景
  2593. function SceneManager:IsNoonQuizScene(scene_id)
  2594. scene_id = scene_id or self:GetSceneId()
  2595. return scene_id == 5171
  2596. end
  2597. function SceneManager:IsShowCollectBtnScene()
  2598. return (self:IsPkBattleScene() or self:IsGuildWarScene() or self:IsCSPvP() or self:IsWeddingScene() or self:IsLeagueWarScene())
  2599. end
  2600. -- 是否为强制隐藏挂机按钮场景
  2601. function SceneManager:IsHideAutoBtnScene(scene_id)
  2602. scene_id = scene_id or self:GetSceneId()
  2603. return self:IsNoonQuizScene()
  2604. end
  2605. -- 是否为强制隐藏跳跃按钮场景
  2606. function SceneManager:IsHideJumpBtnScene(scene_id)
  2607. scene_id = scene_id or self:GetSceneId()
  2608. return self:IsStarDungeonScene()
  2609. end
  2610. function SceneManager:IsDelayAutoFightScene(scene_id)
  2611. return self:IsPkBattleScene()
  2612. end
  2613. function SceneManager:CanAutoFightScene(scene_id)
  2614. return not self:IsCSPvP()
  2615. end
  2616. --是否是情缘副本
  2617. function SceneManager:IsLoveDungeon(dun_id)
  2618. dun_id = dun_id or self:GetCurrDunId()
  2619. local dunConfig = Config.Dungeoncfg[dun_id]
  2620. if dunConfig then
  2621. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.LOVE
  2622. else
  2623. return false
  2624. end
  2625. end
  2626. function SceneManager:IsEudemonsAttackFightScene(scene_id)
  2627. scene_id = scene_id or self:GetSceneId()
  2628. return scene_id == 4401
  2629. end
  2630. --是否是勇者副本
  2631. function SceneManager:IsYongZheDungeon(dun_id)
  2632. dun_id = dun_id or self:GetCurrDunId()
  2633. local dunConfig = Config.Dungeoncfg[dun_id]
  2634. if dunConfig then
  2635. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.YONGZHE
  2636. else
  2637. return false
  2638. end
  2639. end
  2640. --是否在捕蝶场景
  2641. function SceneManager:IsOnButterflyScene(scene_id)
  2642. scene_id = scene_id or self:GetSceneId()
  2643. return scene_id == 3010
  2644. end
  2645. --设置是否在采集
  2646. function SceneManager:SetCollectFlag( is_collect )
  2647. self.is_collect = is_collect
  2648. end
  2649. --设置是否在采集
  2650. function SceneManager:GetCollectFlag( )
  2651. return self.is_collect
  2652. end
  2653. --是否护送场景
  2654. function SceneManager:IsEscortScene( scene_id )
  2655. scene_id = scene_id or self:GetSceneId()
  2656. local scene_data = stringtotable(Config.Convoykv["convoy_pk_scene"].value_content)
  2657. return scene_id == scene_data[1] or scene_id == scene_data[2]
  2658. end
  2659. function SceneManager:IsEscortAllScene( scene_id )
  2660. scene_id = scene_id or self:GetSceneId()
  2661. local scene_data1 = stringtotable(Config.Convoykv["convoy_pk_scene"].value_content)
  2662. local scene_data2 = stringtotable(Config.Convoykv["convoy_safe_scene"].value_content)
  2663. return scene_id == scene_data1[1] or scene_id == scene_data1[2] or scene_id == scene_data2[1] or scene_id == scene_data2[2]
  2664. end
  2665. --已经没有这个副本了
  2666. function SceneManager:IsEscortPVEDunScene( dun_id )
  2667. return false
  2668. end
  2669. --是否展示主界面出口按钮
  2670. function SceneManager:IsShowMainExitScene( )
  2671. return SceneManager:getInstance():IsWorldBeastScene() or self:IsIntrusionWorldHoneScene()
  2672. end
  2673. --显示结婚预告图标的场景
  2674. function SceneManager:IsShowMarriageScene(scene_id)
  2675. local sceneInfo = self:GetSceneInfo(scene_id)
  2676. return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1))
  2677. end
  2678. --不显示危险警告特效场景
  2679. function SceneManager:IsShowDangerWarnScene(scene_id)
  2680. return not self:IsStarFightScene() and not self:IsStarDungeonScene()
  2681. end
  2682. --是否限制其他玩家外观的场景(目前只在创建这些对象的时候生效:AI娘,宝具,宠物,宝宝)
  2683. function SceneManager:IsModelLimited( )
  2684. local is_limited = false
  2685. --大世界不屏蔽
  2686. local scene_id = self:GetSceneId()
  2687. if self:IsMainCityAndFieldScene(scene_id) then
  2688. return false
  2689. end
  2690. --多人战场玩法需要屏蔽
  2691. if self:IsBossScene() --BOSS
  2692. or self:IsRageWarScene() --狂战
  2693. or self:IsWastelandScene() --废土
  2694. or self:IsEndlessScene() --无尽
  2695. or self:IsGuildWarScene() --本服团战
  2696. or self:IsGuildCSGRScene() --跨国团战
  2697. then
  2698. is_limited = true
  2699. end
  2700. return is_limited
  2701. end
  2702. --是否特效全开的场景
  2703. function SceneManager:IsFullEffectScene( scene_id )
  2704. -- if SystemMemoryLevel.Cur == SystemMemoryLevel.Low then
  2705. -- return false
  2706. -- end
  2707. if self:IsMirrorPkRankScene(scene_id) or self:IsCrusadeScene(scene_id) then
  2708. return true
  2709. end
  2710. return false
  2711. end
  2712. --是否显示所有小怪血条的副本,压力本中需要(经验副本、爬塔副本、幻光副本、宠物副本)
  2713. function SceneManager:IsShowMonsterBloodDun( dun_id )
  2714. return self:IsExpDun(dun_id)
  2715. or self:IsOneTowerDungeon(dun_id)
  2716. or self:IsIllusoryLightDun(dun_id)
  2717. or self:IsPetDungeon(dun_id)
  2718. end
  2719. function SceneManager:CheckSceneFightSoundAvaliable(scene_id)
  2720. return self:IsStarFightScene() or self:IsSpiritWarScene()
  2721. end
  2722. function SceneManager:IsShowLiveEffectScene(scene_id)
  2723. return not self:IsBeachScene() and not self:IsStarDungeonScene()
  2724. end
  2725. --隐藏其他人小头像的场景
  2726. function SceneManager:HideOtherHeadScene( scene_id )
  2727. scene_id = scene_id or self:GetSceneId()
  2728. return false
  2729. end
  2730. --是否需要预加载将神资源的副本
  2731. function SceneManager:IsNeedPreloadGodResScene( )
  2732. -- local sceneInfo = self:GetSceneInfo(scene_id)
  2733. -- if sceneInfo and (sceneInfo.type == 3 or sceneInfo.type == 5 or sceneInfo.type == 7 or sceneInfo.type == 8 or
  2734. -- sceneInfo.type == 9 or sceneInfo.type == 11 or sceneInfo.type == 12 or sceneInfo.type == 13 or
  2735. -- sceneInfo.type == 14 or sceneInfo.type == 15 or sceneInfo.type == 16 or sceneInfo.type == 19) then
  2736. -- return true
  2737. -- elseif sceneInfo and sceneInfo.type == 2 then
  2738. -- return not self:IsStarDungeon() and not self:IsStarFightScene() and not self:IsPkRankFightScene()
  2739. -- end
  2740. return true
  2741. end
  2742. --显示墓碑的场景
  2743. function SceneManager:IsShowGraveScene()
  2744. return self:IsBossDesertedScene() or self:IsBossHomeScene()
  2745. end
  2746. function SceneManager:AddGraveVo(grave_vo)
  2747. self.grave_vo_list[grave_vo.instance_id] = grave_vo
  2748. GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_ADD, grave_vo.instance_id, grave_vo)
  2749. end
  2750. function SceneManager:GetGraveVo(ins_id)
  2751. return self.grave_vo_list[ins_id]
  2752. end
  2753. function SceneManager:DeleteGraveVo(ins_id)
  2754. local vo = self:GetGraveVo(ins_id)
  2755. if vo then
  2756. self.grave_vo_list[ins_id] = nil
  2757. GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_REMOVE, ins_id, vo)
  2758. return vo
  2759. end
  2760. end
  2761. function SceneManager:ClearAllGraveVo()
  2762. if not (self:IsShowGraveScene() or self:IsWorldBeastScene()) then
  2763. for k, vo in pairs(self.grave_vo_list) do
  2764. GlobalEventSystem:Fire(SceneEventType.GRAVE_VO_REMOVE, vo.instance_id, vo)
  2765. end
  2766. self.grave_vo_list = {}
  2767. end
  2768. end
  2769. --主城和野外场景
  2770. function SceneManager:IsMainCityAndFieldScene(scene_id)
  2771. local sceneInfo = self:GetSceneInfo(scene_id)
  2772. return (sceneInfo and (sceneInfo.type == 0 or sceneInfo.type == 1))
  2773. end
  2774. --是否全场景,1为全场景 0为九宫格
  2775. function SceneManager:IsBroadCastScene(scene_id)
  2776. local sceneInfo = self:GetSceneInfo(scene_id)
  2777. return (sceneInfo and sceneInfo.broadcast and sceneInfo.broadcast == 1)
  2778. end
  2779. --是否屏蔽传闻和公告的场景
  2780. function SceneManager:IsNoHornAndNoticeScene(scene_id)
  2781. return self:IsNoonQuizScene()
  2782. end
  2783. function SceneManager:IsSwingScene(scene_id)
  2784. return self:IsBeachScene() or self:IsKFGuildWarFightScene()
  2785. end
  2786. --boss特殊选中光环
  2787. function SceneManager:ShowSpecialLightScene( scene_id )
  2788. return self:IsBossScene(scene_id) or self:IsWorldBeastScene(scene_id)
  2789. end
  2790. --觉醒之门场景
  2791. function SceneManager:IsAwakeScene(scene_id)
  2792. scene_id = scene_id or self:GetSceneId()
  2793. return scene_id == 2401
  2794. end
  2795. --新手引导经验副本
  2796. function SceneManager:IsGuideExpDungeon(dun_id)
  2797. local dun_id = dun_id or self:GetCurrDunId()
  2798. return dun_id == 3002
  2799. end
  2800. --觉醒之门
  2801. function SceneManager:IsAwakeDungeon(dun_id)
  2802. dun_id = dun_id or self:GetCurrDunId()
  2803. local dunConfig = Config.Dungeoncfg[dun_id]
  2804. if dunConfig then
  2805. -- return dunConfig.type == BaseDungeonModel.DUN_TYPE.AWAKE
  2806. else
  2807. return false
  2808. end
  2809. end
  2810. -- 荣耀战神
  2811. function SceneManager:IsHonourFightScene(scene_id)
  2812. -- scene_id = scene_id or self:GetSceneId()
  2813. -- local bf_k = 4
  2814. -- local kf_k = 5
  2815. -- if Config.Wargodkv[bf_k].val == scene_id or Config.Wargodkv[kf_k].val == scene_id then
  2816. -- return true
  2817. -- end
  2818. return false
  2819. end
  2820. function SceneManager:IsLeagueWarScene(scene_id)
  2821. local bool = false
  2822. -- scene_id = scene_id or self:GetSceneId()
  2823. -- if scene_id == Config.Leaguewarconstcfg[6].value or scene_id == Config.Leaguewarconstcfg[11].value then
  2824. -- bool = true
  2825. -- end
  2826. return bool
  2827. end
  2828. -- function SceneManager:NeedEnterSceneAction(force_show_action)
  2829. -- if not force_show_action and RoleManager.Instance.mainRoleInfo.level < 150 then
  2830. -- return false
  2831. -- end
  2832. -- local scene_id = SceneController.Instance.request_scene_id
  2833. -- if scene_id then
  2834. -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id]
  2835. -- if not config_data then
  2836. -- return Config.ConfigChangeSceneEffect.default_action
  2837. -- end
  2838. -- return config_data.pre_action
  2839. -- end
  2840. -- return false
  2841. -- end
  2842. function SceneManager:IsEnterSameScene()
  2843. do return false end
  2844. -- local scene_id = SceneController.Instance.request_scene_id
  2845. -- if scene_id then
  2846. -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id]
  2847. -- if config_data and config_data.load_type == 3 then
  2848. -- return true
  2849. -- end
  2850. -- end
  2851. -- return Config.ConfigChangeSceneEffect.default_load == 3
  2852. end
  2853. function SceneManager:NeedEnterSceneEffect()
  2854. -- local config_data = Config.ConfigChangeSceneEffect.data[self.curr_scene_id]
  2855. -- if not config_data then
  2856. -- return Config.ConfigChangeSceneEffect.default_effect
  2857. -- end
  2858. -- if config_data.enter_effect then
  2859. -- return true
  2860. -- end
  2861. return false
  2862. end
  2863. function SceneManager:SetCacheMainRolePos( )
  2864. local main_role = Scene.Instance:GetMainRole()
  2865. if main_role then
  2866. self.cache_main_role_pos_x = main_role.real_pos.x
  2867. self.cache_main_role_pos_y = main_role.real_pos.y
  2868. self.cache_main_role_birth_angle = main_role:GetDirectionAngle()
  2869. end
  2870. end
  2871. function SceneManager:ResetCacheMainRolePos( )
  2872. self.cache_main_role_pos_x = 0
  2873. self.cache_main_role_pos_y = 0
  2874. self.cache_main_role_birth_angle = nil
  2875. end
  2876. function SceneManager:GetCacheMainRolePos( )
  2877. if self.cache_main_role_pos_x then
  2878. self.cache_main_role_pos_x = self.cache_main_role_pos_x + 1
  2879. end
  2880. return self.cache_main_role_pos_x, self.cache_main_role_pos_y, self.cache_main_role_birth_angle
  2881. end
  2882. --不需要加载场景进度条
  2883. function SceneManager:NoLoadingViewScene(next_scene_id)
  2884. if not next_scene_id then
  2885. return self.is_no_loading_scene
  2886. end
  2887. local cur_scene_id = self:GetSceneId()
  2888. local next_scene_id = next_scene_id
  2889. self.is_no_loading_scene = false
  2890. local temp_cfg = Config.ConfigChangeSceneEffect.data[cur_scene_id]
  2891. if temp_cfg then
  2892. for k,v in pairs(temp_cfg) do
  2893. if v == next_scene_id then
  2894. self.is_no_loading_scene = true
  2895. break
  2896. end
  2897. end
  2898. end
  2899. return self.is_no_loading_scene
  2900. -- local bool = self:IsSpecialSceneLoadEffect(dungeon_id)--有些副本场景切换动画要特殊处理
  2901. -- if bool == false then
  2902. -- return false
  2903. -- end
  2904. -- if BaseDungeonModel:getInstance().exit_by_hand2 then--副本退出的时候也不要无缝切换
  2905. -- BaseDungeonModel:getInstance().exit_by_hand2 = false
  2906. -- self.is_no_loading_scene = false
  2907. -- return false
  2908. -- end
  2909. -- if scene_id then
  2910. -- if Scene.Instance.is_first_enter_scene then
  2911. -- self.is_no_loading_scene = false
  2912. -- Scene.Instance.is_first_enter_scene = false
  2913. -- return false
  2914. -- end
  2915. -- local default_loadtype = Config.ConfigChangeSceneEffect.default_load
  2916. -- local config_data = Config.ConfigChangeSceneEffect.data[scene_id]
  2917. -- local no_loading_state = false
  2918. -- if default_loadtype ~= 1 then
  2919. -- no_loading_state = true
  2920. -- end
  2921. -- if config_data then
  2922. -- if config_data.load_type == 1 then
  2923. -- no_loading_state = false
  2924. -- else
  2925. -- no_loading_state = true
  2926. -- end
  2927. -- end
  2928. -- if not no_loading_state then
  2929. -- config_data = Config.ConfigChangeSceneEffect.data[self:GetSceneId()]
  2930. -- if config_data and config_data.load_type ~= 1 then
  2931. -- no_loading_state = true
  2932. -- end
  2933. -- end
  2934. -- self.is_no_loading_scene = no_loading_state
  2935. -- else
  2936. -- if Scene.Instance.is_first_enter_scene then
  2937. -- return false
  2938. -- end
  2939. -- end
  2940. -- return self.is_no_loading_scene
  2941. end
  2942. --是否在无尽领域
  2943. function SceneManager:IsEndlessScene(scene_id)
  2944. scene_id = scene_id or self:GetSceneId()
  2945. return ((scene_id >= 7100 and scene_id <= 7108) or (scene_id >= 7110 and scene_id <= 7118))
  2946. end
  2947. --是否在无尽领域跨服场景
  2948. function SceneManager:IsCSEndlessScene( scene_id )
  2949. scene_id = scene_id or self:GetSceneId()
  2950. return (scene_id >= 7110 and scene_id <= 7118)
  2951. end
  2952. --是否在无尽领域顶层
  2953. function SceneManager:IsEndlessLastScene( scene_id )
  2954. scene_id = scene_id or self:GetSceneId()
  2955. return (scene_id == EndlessConst.CSENDLESS_NINE_FLOOR_ID or scene_id == EndlessConst.ENDLESS_NINE_FLOOR_ID)
  2956. end
  2957. --是否显示伤害第一标识
  2958. function SceneManager:IsShowAttFirstScene( scene_id )
  2959. return self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id) or self:IsBossDesertedScene() or self:IsBossHomeScene()
  2960. end
  2961. --是否显示boss疲劳
  2962. function SceneManager:IsShowBossTireScene( scene_id )
  2963. return self:IsBossWorldScene(scene_id) or self:IsBossMoneyScene(scene_id)
  2964. end
  2965. --是否显示协助者标识
  2966. function SceneManager:IsShowHelperScene( scene_id )
  2967. return self:IsBossMoneyScene(scene_id) or self:IsGuildScene(scene_id) or self:IsBossDesertedScene()
  2968. end
  2969. --是否显示受击tip
  2970. function SceneManager:IsShowBeenAttackTips( scene_id )
  2971. return self:IsBossMoneyScene(scene_id) or self:IsMainCityAndFieldScene() or self:IsBossDesertedScene() or self:IsBossHomeScene()
  2972. end
  2973. function SceneManager:IsHideMainVipIcon( )
  2974. return self:IsDungeonScene() or self:IsBossWorldScene(scene_id)
  2975. or self:IsBossMoneyScene(scene_id) or self:IsGuildScene() or self:IsEscortScene()
  2976. or self:IsRageWarScene() or self:IsBossDesertedScene() or self:IsGuildCSGRScene() or self:IsGuildWarScene() or self:IsBossHomeScene()
  2977. end
  2978. --是否跨服世界场景(是否需要显示跨服世界分区预告的场景)
  2979. function SceneManager:IsKfWordScene( scene_id )
  2980. local scene_id = scene_id or self:GetSceneId()
  2981. return scene_id == 1016 --跨服主城
  2982. or scene_id == 1017 --跨服护送
  2983. end
  2984. --是否多人战斗场景(是的话会调高同场景人数)
  2985. function SceneManager:IsMultiPlayerBattleScene( )
  2986. return self:IsGuildWarScene() or self:IsCSGWarScene()
  2987. end
  2988. --是否是跨国团战场景
  2989. function SceneManager:IsCSGWarScene( scene_id )
  2990. scene_id = scene_id or self:GetSceneId()
  2991. return Config.Crossguildwarconfig[11].value == scene_id
  2992. end
  2993. -- 是否是狂战领域活动场景
  2994. function SceneManager:IsRageWarScene(scene_id)
  2995. scene_id = scene_id or self:GetSceneId()
  2996. return scene_id == 7800 -- 本服阶段
  2997. or scene_id == 7810 -- 开服未开启跨服的本服第二阶段
  2998. or scene_id == 7820 -- 跨服阶段
  2999. end
  3000. -- 是否是狂战领域第二阶段场景
  3001. function SceneManager:IsRageWarRound2Scene(scene_id)
  3002. scene_id = scene_id or self:GetSceneId()
  3003. return scene_id == 7810 -- 开服未开启跨服的本服第二阶段
  3004. or scene_id == 7820 -- 跨服阶段
  3005. end
  3006. function SceneManager:IsRageWarCrossServerScene(scene_id)
  3007. scene_id = scene_id or self:GetSceneId()
  3008. return scene_id == 7820
  3009. end
  3010. --是否是特殊场景加载场景切换特效
  3011. function SceneManager:IsSpecialSceneLoadEffect( dungeon_id )
  3012. if self:IsOneTowerDungeon(dungeon_id) then --爬塔副本,在第一次进去的时候,不要无缝切换,第二次开始才无缝切换
  3013. if not self.is_first_enter_tower_dun then
  3014. self.is_first_enter_tower_dun = true
  3015. return false
  3016. end
  3017. else
  3018. self.is_first_enter_tower_dun = false
  3019. end
  3020. end
  3021. --是否在废土战场
  3022. function SceneManager:IsWastelandScene(scene_id)
  3023. local scene_id = scene_id or self:GetSceneId()
  3024. return ((scene_id >= 7600 and scene_id <= 7621) or scene_id == 7630 or scene_id == 7631)
  3025. end
  3026. --是否在废土战场跨服场景
  3027. function SceneManager:IsCSWastelandScene( scene_id )
  3028. local scene_id = scene_id or self:GetSceneId()
  3029. return (scene_id == 7601 or scene_id == 7611 or scene_id == 7621 or scene_id == 7631)
  3030. end
  3031. --废土准备场景
  3032. function SceneManager:IsWastelandPrepareScene( )
  3033. local scene_id = scene_id or self:GetSceneId()
  3034. return scene_id == 7630 or scene_id == 7631
  3035. end
  3036. --是否展示左侧的动态轮播信息场景
  3037. function SceneManager:IsShowDynamicInfoScene(scene_id)
  3038. local scene_id = scene_id or self:GetSceneId()
  3039. if self:IsWastelandPrepareScene(scene_id) -- 废土准备场景
  3040. or self:IsGuildScene(scene_id) -- 社团驻地场景
  3041. or BeachModel:GetInstance():IsShowDynamicInfo(scene_id) -- 温泉场景
  3042. or self:IsGuildWarScene(scene_id) --本服团战
  3043. or self:IsEndlessScene(scene_id)--无尽领域
  3044. or self:IsGuildCSGRScene(scene_id) -- 本国团战
  3045. then
  3046. return true
  3047. end
  3048. return false
  3049. end
  3050. --得到道具假掉落位置单位是80(掉落的数量)
  3051. function SceneManager:GetGoodsFakerDropPosList( goods_len, per_interval )
  3052. if not goods_len or goods_len == 0 then return end
  3053. local per_interval = per_interval or 80
  3054. local pos_list = {}
  3055. local dot_list = nil
  3056. for k,v in ipairs(self.drop_pos_cfg) do
  3057. if k <= goods_len then
  3058. pos_list[#pos_list + 1] = {pos_x = per_interval*v[1],pos_y = per_interval*v[2]}
  3059. else
  3060. break
  3061. end
  3062. end
  3063. return pos_list
  3064. end
  3065. --初始化掉落随机位置列表
  3066. function SceneManager:InitDropPosCfg( )
  3067. self.drop_pos_cfg = {}
  3068. local cfg = DeepCopy(Config.Dropdotrule)
  3069. for k,v in ipairs(cfg) do
  3070. local dot_list = stringtotable(v.dot_list)
  3071. for ii,vv in ipairs(dot_list) do
  3072. self.drop_pos_cfg[#self.drop_pos_cfg + 1] = vv
  3073. end
  3074. end
  3075. end
  3076. --设置当前攻击主角的目标数据(右下角头像显示)
  3077. function SceneManager:SetAttackHeadVo( vo, role_id, force )
  3078. --手动点击角色,要覆盖目标
  3079. if force then
  3080. self.target_head_vo = vo
  3081. GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, true, vo, 2)
  3082. return
  3083. end
  3084. --战斗那边不知道vo,只有role_id,需要去场景上拿
  3085. if not self.target_head_vo then
  3086. if role_id then
  3087. vo = self:GetRoleVo(role_id)
  3088. end
  3089. self.target_head_vo = vo
  3090. if vo then
  3091. GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, true, vo, 2)
  3092. end
  3093. end
  3094. end
  3095. function SceneManager:ResetAttackHeadVo(hide_head)
  3096. if hide_head then
  3097. if self.target_head_vo then
  3098. GlobalEventSystem:Fire(EventName.SHOW_OTHER_HEAD, false)
  3099. end
  3100. end
  3101. self.target_head_vo = false
  3102. end
  3103. function SceneManager:GetAttackHeadVo( )
  3104. return self.target_head_vo
  3105. end
  3106. function SceneManager:GetScenObjDepth(y)
  3107. return SceneDepth.Obj + y * 0.5
  3108. end
  3109. function SceneManager:GetCameraRotateConfig( )
  3110. -- if not self:IsMainCityAndFieldScene() then
  3111. -- return
  3112. -- end
  3113. local scene_id = self:GetSceneId()
  3114. local temp_cfg = self.camera_rotate_cfg[scene_id]
  3115. if temp_cfg then
  3116. return temp_cfg
  3117. end
  3118. temp_cfg = Config.ConfigSceneCamera[scene_id] or Config.ConfigSceneCamera["default"]
  3119. if temp_cfg and temp_cfg.area_list then
  3120. self.camera_rotate_cfg[scene_id] = temp_cfg
  3121. return temp_cfg
  3122. end
  3123. end
  3124. function SceneManager:GetCameraRotateAngle( angle )
  3125. local cfg = self:GetCameraRotateConfig()
  3126. if not cfg then
  3127. return
  3128. end
  3129. local area_list = cfg.area_list or {}
  3130. local area_index, camera_angle
  3131. for k,v in pairs(area_list) do
  3132. local is_turn_around = false
  3133. if v[1] > v[2] then
  3134. is_turn_around = true
  3135. end
  3136. if is_turn_around and (angle > v[1] or angle <= v[2]) then
  3137. area_index = k
  3138. camera_angle = v[3]
  3139. break
  3140. elseif angle > v[1] and angle <= v[2] then
  3141. area_index = k
  3142. camera_angle = v[3]
  3143. break
  3144. end
  3145. end
  3146. if area_index and camera_angle then
  3147. return area_index, camera_angle
  3148. end
  3149. end
  3150. function SceneManager:IsDesertedBossCrossScene( scene_id )
  3151. local scene_id = scene_id or self:GetSceneId()
  3152. return BossModel:GetInstance():CheckIsCrossDesertedScene(scene_id)
  3153. end
  3154. function SceneManager:IsUnderWaterScene( scene_id )
  3155. local scene_id = scene_id or self:GetSceneId()
  3156. return scene_id == 1005 or scene_id == 2209 or scene_id == 2210 or scene_id == 10051
  3157. end
  3158. function SceneManager:IsMappingToSameScene( cur_id, tar_id )
  3159. self.scene_mapping_cfg = self.scene_mapping_cfg or {
  3160. [1003] = 1,
  3161. [1016] = 1,
  3162. [4063] = 2,
  3163. [4064] = 2,
  3164. }
  3165. if self.scene_mapping_cfg[cur_id] and self.scene_mapping_cfg[cur_id] == self.scene_mapping_cfg[tar_id] then
  3166. return true
  3167. end
  3168. return false
  3169. end
  3170. function SceneManager:CheckMatchLoadingRes( )
  3171. local res_list = {}
  3172. local role_lev = RoleManager.Instance.mainRoleInfo.level
  3173. if role_lev == 0 then
  3174. role_lev = LoginModel:getInstance():GetSelectRoleLevel() or 0
  3175. end
  3176. local open_serevr_time = ServerTimeModel:getInstance():GetOpenServerDay()
  3177. local cur_server_time = TimeUtil:getServerTime()
  3178. local create_role_time = ServerTimeModel:getInstance():GetCreateRoleDay()
  3179. local level_match, server_match, time_match, create_match,week_match --匹配标示
  3180. local level_item, server_item, create_item,week_item
  3181. local max_ran = 0
  3182. for k,v in pairs(Config.Sceneload) do
  3183. level_match, server_match, time_match, create_match, week_match = true, true, true, true,true
  3184. if v.lv then
  3185. level_item = stringtotable(v.lv)
  3186. if not IsTableEmpty(level_item) and (role_lev < level_item[1] or role_lev > level_item[2]) then
  3187. if (role_lev < level_item[1] or level_item[2] ~= 0 ) then
  3188. level_match = false
  3189. end
  3190. end
  3191. end
  3192. if v.server_open then
  3193. server_item = stringtotable(v.server_open)
  3194. if not IsTableEmpty(server_item) and (open_serevr_time < server_item[1] or open_serevr_time > server_item[2]) then
  3195. if (open_serevr_time < server_item[1] or server_item[2] ~= 0 ) then
  3196. server_match = false
  3197. end
  3198. end
  3199. end
  3200. if v.start_time and tonumber(v.start_time) > 0 and v.end_time and tonumber(v.end_time) > 0 then
  3201. if cur_server_time < tonumber(v.start_time) or cur_server_time > tonumber(v.end_time)then
  3202. time_match = false
  3203. end
  3204. end
  3205. if v.create_day then
  3206. if v.create_day then
  3207. create_item = stringtotable(v.create_day)
  3208. if not IsTableEmpty(create_item) and (create_role_time < create_item[1] or create_role_time > create_item[2]) then
  3209. if (create_role_time < create_item[1] or create_item[2] ~= 0 ) then
  3210. create_match = false
  3211. end
  3212. end
  3213. end
  3214. end
  3215. if v.week then
  3216. create_week = stringtotable(v.week)
  3217. local cur_date = os.date("*t", cur_server_time)
  3218. local cur_week_day = cur_date and cur_date.wday
  3219. cur_week_day = cur_week_day - 1 == 0 and 7 or cur_week_day - 1 --os.date周日是1,但是配置1是周一
  3220. if cur_week_day and not IsTableEmpty(create_week) then
  3221. week_match = false
  3222. for k,v in pairs(create_week) do
  3223. if tonumber(v) == tonumber(cur_week_day) then
  3224. week_match = true
  3225. break
  3226. end
  3227. end
  3228. end
  3229. end
  3230. --全部条件满足的才放到列表里
  3231. if level_match and server_match and time_match and create_match and week_match and v.weight then
  3232. max_ran = max_ran + v.weight
  3233. table.insert(res_list, v.id)
  3234. end
  3235. end
  3236. --按权重随机
  3237. local cur_res_id = 1
  3238. if #res_list >= 1 then
  3239. math.randomseed(os.clock() * 100000000)
  3240. local random_index = math.random(1, max_ran)
  3241. local temp_cfg
  3242. local cur_weight = 0
  3243. for i=1, #res_list do
  3244. temp_cfg = Config.Sceneload[res_list[i]]
  3245. if temp_cfg and temp_cfg.weight then
  3246. cur_weight = cur_weight + temp_cfg.weight
  3247. if cur_weight >= random_index then
  3248. cur_res_id = temp_cfg.res_id
  3249. break
  3250. end
  3251. end
  3252. end
  3253. end
  3254. return cur_res_id
  3255. end
  3256. function SceneManager:IsDunExpSeaScene( scene_id )
  3257. local scene_id = scene_id or self:GetSceneId()
  3258. return scene_id == Config.Expseafloor[1].scene
  3259. end