ObjectManagerAdon.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Adon.Game.Manager
  5. {
  6. /// <summary>
  7. /// 游戏对象管理器
  8. /// </summary>
  9. public class ObjectManagerAdon : MonoBehaviour
  10. {
  11. public static HeroPlayerController Hero;
  12. /// <summary>
  13. /// 已激活英雄列表
  14. /// </summary>
  15. private static List<GameObject> m_Heros = new List<GameObject>();
  16. /// <summary>
  17. /// 怪物列表
  18. /// </summary>
  19. private static List<GameObject> m_Monsters = new List<GameObject>();
  20. /// <summary>
  21. /// 全部已激活对象
  22. /// </summary>
  23. private static Dictionary<string, GameObject> m_Objects = new Dictionary<string, GameObject>();
  24. /// <summary>
  25. /// 添加英雄对象
  26. /// </summary>
  27. /// <param name="name"></param>
  28. /// <param name="obj"></param>
  29. public static void AddHeroObject(string name, GameObject obj)
  30. {
  31. m_Heros.Remove(obj);
  32. m_Heros.Add(obj);
  33. m_Objects.Remove(name);
  34. m_Objects.Add(name, obj);
  35. Hero = obj.GetComponent<HeroPlayerController>();
  36. }
  37. /// <summary>
  38. /// 添加怪物对象
  39. /// </summary>
  40. /// <param name="name"></param>
  41. /// <param name="obj"></param>
  42. public static void AddMobObject(string name, GameObject obj)
  43. {
  44. m_Monsters.Remove(obj);
  45. m_Monsters.Add(obj);
  46. m_Objects.Remove(name);
  47. m_Objects.Add(name, obj);
  48. }
  49. /// <summary>
  50. /// 回收怪物
  51. /// </summary>
  52. /// <param name="id"></param>
  53. /// <param name="pbObj"></param>
  54. /// <param name="bObjMon"></param>
  55. public static void RemoveMonster(string name, GameObject pbObj)
  56. {
  57. m_Objects.Remove(name);
  58. if (m_Monsters.Exists(x => x == pbObj))
  59. {
  60. m_Monsters.Remove(pbObj);
  61. }
  62. }
  63. public static List<GameObject> GetMonsters()
  64. {
  65. return m_Monsters;
  66. }
  67. }
  68. }