PlacesItem.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using UnityEngine;
  7. namespace Fort23.Mono
  8. {
  9. public class PlacesItem
  10. {
  11. public GameObjectPool gameObjectPool;
  12. public BigMapConfig bigMapConfig;
  13. private ReferenceCollector referenceCollector;
  14. public List<PlacesWidget> PlacesWidgets = new List<PlacesWidget>();
  15. public async CTask CustomInit(int bigMapId, GameObjectPool gameObjectPool, Action<ItemWidgetBasic> callBack = null)
  16. {
  17. this.gameObjectPool = gameObjectPool;
  18. bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(bigMapId);
  19. referenceCollector = gameObjectPool.own.GetComponent<ReferenceCollector>();
  20. for (var i = 0; i < bigMapConfig.places.Length; i++)
  21. {
  22. GameObject gam = referenceCollector.Get<GameObject>("places_" + bigMapConfig.places[i]);
  23. PlacesWidget placesWidget = await UIManager.Instance.CreateGComponentForObject<PlacesWidget>(gam, null);
  24. placesWidget.OnClick = callBack;
  25. placesWidget.CustomInit(bigMapConfig.places[i]);
  26. PlacesWidgets.Add(placesWidget);
  27. }
  28. }
  29. public void Dispose()
  30. {
  31. UIManager.Instance.DormancyGComponent(gameObjectPool);
  32. gameObjectPool = null;
  33. referenceCollector = null;
  34. PlacesWidgets.Clear();
  35. }
  36. }
  37. }