LeagueDataManager.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. namespace GFGGame
  5. {
  6. public class LeagueDataManager : SingletonBase<LeagueDataManager>
  7. {
  8. public int Type = 2;// 1:已经加入军团 2:未加入军团
  9. public int MaxFinishType { get { return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueSkillMaxType); } }
  10. public int MaxFinishLayer { get { return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueSkillMaxLayer); } }
  11. public LeagueData LeagueData;//联盟信息
  12. public int HallLevel { get { return (int)GetNumeriValue(LeagueNumericType.HallLevel); } }
  13. public int HotelLevel { get { return (int)GetNumeriValue(LeagueNumericType.HotelLevel); } }
  14. public int StoreLevel { get { return (int)GetNumeriValue(LeagueNumericType.StoreLevel); } }
  15. public Dictionary<int, long> LeagueNumber = new Dictionary<int, long>();//联盟数值,LeagueNumericType
  16. public Dictionary<long, LeagueListData> ListDatas = new Dictionary<long, LeagueListData>();//联盟列表
  17. public Dictionary<long, OtherRoleInfoData> ListApplyDatas = new Dictionary<long, OtherRoleInfoData>();//联盟申请列表
  18. public List<LeagueLogData> ListLogDatas = new List<LeagueLogData>();//日志数据
  19. public Dictionary<long, int> ListAnswerDatas = new Dictionary<long, int>();//答题数据
  20. public void Clear()
  21. {
  22. Type = 2;
  23. ListDatas.Clear();
  24. LeagueData = null;
  25. ListApplyDatas.Clear();
  26. ListLogDatas.Clear();
  27. }
  28. public void SetNumeric(int type, long value)
  29. {
  30. LeagueNumber[type] = value;
  31. }
  32. public long GetNumeriValue(int type)
  33. {
  34. if (LeagueNumber.TryGetValue(type, out long value))
  35. {
  36. return value;
  37. }
  38. return 0;
  39. }
  40. public string GetMemberTitle(int pos)
  41. {
  42. string title = "";
  43. switch (pos)
  44. {
  45. case LeaguePos.Owner:
  46. title = "社长";
  47. break;
  48. case LeaguePos.SubOwner:
  49. title = "副社长";
  50. break;
  51. case LeaguePos.Flower:
  52. title = "御史";
  53. break;
  54. case LeaguePos.Member:
  55. title = "成员";
  56. break;
  57. }
  58. return title;
  59. }
  60. public int GetMyPos()
  61. {
  62. if (LeagueDataManager.Instance.LeagueData.LeagueMemberDatas.TryGetValue(RoleDataManager.roleId, out LeagueMemberData memberData))
  63. {
  64. return memberData.Pos;
  65. }
  66. return LeaguePos.Member;
  67. }
  68. // //判断一个玩家是否是会长副会长
  69. // public bool CheckPlayerIsLeader()
  70. // {
  71. // }
  72. /// <summary>
  73. /// 根据祈福类型获取祈福次数
  74. /// </summary>
  75. /// <returns></returns>
  76. public int GetPrayTimesByType(int prayType)
  77. {
  78. int curCount = 0;
  79. switch (prayType)
  80. {
  81. case LeaguePrayType.First:
  82. curCount = RoleDataManager.LeagueType1PrayTimes;
  83. break;
  84. case LeaguePrayType.Second:
  85. curCount = RoleDataManager.LeagueType2PrayTimes;
  86. break;
  87. case LeaguePrayType.Third:
  88. curCount = RoleDataManager.LeagueType3PrayTimes;
  89. break;
  90. }
  91. return curCount;
  92. }
  93. public int GetAllSkillScore(int scoreType)
  94. {
  95. int score = 0;
  96. foreach (int key in SkillDataManager.Instance.LeagueSkillScoreDatas.Keys)
  97. {
  98. score += SkillDataManager.Instance.LeagueSkillScoreDatas[key][scoreType];
  99. }
  100. return score;
  101. }
  102. public int GetSkillScoreByType(int skillType, int scoreType)
  103. {
  104. int score = 0;
  105. if (!SkillDataManager.Instance.LeagueSkillScoreDatas.ContainsKey(skillType)) return score;
  106. return SkillDataManager.Instance.LeagueSkillScoreDatas[skillType][scoreType];
  107. }
  108. //检测一个技能是否激活
  109. public bool CheckIsSkillActive(int skillType, int skillId)
  110. {
  111. if (!SkillDataManager.Instance.LeagueSkillDatas.ContainsKey(skillType)) return false;
  112. return SkillDataManager.Instance.LeagueSkillDatas[skillType].IndexOf(skillId) >= 0;
  113. }
  114. //根据技能类型获取该类型进度
  115. public double GetSkillProgressByType(int skillType)
  116. {
  117. LeagueSkillCountCfg skillCountCfg = LeagueSkillCountCfgArray.Instance.GetCfg(skillType);
  118. // int maxFinishType = GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueSkillMaxType);
  119. if (skillCountCfg.type - MaxFinishType <= 0) return 100;
  120. if (skillCountCfg.type - MaxFinishType > 1) return 0;
  121. // int layer = GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueSkillMaxLayer);
  122. if (MaxFinishLayer == 0) return 0;
  123. List<LeagueSkillCfg> firstSkillCfgs = LeagueSkillCfgArray.Instance.GetCfgsBytypeAndlayer(skillType, 1);
  124. int startId = firstSkillCfgs[0].id;
  125. List<LeagueSkillCfg> curSkillCfgs = LeagueSkillCfgArray.Instance.GetCfgsBytypeAndlayer(skillType, MaxFinishLayer + 1);
  126. int curId = curSkillCfgs[0].id;
  127. for (int i = 0; i < curSkillCfgs.Count; i++)
  128. {
  129. if (SkillDataManager.Instance.LeagueSkillDatas[skillType].IndexOf(curSkillCfgs[i].id) < 0)
  130. {
  131. curId = curSkillCfgs[i].id;
  132. break;
  133. }
  134. }
  135. float count = curId - startId;
  136. float maxCount = skillCountCfg.skillCount;
  137. return Math.Round(count / maxCount * 100, 1); ;
  138. }
  139. }
  140. }