PlayerGuideDataComponent.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections.Generic;
  2. using Excel2Json;
  3. using Fort23.UTool;
  4. using Utility;
  5. namespace Mono.Player
  6. {
  7. public class PlayerGuideDataComponent
  8. {
  9. /// <summary>
  10. /// key 引导组 value 第几步
  11. /// </summary>
  12. public Map<int, int> AllGuideData = new Map<int, int>();
  13. public Map<int, List<int>> ALLGuideStepData = new Map<int, List<int>>();
  14. //
  15. // public void Init(RepeatedField<Guide> repeatedField)
  16. // {
  17. // foreach (var playerGuideConfig in ConfigComponent.Instance.GetAll<PlayerGuideConfig>())
  18. // {
  19. // if (!ALLGuideStepData.ContainsKey(playerGuideConfig.groupID))
  20. // {
  21. // List<int> list = new List<int>();
  22. // list.Add(playerGuideConfig.ID);
  23. // ALLGuideStepData.Add(playerGuideConfig.groupID, list);
  24. // }
  25. // else
  26. // {
  27. // ALLGuideStepData[playerGuideConfig.groupID].Add(playerGuideConfig.ID);
  28. // }
  29. // }
  30. //
  31. // for (var i = 0; i < repeatedField.Count; i++)
  32. // {
  33. // int index = ALLGuideStepData[repeatedField[i].GroupId].IndexOf(repeatedField[i].GuideId);
  34. // if (index == -1)
  35. // {
  36. // index = ALLGuideStepData[repeatedField[i].GroupId].Count - 1;
  37. // }
  38. //
  39. // AllGuideData.Add(repeatedField[i].GroupId, index);
  40. // }
  41. //
  42. // if (AllGuideData.Count == 0)
  43. // {
  44. // PlayerManager.Instance.curGuideGroupId = 0;
  45. // }
  46. // }
  47. /// <summary>
  48. /// 更新本地引导缓存
  49. /// </summary>
  50. /// <param name="id"></param>
  51. public void UpdateData(int id)
  52. {
  53. PlayerGuideConfig playerGuideConfig = ConfigComponent.Instance.Get<PlayerGuideConfig>(id);
  54. int index = ALLGuideStepData[playerGuideConfig.groupID].IndexOf(id);
  55. AllGuideData[playerGuideConfig.groupID] = index;
  56. }
  57. public int GetGuideIndex(int id)
  58. {
  59. if (AllGuideData.ContainsKey(id))
  60. {
  61. return AllGuideData[id];
  62. }
  63. return -1;
  64. }
  65. }
  66. }