Newer
Older
DungeonShooting / DungeonShooting_Godot / src / framework / map / preinstall / PreinstallMarkManager.cs
  1.  
  2. using System.Collections.Generic;
  3. using Config;
  4.  
  5.  
  6. public static class PreinstallMarkManager
  7. {
  8. /// <summary>
  9. /// 随机武器
  10. /// </summary>
  11. public static readonly RandomActivityBase RandomWeapon = new RandomActivityBase()
  12. {
  13. Id = "$RandomGun",
  14. Name = "随机武器",
  15. Type = ActivityType.Other,
  16. Icon = ResourcePath.resource_sprite_ui_commonIcon_Dice_png,
  17. ShowInMapEditor = true
  18. };
  19.  
  20. /// <summary>
  21. /// 随机敌人
  22. /// </summary>
  23. public static readonly RandomActivityBase RandomEnemy = new RandomActivityBase()
  24. {
  25. Id = "$RandomEnemy",
  26. Name = "随机敌人",
  27. Type = ActivityType.Other,
  28. Icon = ResourcePath.resource_sprite_ui_commonIcon_Dice_png,
  29. ShowInMapEditor = true
  30. };
  31.  
  32. /// <summary>
  33. /// 随机道具
  34. /// </summary>
  35. public static readonly RandomActivityBase RandomProp = new RandomActivityBase()
  36. {
  37. Id = "$RandomProp",
  38. Name = "随机道具",
  39. Type = ActivityType.Other,
  40. Icon = ResourcePath.resource_sprite_ui_commonIcon_Dice_png,
  41. ShowInMapEditor = true
  42. };
  43.  
  44. private static Dictionary<ActivityType, List<ExcelConfig.ActivityBase>> _cache = new Dictionary<ActivityType, List<ExcelConfig.ActivityBase>>();
  45.  
  46. private static bool _init = false;
  47. public static void Init()
  48. {
  49. if (_init)return;
  50. _init = true;
  51. foreach (var activityBase in ExcelConfig.ActivityBase_List)
  52. {
  53. var type = (ActivityType)activityBase.Type;
  54. if (!_cache.TryGetValue(type, out var list))
  55. {
  56. list = new List<ExcelConfig.ActivityBase>();
  57. _cache.Add(type, list);
  58. }
  59. list.Add(activityBase);
  60. }
  61. }
  62. /// <summary>
  63. /// 根据id获取标记配置, 该函数会自动匹配随机标记
  64. /// </summary>
  65. public static ExcelConfig.ActivityBase GetMarkConfig(string id)
  66. {
  67. if (RandomWeapon.Id == id)
  68. {
  69. return RandomWeapon;
  70. }
  71. else if (RandomEnemy.Id == id)
  72. {
  73. return RandomEnemy;
  74. }
  75. else if (RandomProp.Id == id)
  76. {
  77. return RandomProp;
  78. }
  79.  
  80. ExcelConfig.ActivityBase_Map.TryGetValue(id, out var activityBase);
  81. return activityBase;
  82. }
  83.  
  84. public static List<ExcelConfig.ActivityBase> GetMarkConfigsByType(ActivityType type)
  85. {
  86. if (!_cache.TryGetValue(type, out var arr))
  87. {
  88. arr = new List<ExcelConfig.ActivityBase>();
  89. _cache.Add(type, arr);
  90. }
  91. return arr;
  92. }
  93.  
  94. /// <summary>
  95. /// 获取特殊标记名称
  96. /// </summary>
  97. public static string GetSpecialName(SpecialMarkType type)
  98. {
  99. if (type == SpecialMarkType.BirthPoint)
  100. {
  101. return "出生标记";
  102. }
  103. else if (type == SpecialMarkType.OutPoint)
  104. {
  105. return "出口标记";
  106. }
  107.  
  108. return string.Empty;
  109. }
  110. }