Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / room / World.cs
  1. using System.Collections.Generic;
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 游戏世界
  6. /// </summary>
  7. public partial class World : Node2D
  8. {
  9. /// <summary>
  10. /// //对象根节点
  11. /// </summary>
  12. [Export] public Node2D NormalLayer;
  13. /// <summary>
  14. /// 对象根节点, 带y轴排序功能
  15. /// </summary>
  16. [Export] public Node2D YSortLayer;
  17. /// <summary>
  18. /// 地图根节点
  19. /// </summary>
  20. [Export] public TileMap TileRoot;
  21.  
  22. [Export] public Node2D StaticSpriteRoot;
  23. [Export] public Node2D AffiliationAreaRoot;
  24. /// <summary>
  25. /// 是否暂停
  26. /// </summary>
  27. public bool Pause
  28. {
  29. get => _pause;
  30. set
  31. {
  32. if (_pause != value)
  33. {
  34. _pause = value;
  35. if (value)
  36. {
  37. ProcessMode = ProcessModeEnum.WhenPaused;
  38. }
  39. else
  40. {
  41. ProcessMode = ProcessModeEnum.Inherit;
  42. }
  43. }
  44. }
  45. }
  46. /// <summary>
  47. /// 所有被扔在地上的武器
  48. /// </summary>
  49. public HashSet<Weapon> Weapon_UnclaimedWeapons { get; } = new HashSet<Weapon>();
  50. /// <summary>
  51. /// 记录所有存活的敌人
  52. /// </summary>
  53. public List<Enemy> Enemy_InstanceList { get; } = new List<Enemy>();
  54. /// <summary>
  55. /// 公共属性, 敌人是否找到目标, 如果找到目标, 则与目标同房间的所有敌人都会知道目标的位置
  56. /// </summary>
  57. public bool Enemy_IsFindTarget { get; set; }
  58.  
  59. /// <summary>
  60. /// 公共属性, 敌人在哪个区域找到的目标, 所有该区域下的敌人都会知道目标的位置
  61. /// </summary>
  62. public HashSet<AffiliationArea> Enemy_FindTargetAffiliationSet { get; } = new HashSet<AffiliationArea>();
  63. /// <summary>
  64. /// 公共属性, 敌人找到的目标的位置, 如果目标在视野内, 则一直更新
  65. /// </summary>
  66. public Vector2 Enemy_FindTargetPosition { get; set; }
  67. private bool _pause = false;
  68. public override void _Ready()
  69. {
  70. TileRoot.YSortEnabled = false;
  71. }
  72.  
  73. /// <summary>
  74. /// 获取指定层级根节点
  75. /// </summary>
  76. public Node2D GetRoomLayer(RoomLayerEnum layerEnum)
  77. {
  78. switch (layerEnum)
  79. {
  80. case RoomLayerEnum.NormalLayer:
  81. return NormalLayer;
  82. case RoomLayerEnum.YSortLayer:
  83. return YSortLayer;
  84. }
  85.  
  86. return null;
  87. }
  88. }