TravelDataManager.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class TravelDataManager : SingletonBase<TravelDataManager>
  9. {
  10. public TravelData TravelData { get; set; }
  11. public List<int> ListTravelLocationCount = new List<int>();//下标对应TravelLoactionCfg表格id
  12. public List<int> ListTravelAreaRewardState = new List<int>();//下标对应TravelGuide表格id
  13. public void Clear()
  14. {
  15. TravelData = null;
  16. ListTravelLocationCount.Clear();
  17. ListTravelAreaRewardState.Clear();
  18. }
  19. public int GetTravelIndexByLocationId(int locationId)
  20. {
  21. for (int i = 0; i < CommonDataManager.Tables.TblTravelLoactionCfg.DataList.Count; i++)
  22. {
  23. if (CommonDataManager.Tables.TblTravelLoactionCfg.DataList[i].Id == locationId)
  24. {
  25. return i;
  26. }
  27. }
  28. return -1;
  29. }
  30. public int GetTravelCountByLocationId(int locationId)
  31. {
  32. if (ListTravelLocationCount.Count == 0) return 0;
  33. int index = GetTravelIndexByLocationId(locationId);
  34. return ListTravelLocationCount[index];
  35. }
  36. public int GetGuideIndexByAreaId(int areaId)
  37. {
  38. for (int i = 0; i < CommonDataManager.Tables.TblTravelGuideCfg.DataList.Count ; i++)
  39. {
  40. if (CommonDataManager.Tables.TblTravelGuideCfg.DataList[i].Id == areaId)
  41. {
  42. return i;
  43. }
  44. }
  45. return -1;
  46. }
  47. public int GetGuideRewardStateByAreaId(int areaId)
  48. {
  49. if (ListTravelAreaRewardState.Count == 0) return ConstBonusStatus.CAN_NOT_GET;
  50. int index = GetGuideIndexByAreaId(areaId);
  51. return TravelDataManager.Instance.ListTravelAreaRewardState[index];
  52. }
  53. public void GetTotalTravelProgress(out int count, out int totalCount)
  54. {
  55. totalCount = 1;
  56. count = 0;
  57. if (ListTravelLocationCount == null) return;
  58. for (int i = 0; i < ListTravelLocationCount.Count; i++)
  59. {
  60. if (ListTravelLocationCount[i] > 0)
  61. {
  62. count++;
  63. }
  64. }
  65. totalCount = ListTravelLocationCount.Count;
  66. }
  67. }
  68. }