PlayerManager.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Excel2Json;
  4. using Fort23.UTool;
  5. using GameLogic.Bag;
  6. using GameLogic.Hero;
  7. using UnityEngine;
  8. using Utility;
  9. public class PlayerManager : Singleton<PlayerManager>
  10. {
  11. /// <summary>
  12. /// 英雄管理
  13. /// </summary>
  14. public HeroController heroController = new HeroController();
  15. public GameConstantConfig gameConstantConfig;
  16. public long coin;
  17. public long diamond;
  18. public long heroExp;
  19. /// <summary>
  20. /// 上一个强化的英雄
  21. /// </summary>
  22. public HeroInfo lastHeroInfo;
  23. public void Init()
  24. {
  25. gameConstantConfig = ConfigComponent.Instance.Get<GameConstantConfig>(1);
  26. AccountFileInfo.Instance.LoadPlayerData();
  27. InitGameData();
  28. }
  29. private void InitGameData()
  30. {
  31. InitBags();
  32. heroController.InitHeroes();
  33. // InitHeroes();
  34. }
  35. private void InitBags()
  36. {
  37. BagController.Instance.Init();
  38. }
  39. // public void InitTestHero()
  40. // {
  41. // heroListInLead.Clear();
  42. // // AccountFileInfo.Instance.LoadPlayerData();
  43. //
  44. // AccountFileInfo.HeroData heroData1 = new AccountFileInfo.HeroData
  45. // {
  46. // heroModelId = 105,
  47. // heroPowerId = 1,
  48. // heroPromoteId = 3
  49. // };
  50. //
  51. // AccountFileInfo.HeroData heroData2 = new AccountFileInfo.HeroData
  52. // {
  53. // heroModelId = 107,
  54. // heroPowerId = 1,
  55. // heroPromoteId = 3
  56. // };
  57. //
  58. // AccountFileInfo.HeroData heroData3 = new AccountFileInfo.HeroData
  59. // {
  60. // heroModelId = 116,
  61. // heroPowerId = 1,
  62. // heroPromoteId = 3
  63. // };
  64. // AccountFileInfo.HeroData heroData4 = new AccountFileInfo.HeroData
  65. // {
  66. // heroModelId = 113,
  67. // heroPowerId = 1,
  68. // heroPromoteId = 3
  69. // };
  70. // AccountFileInfo.Instance.playerData.HeroListData.Clear();
  71. // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData1);
  72. // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData2);
  73. // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData3);
  74. // AccountFileInfo.Instance.playerData.HeroListData.Add(heroData4);
  75. //
  76. // for (int i = 0; i < AccountFileInfo.Instance.playerData.HeroListData.Count; i++)
  77. // {
  78. // AccountFileInfo.HeroData heroData = AccountFileInfo.Instance.playerData.HeroListData[i];
  79. // HeroInfo heroInfo = new HeroInfo();
  80. // heroInfo.InitHero(heroData);
  81. // heroListInLead.Add(heroInfo);
  82. // }
  83. // }
  84. // public CombatHeroInfo GetHeroInfo(int modelID)
  85. // {
  86. // if (lastHeroInfo != null && lastHeroInfo.modelID == modelID)
  87. // {
  88. // return lastHeroInfo;
  89. // }
  90. //
  91. // for (int i = 0; i < heroListInLead.Count; i++)
  92. // {
  93. // HeroInfo info = heroListInLead[i];
  94. // if (info.modelID == modelID)
  95. // {
  96. // return info;
  97. // }
  98. // }
  99. //
  100. // return null;
  101. // }
  102. /// <summary>
  103. /// 保存英雄数据
  104. /// </summary>
  105. /// <param name="heroInfo"></param>
  106. public void SaveHeroData(HeroInfo heroInfo)
  107. {
  108. AccountFileInfo.Instance.SaveHeroData(heroInfo);
  109. // if (!QuickSaveHeroData(heroInfo))
  110. // {
  111. // for (int i = 0; i < AccountFileInfo.Instance.playerData.HeroListInLeadDatas.Count; i++)
  112. // {
  113. // AccountFileInfo.HeroData heroData = AccountFileInfo.Instance.playerData.HeroListInLeadDatas[i];
  114. // if (heroData.heroModelId == heroInfo.modelID)
  115. // {
  116. // AccountFileInfo.Instance.playerData.HeroListInLeadDatas[i] = heroInfo.ToHeroData();
  117. // //存下来,用于快速查找
  118. // leadHeroIdx = i;
  119. // AccountFileInfo.Instance.SavePlayerData();
  120. // return;
  121. // }
  122. // }
  123. // }
  124. }
  125. }