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 Weapon = new RandomActivityBase()
  12. {
  13. Id = "$RandomGun",
  14. Name = "随机武器",
  15. Type = (int)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 Enemy = new RandomActivityBase()
  24. {
  25. Id = "$RandomEnemy",
  26. Name = "随机敌人",
  27. Type = (int)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 Prop = new RandomActivityBase()
  36. {
  37. Id = "$RandomProp",
  38. Name = "随机道具",
  39. Type = (int)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 =
  45. new Dictionary<ActivityType, List<ExcelConfig.ActivityBase>>();
  46.  
  47. private static bool _init = false;
  48. public static void Init()
  49. {
  50. if (_init)return;
  51. _init = true;
  52. foreach (var activityBase in ExcelConfig.ActivityBase_List)
  53. {
  54. var type = (ActivityType)activityBase.Type;
  55. if (!_cache.TryGetValue(type, out var list))
  56. {
  57. list = new List<ExcelConfig.ActivityBase>();
  58. _cache.Add(type, list);
  59. }
  60. list.Add(activityBase);
  61. }
  62. }
  63. /// <summary>
  64. /// 根据id获取标记配置, 该函数会自动匹配随机标记
  65. /// </summary>
  66. public static ExcelConfig.ActivityBase GetMarkConfig(string id)
  67. {
  68. if (Weapon.Id == id)
  69. {
  70. return Weapon;
  71. }
  72. else if (Enemy.Id == id)
  73. {
  74. return Enemy;
  75. }
  76. else if (Prop.Id == id)
  77. {
  78. return Prop;
  79. }
  80.  
  81. ExcelConfig.ActivityBase_Map.TryGetValue(id, out var activityBase);
  82. return activityBase;
  83. }
  84.  
  85. public static List<ExcelConfig.ActivityBase> GetMarkConfigsByType(ActivityType type)
  86. {
  87. if (!_cache.TryGetValue(type, out var arr))
  88. {
  89. arr = new List<ExcelConfig.ActivityBase>();
  90. _cache.Add(type, arr);
  91. }
  92. return arr;
  93. }
  94.  
  95. /// <summary>
  96. /// 获取特殊标记名称
  97. /// </summary>
  98. public static string GetSpecialName(SpecialMarkType type)
  99. {
  100. if (type == SpecialMarkType.BirthPoint)
  101. {
  102. return "出生标记";
  103. }
  104.  
  105. return string.Empty;
  106. }
  107. }