Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / room / DungeonManager.cs
  1.  
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using Godot;
  6.  
  7. /// <summary>
  8. /// 地牢管理器
  9. /// </summary>
  10. public partial class DungeonManager : Node2D
  11. {
  12. /// <summary>
  13. /// 起始房间
  14. /// </summary>
  15. public RoomInfo StartRoomInfo => _dungeonGenerator?.StartRoomInfo;
  16. /// <summary>
  17. /// 当前玩家所在的房间
  18. /// </summary>
  19. public RoomInfo ActiveRoomInfo => Player.Current?.AffiliationArea?.RoomInfo;
  20. /// <summary>
  21. /// 当前玩家所在的区域
  22. /// </summary>
  23. public AffiliationArea ActiveAffiliationArea => Player.Current?.AffiliationArea;
  24.  
  25. /// <summary>
  26. /// 是否在地牢里
  27. /// </summary>
  28. public bool IsInDungeon { get; private set; }
  29.  
  30. /// <summary>
  31. /// 是否是编辑器模式
  32. /// </summary>
  33. public bool IsEditorMode { get; private set; }
  34. /// <summary>
  35. /// 当前使用的配置
  36. /// </summary>
  37. public DungeonConfig CurrConfig { get; private set; }
  38. private UiBase _prevUi;
  39. private DungeonTileMap _dungeonTileMap;
  40. private AutoTileConfig _autoTileConfig;
  41. private DungeonGenerator _dungeonGenerator;
  42. //房间内所有静态导航网格数据
  43. private List<NavigationPolygonData> _roomStaticNavigationList;
  44. private World _world;
  45. //用于检查房间敌人的计时器
  46. private float _checkEnemyTimer = 0;
  47.  
  48.  
  49. public DungeonManager()
  50. {
  51. //绑定事件
  52. EventManager.AddEventListener(EventEnum.OnPlayerFirstEnterRoom, OnPlayerFirstEnterRoom);
  53. EventManager.AddEventListener(EventEnum.OnPlayerEnterRoom, OnPlayerEnterRoom);
  54. }
  55. /// <summary>
  56. /// 加载地牢
  57. /// </summary>
  58. public void LoadDungeon(DungeonConfig config, Action finish = null)
  59. {
  60. IsEditorMode = false;
  61. CurrConfig = config;
  62. GameApplication.Instance.StartCoroutine(RunLoadDungeonCoroutine(finish));
  63. }
  64. /// <summary>
  65. /// 重启地牢
  66. /// </summary>
  67. public void RestartDungeon(DungeonConfig config)
  68. {
  69. IsEditorMode = false;
  70. CurrConfig = config;
  71. ExitDungeon(() =>
  72. {
  73. LoadDungeon(CurrConfig);
  74. });
  75. }
  76.  
  77. /// <summary>
  78. /// 退出地牢
  79. /// </summary>
  80. public void ExitDungeon(Action finish = null)
  81. {
  82. IsInDungeon = false;
  83. GameApplication.Instance.StartCoroutine(RunExitDungeonCoroutine(finish));
  84. }
  85. //-------------------------------------------------------------------------------------
  86.  
  87. /// <summary>
  88. /// 在编辑器模式下进入地牢
  89. /// </summary>
  90. /// <param name="config">地牢配置</param>
  91. public void EditorPlayDungeon(DungeonConfig config)
  92. {
  93. IsEditorMode = true;
  94. CurrConfig = config;
  95. if (_prevUi != null)
  96. {
  97. _prevUi.HideUi();
  98. }
  99. GameApplication.Instance.StartCoroutine(RunLoadDungeonCoroutine(null));
  100. }
  101. /// <summary>
  102. /// 在编辑器模式下进入地牢
  103. /// </summary>
  104. /// <param name="prevUi">记录上一个Ui</param>
  105. /// <param name="config">地牢配置</param>
  106. public void EditorPlayDungeon(UiBase prevUi, DungeonConfig config)
  107. {
  108. IsEditorMode = true;
  109. CurrConfig = config;
  110. _prevUi = prevUi;
  111. if (_prevUi != null)
  112. {
  113. _prevUi.HideUi();
  114. }
  115. GameApplication.Instance.StartCoroutine(RunLoadDungeonCoroutine(null));
  116. }
  117.  
  118. /// <summary>
  119. /// 在编辑器模式下退出地牢, 并且打开上一个Ui
  120. /// </summary>
  121. public void EditorExitDungeon()
  122. {
  123. IsInDungeon = false;
  124. GameApplication.Instance.StartCoroutine(RunExitDungeonCoroutine(() =>
  125. {
  126. IsEditorMode = false;
  127. //显示上一个Ui
  128. if (_prevUi != null)
  129. {
  130. _prevUi.ShowUi();
  131. }
  132. }));
  133. }
  134. //-------------------------------------------------------------------------------------
  135.  
  136. public override void _Process(double delta)
  137. {
  138. if (IsInDungeon)
  139. {
  140. _checkEnemyTimer += (float)delta;
  141. if (_checkEnemyTimer >= 1)
  142. {
  143. _checkEnemyTimer %= 1;
  144. //检查房间内的敌人存活状况
  145. OnCheckEnemy();
  146. }
  147. //更新敌人视野
  148. UpdateEnemiesView();
  149. if (GameApplication.Instance.Debug)
  150. {
  151. QueueRedraw();
  152. }
  153. }
  154. }
  155.  
  156. //执行加载地牢协程
  157. private IEnumerator RunLoadDungeonCoroutine(Action finish)
  158. {
  159. //打开 loading UI
  160. UiManager.Open_Loading();
  161. yield return 0;
  162. //创建世界场景
  163. _world = GameApplication.Instance.CreateNewWorld();
  164. yield return new WaitForFixedProcess(10);
  165. //生成地牢房间
  166. _dungeonGenerator = new DungeonGenerator(CurrConfig);
  167. _dungeonGenerator.Generate();
  168. yield return 0;
  169. //填充地牢
  170. _autoTileConfig = new AutoTileConfig();
  171. _dungeonTileMap = new DungeonTileMap(_world.TileRoot);
  172. _dungeonTileMap.AutoFillRoomTile(_autoTileConfig, _dungeonGenerator.StartRoomInfo, _dungeonGenerator.Random);
  173. yield return 0;
  174. //生成寻路网格, 这一步操作只生成过道的导航
  175. _dungeonTileMap.GenerateNavigationPolygon(GameConfig.AisleFloorMapLayer);
  176. yield return 0;
  177. //挂载过道导航区域
  178. _dungeonTileMap.MountNavigationPolygon(_world.TileRoot);
  179. yield return 0;
  180. //过道导航区域数据
  181. _roomStaticNavigationList = new List<NavigationPolygonData>();
  182. _roomStaticNavigationList.AddRange(_dungeonTileMap.GetPolygonData());
  183. yield return 0;
  184. //门导航区域数据
  185. _roomStaticNavigationList.AddRange(_dungeonTileMap.GetConnectDoorPolygonData());
  186. yield return new WaitForFixedProcess(10);
  187. //初始化所有房间
  188. _dungeonGenerator.EachRoom(InitRoom);
  189. yield return new WaitForFixedProcess(10);
  190.  
  191. //播放bgm
  192. //SoundManager.PlayMusic(ResourcePath.resource_sound_bgm_Intro_ogg, -17f);
  193.  
  194. //初始房间创建玩家标记
  195. var playerBirthMark = StartRoomInfo.RoomPreinstall.GetPlayerBirthMark();
  196. //创建玩家
  197. var player = ActivityObject.Create<Player>(ActivityObject.Ids.Id_role0001);
  198. if (playerBirthMark != null)
  199. {
  200. //player.Position = new Vector2(50, 50);
  201. player.Position = playerBirthMark.Position;
  202. }
  203. player.Name = "Player";
  204. player.PutDown(RoomLayerEnum.YSortLayer);
  205. Player.SetCurrentPlayer(player);
  206. //地牢加载即将完成
  207. _dungeonGenerator.EachRoom(info => info.OnReady());
  208.  
  209. //玩家手上添加武器
  210. //player.PickUpWeapon(ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0001));
  211. // var weapon = ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0001);
  212. // weapon.PutDown(player.Position, RoomLayerEnum.NormalLayer);
  213. // var weapon2 = ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0002);
  214. // weapon2.PutDown(player.Position, RoomLayerEnum.NormalLayer);
  215. // var weapon3 = ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0003);
  216. // weapon3.PutDown(player.Position, RoomLayerEnum.NormalLayer);
  217. // var weapon4 = ActivityObject.Create<Weapon>(ActivityObject.Ids.Id_weapon0004);
  218. // weapon4.PutDown(player.Position, RoomLayerEnum.NormalLayer);
  219.  
  220. GameApplication.Instance.Cursor.SetGuiMode(false);
  221. yield return 0;
  222. //打开游戏中的ui
  223. UiManager.Open_RoomUI();
  224. //派发进入地牢事件
  225. EventManager.EmitEvent(EventEnum.OnEnterDungeon);
  226. IsInDungeon = true;
  227. QueueRedraw();
  228. yield return 0;
  229. //关闭 loading UI
  230. UiManager.Destroy_Loading();
  231. if (finish != null)
  232. {
  233. finish();
  234. }
  235. }
  236.  
  237. private IEnumerator RunExitDungeonCoroutine(Action finish)
  238. {
  239. //打开 loading UI
  240. UiManager.Open_Loading();
  241. yield return 0;
  242. _world.Pause = true;
  243. yield return 0;
  244. _dungeonGenerator.EachRoom(DisposeRoomInfo);
  245. yield return 0;
  246. _dungeonTileMap = null;
  247. _autoTileConfig = null;
  248. _dungeonGenerator = null;
  249. _roomStaticNavigationList.Clear();
  250. _roomStaticNavigationList = null;
  251. UiManager.Hide_RoomUI();
  252. yield return new WaitForFixedProcess(10);
  253. Player.SetCurrentPlayer(null);
  254. _world = null;
  255. GameApplication.Instance.DestroyWorld();
  256. yield return new WaitForFixedProcess(10);
  257. QueueRedraw();
  258. //鼠标还原
  259. GameApplication.Instance.Cursor.SetGuiMode(true);
  260. //派发退出地牢事件
  261. EventManager.EmitEvent(EventEnum.OnExitDungeon);
  262. yield return 0;
  263. //关闭 loading UI
  264. UiManager.Destroy_Loading();
  265. if (finish != null)
  266. {
  267. finish();
  268. }
  269. }
  270. // 初始化房间
  271. private void InitRoom(RoomInfo roomInfo)
  272. {
  273. //挂载房间导航区域
  274. MountNavFromRoomInfo(roomInfo);
  275. //创建门
  276. CreateDoor(roomInfo);
  277. //创建房间归属区域
  278. CreateRoomAffiliation(roomInfo);
  279. //创建静态精灵画布
  280. CreateRoomStaticSpriteCanvas(roomInfo);
  281. }
  282. //挂载房间导航区域
  283. private void MountNavFromRoomInfo(RoomInfo roomInfo)
  284. {
  285. var polygonArray = roomInfo.RoomSplit.TileInfo.NavigationList;
  286. var polygon = new NavigationPolygon();
  287. var offset = roomInfo.GetOffsetPosition();
  288. for (var i = 0; i < polygonArray.Count; i++)
  289. {
  290. var navigationPolygonData = polygonArray[i];
  291. var tempPosArray = navigationPolygonData.GetPoints();
  292. var polygonPointArray = new Vector2[tempPosArray.Length];
  293. //这里的位置需要加上房间位置
  294. for (var j = 0; j < tempPosArray.Length; j++)
  295. {
  296. polygonPointArray[j] = tempPosArray[j] + roomInfo.GetWorldPosition() - offset;
  297. }
  298. polygon.AddOutline(polygonPointArray);
  299.  
  300. //存入汇总列表
  301. var polygonData = new NavigationPolygonData(navigationPolygonData.Type);
  302. polygonData.SetPoints(polygonPointArray);
  303. _roomStaticNavigationList.Add(polygonData);
  304. }
  305. polygon.MakePolygonsFromOutlines();
  306. var navigationPolygon = new NavigationRegion2D();
  307. navigationPolygon.Name = "NavigationRegion" + (GetChildCount() + 1);
  308. navigationPolygon.NavigationPolygon = polygon;
  309. _world.TileRoot.AddChild(navigationPolygon);
  310. }
  311.  
  312. //创建门
  313. private void CreateDoor(RoomInfo roomInfo)
  314. {
  315. foreach (var doorInfo in roomInfo.Doors)
  316. {
  317. RoomDoor door;
  318. switch (doorInfo.Direction)
  319. {
  320. case DoorDirection.E:
  321. door = ActivityObject.Create<RoomDoor>(ActivityObject.Ids.Id_other_door_e);
  322. door.Position = (doorInfo.OriginPosition + new Vector2(0.5f, 2)) * GameConfig.TileCellSize;
  323. door.ZIndex = GameConfig.TopMapLayer;
  324. break;
  325. case DoorDirection.W:
  326. door = ActivityObject.Create<RoomDoor>(ActivityObject.Ids.Id_other_door_w);
  327. door.Position = (doorInfo.OriginPosition + new Vector2(-0.5f, 2)) * GameConfig.TileCellSize;
  328. door.ZIndex = GameConfig.TopMapLayer;
  329. break;
  330. case DoorDirection.S:
  331. door = ActivityObject.Create<RoomDoor>(ActivityObject.Ids.Id_other_door_s);
  332. door.Position = (doorInfo.OriginPosition + new Vector2(2f, 1.5f)) * GameConfig.TileCellSize;
  333. door.ZIndex = GameConfig.TopMapLayer;
  334. break;
  335. case DoorDirection.N:
  336. door = ActivityObject.Create<RoomDoor>(ActivityObject.Ids.Id_other_door_n);
  337. door.Position = (doorInfo.OriginPosition + new Vector2(2f, -0.5f)) * GameConfig.TileCellSize;
  338. door.ZIndex = GameConfig.MiddleMapLayer;
  339. break;
  340. default:
  341. return;
  342. }
  343. doorInfo.Door = door;
  344. door.Init(doorInfo);
  345. door.PutDown(RoomLayerEnum.NormalLayer, false);
  346. }
  347. }
  348.  
  349. //创建房间归属区域
  350. private void CreateRoomAffiliation(RoomInfo roomInfo)
  351. {
  352. var affiliation = new AffiliationArea();
  353. affiliation.Name = "AffiliationArea" + roomInfo.Id;
  354. affiliation.Init(roomInfo, new Rect2(
  355. roomInfo.GetWorldPosition() + new Vector2(GameConfig.TileCellSize, GameConfig.TileCellSize),
  356. (roomInfo.Size - new Vector2I(2, 2)) * GameConfig.TileCellSize));
  357. roomInfo.AffiliationArea = affiliation;
  358. _world.AffiliationAreaRoot.AddChild(affiliation);
  359. }
  360.  
  361. //创建静态精灵画布
  362. private void CreateRoomStaticSpriteCanvas(RoomInfo roomInfo)
  363. {
  364. var worldPos = roomInfo.GetWorldPosition();
  365. var pos = new Vector2I((int)worldPos.X, (int)worldPos.Y);
  366. int minX = pos.X;
  367. int minY = pos.Y;
  368. int maxX = minX + roomInfo.GetWidth();
  369. int maxY = minY + roomInfo.GetHeight();
  370.  
  371. //遍历每一个连接的门, 计算计算canvas覆盖范围
  372. foreach (var doorInfo in roomInfo.Doors)
  373. {
  374. var connectDoor = doorInfo.ConnectDoor;
  375. switch (connectDoor.Direction)
  376. {
  377. case DoorDirection.E:
  378. case DoorDirection.W:
  379. {
  380. var (px1, py1) = connectDoor.GetWorldOriginPosition();
  381. var py2 = py1 + 4 * GameConfig.TileCellSize;
  382. if (px1 < minX)
  383. {
  384. minX = px1;
  385. }
  386. else if (px1 > maxX)
  387. {
  388. maxX = px1;
  389. }
  390.  
  391. if (py1 < minY)
  392. {
  393. minY = py1;
  394. }
  395. else if (py1 > maxY)
  396. {
  397. maxY = py1;
  398. }
  399. if (py2 < minY)
  400. {
  401. minY = py2;
  402. }
  403. else if (py2 > maxY)
  404. {
  405. maxY = py2;
  406. }
  407. }
  408. break;
  409. case DoorDirection.S:
  410. case DoorDirection.N:
  411. {
  412. var (px1, py1) = connectDoor.GetWorldOriginPosition();
  413. var px2 = px1 + 4 * GameConfig.TileCellSize;
  414. if (px1 < minX)
  415. {
  416. minX = px1;
  417. }
  418. else if (px1 > maxX)
  419. {
  420. maxX = px1;
  421. }
  422.  
  423. if (py1 < minY)
  424. {
  425. minY = py1;
  426. }
  427. else if (py1 > maxY)
  428. {
  429. maxY = py1;
  430. }
  431. if (px2 < minX)
  432. {
  433. minX = px2;
  434. }
  435. else if (px2 > maxX)
  436. {
  437. maxX = px2;
  438. }
  439. }
  440. break;
  441. }
  442. }
  443.  
  444. minX -= GameConfig.TileCellSize;
  445. minY -= GameConfig.TileCellSize;
  446. maxX += GameConfig.TileCellSize;
  447. maxY += GameConfig.TileCellSize;
  448. var staticSpriteCanvas = new RoomStaticImageCanvas(
  449. _world.StaticSpriteRoot,
  450. new Vector2I(minX, minY),
  451. maxX - minX, maxY - minY
  452. );
  453. staticSpriteCanvas.RoomOffset = new Vector2I(worldPos.X - minX, worldPos.Y - minY);
  454. roomInfo.StaticImageCanvas = staticSpriteCanvas;
  455. }
  456.  
  457. /// <summary>
  458. /// 玩家第一次进入某个房间回调
  459. /// </summary>
  460. private void OnPlayerFirstEnterRoom(object o)
  461. {
  462. var room = (RoomInfo)o;
  463. room.OnFirstEnter();
  464. //如果关门了, 那么房间外的敌人就会丢失目标
  465. if (room.IsSeclusion)
  466. {
  467. var playerAffiliationArea = Player.Current.AffiliationArea;
  468. foreach (var enemy in _world.Enemy_InstanceList)
  469. {
  470. //不与玩家处于同一个房间
  471. if (enemy.AffiliationArea != playerAffiliationArea)
  472. {
  473. if (enemy.StateController.CurrState != AiStateEnum.AiNormal)
  474. {
  475. enemy.StateController.ChangeState(AiStateEnum.AiNormal);
  476. }
  477. }
  478. }
  479. }
  480. }
  481.  
  482. /// <summary>
  483. /// 玩家进入某个房间回调
  484. /// </summary>
  485. private void OnPlayerEnterRoom(object o)
  486. {
  487. }
  488. /// <summary>
  489. /// 检测当前房间敌人是否已经消灭干净, 应当每秒执行一次
  490. /// </summary>
  491. private void OnCheckEnemy()
  492. {
  493. var activeRoom = ActiveRoomInfo;
  494. if (activeRoom != null)// && //activeRoom.IsSeclusion)
  495. {
  496. if (activeRoom.IsSeclusion) //房间处于关上状态
  497. {
  498. if (activeRoom.IsCurrWaveOver()) //所有标记执行完成
  499. {
  500. //是否有存活的敌人
  501. var flag = ActiveAffiliationArea.ExistIncludeItem(
  502. activityObject => activityObject.CollisionWithMask(PhysicsLayer.Enemy)
  503. );
  504. //GD.Print("当前房间存活数量: " + count);
  505. if (!flag)
  506. {
  507. activeRoom.OnClearRoom();
  508. }
  509. }
  510. }
  511. }
  512. }
  513.  
  514. /// <summary>
  515. /// 更新敌人视野
  516. /// </summary>
  517. private void UpdateEnemiesView()
  518. {
  519. _world.Enemy_IsFindTarget = false;
  520. _world.Enemy_FindTargetAffiliationSet.Clear();
  521. for (var i = 0; i < _world.Enemy_InstanceList.Count; i++)
  522. {
  523. var enemy = _world.Enemy_InstanceList[i];
  524. var state = enemy.StateController.CurrState;
  525. if (state == AiStateEnum.AiFollowUp || state == AiStateEnum.AiSurround) //目标在视野内
  526. {
  527. if (!_world.Enemy_IsFindTarget)
  528. {
  529. _world.Enemy_IsFindTarget = true;
  530. _world.Enemy_FindTargetPosition = Player.Current.GetCenterPosition();
  531. _world.Enemy_FindTargetAffiliationSet.Add(Player.Current.AffiliationArea);
  532. }
  533. _world.Enemy_FindTargetAffiliationSet.Add(enemy.AffiliationArea);
  534. }
  535. }
  536. }
  537.  
  538. private void DisposeRoomInfo(RoomInfo roomInfo)
  539. {
  540. roomInfo.Destroy();
  541. }
  542. public override void _Draw()
  543. {
  544. if (GameApplication.Instance.Debug)
  545. {
  546. if (_dungeonTileMap != null)
  547. {
  548. //绘制ai寻路区域
  549. Utils.DrawNavigationPolygon(this, _roomStaticNavigationList.ToArray());
  550. }
  551. //绘制房间区域
  552. // if (_dungeonGenerator != null)
  553. // {
  554. // DrawRoomInfo(StartRoom);
  555. // }
  556. //绘制边缘线
  557. }
  558. }
  559. //绘制房间区域, debug 用
  560. private void DrawRoomInfo(RoomInfo roomInfo)
  561. {
  562. var cellSize = _world.TileRoot.CellQuadrantSize;
  563. var pos1 = (roomInfo.Position + roomInfo.Size / 2) * cellSize;
  564. //绘制下一个房间
  565. foreach (var nextRoom in roomInfo.Next)
  566. {
  567. var pos2 = (nextRoom.Position + nextRoom.Size / 2) * cellSize;
  568. DrawLine(pos1, pos2, Colors.Red);
  569. DrawRoomInfo(nextRoom);
  570. }
  571.  
  572. DrawString(ResourceManager.DefaultFont16Px, pos1 - new Vector2I(0, 10), "Id: " + roomInfo.Id.ToString());
  573. DrawString(ResourceManager.DefaultFont16Px, pos1 + new Vector2I(0, 10), "Layer: " + roomInfo.Layer.ToString());
  574.  
  575. //绘制门
  576. foreach (var roomDoor in roomInfo.Doors)
  577. {
  578. var originPos = roomDoor.OriginPosition * cellSize;
  579. switch (roomDoor.Direction)
  580. {
  581. case DoorDirection.E:
  582. DrawLine(originPos, originPos + new Vector2(3, 0) * cellSize, Colors.Yellow);
  583. DrawLine(originPos + new Vector2(0, 4) * cellSize, originPos + new Vector2(3, 4) * cellSize,
  584. Colors.Yellow);
  585. break;
  586. case DoorDirection.W:
  587. DrawLine(originPos, originPos - new Vector2(3, 0) * cellSize, Colors.Yellow);
  588. DrawLine(originPos + new Vector2(0, 4) * cellSize, originPos - new Vector2(3, -4) * cellSize,
  589. Colors.Yellow);
  590. break;
  591. case DoorDirection.S:
  592. DrawLine(originPos, originPos + new Vector2(0, 3) * cellSize, Colors.Yellow);
  593. DrawLine(originPos + new Vector2(4, 0) * cellSize, originPos + new Vector2(4, 3) * cellSize,
  594. Colors.Yellow);
  595. break;
  596. case DoorDirection.N:
  597. DrawLine(originPos, originPos - new Vector2(0, 3) * cellSize, Colors.Yellow);
  598. DrawLine(originPos + new Vector2(4, 0) * cellSize, originPos - new Vector2(-4, 3) * cellSize,
  599. Colors.Yellow);
  600. break;
  601. }
  602. //绘制房间区域
  603. DrawRect(new Rect2(roomInfo.Position * cellSize, roomInfo.Size * cellSize), Colors.Blue, false);
  604.  
  605. if (roomDoor.HasCross && roomDoor.RoomInfo.Id < roomDoor.ConnectRoom.Id)
  606. {
  607. DrawRect(new Rect2(roomDoor.Cross * cellSize, new Vector2(cellSize * 4, cellSize * 4)), Colors.Yellow, false);
  608. }
  609. }
  610. }
  611. /// <summary>
  612. /// 将房间类型枚举转为字符串
  613. /// </summary>
  614. public static string DungeonRoomTypeToString(DungeonRoomType roomType)
  615. {
  616. switch (roomType)
  617. {
  618. case DungeonRoomType.Battle: return "battle";
  619. case DungeonRoomType.Inlet: return "inlet";
  620. case DungeonRoomType.Outlet: return "outlet";
  621. case DungeonRoomType.Boss: return "boss";
  622. case DungeonRoomType.Reward: return "reward";
  623. case DungeonRoomType.Shop: return "shop";
  624. case DungeonRoomType.Event: return "event";
  625. }
  626.  
  627. return "battle";
  628. }
  629. /// <summary>
  630. /// 将房间类型枚举转为描述字符串
  631. /// </summary>
  632. public static string DungeonRoomTypeToDescribeString(DungeonRoomType roomType)
  633. {
  634. switch (roomType)
  635. {
  636. case DungeonRoomType.Battle: return "战斗房间";
  637. case DungeonRoomType.Inlet: return "起始房间";
  638. case DungeonRoomType.Outlet: return "结束房间";
  639. case DungeonRoomType.Boss: return "Boss房间";
  640. case DungeonRoomType.Reward: return "奖励房间";
  641. case DungeonRoomType.Shop: return "商店房间";
  642. case DungeonRoomType.Event: return "事件房间";
  643. }
  644.  
  645. return "战斗房间";
  646. }
  647. }