RoleDataManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. using FairyGUI;
  2. using ET;
  3. using System.Collections.Generic;
  4. namespace GFGGame
  5. {
  6. public class RoleDataManager
  7. {
  8. public static bool powerTimeServerLock;
  9. public static long roleId;
  10. public static string roleName
  11. {
  12. get
  13. {
  14. return GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRoleName();
  15. }
  16. }
  17. public static int rechargeTotalMon
  18. {
  19. get
  20. {
  21. return GameGlobal.myNumericComponent.GetAsInt(NumericType.RechargeTotaMonthly);
  22. }
  23. }
  24. public static string slogan = "";
  25. public static int headId = ConstItemID.HEADID;
  26. public static int headBorderId = ConstItemID.BORDERID;
  27. private static List<long> _photoDatas = new List<long>();
  28. public static List<long> photoDatas
  29. {
  30. get
  31. {
  32. return _photoDatas;
  33. }
  34. set
  35. {
  36. _photoDatas = value;
  37. }
  38. }
  39. // 佩戴徽章列表
  40. private static List<int> _badgeDatas = new List<int>();
  41. public static List<int> badgeDatas
  42. {
  43. get
  44. {
  45. return _badgeDatas;
  46. }
  47. set
  48. {
  49. _badgeDatas = value;
  50. }
  51. }
  52. private static int _mainBgID = MainBackgroundCfgArray.Instance.dataArray[0].id;
  53. public static int mainBgID
  54. {
  55. get
  56. {
  57. return _mainBgID;
  58. }
  59. set
  60. {
  61. _mainBgID = value;
  62. }
  63. }
  64. public static int saveDressUpBgToMainBg
  65. {
  66. get
  67. {
  68. return GameGlobal.myNumericComponent.GetAsInt(NumericType.IsOpenChangeGearBg);
  69. }
  70. }
  71. private static int _achievementTaskCollect;
  72. public static int achievementTaskCollect
  73. {
  74. get
  75. {
  76. return _achievementTaskCollect;
  77. }
  78. set
  79. {
  80. _achievementTaskCollect = value;
  81. }
  82. }
  83. public static int power
  84. {
  85. get
  86. {
  87. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Power);
  88. }
  89. }
  90. public static int powerLimit
  91. {
  92. get
  93. {
  94. return GameGlobal.myNumericComponent.GetAsInt(NumericType.PowerLimit) + GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardPowerLimitAdd);
  95. }
  96. }
  97. public static long gold
  98. {
  99. get
  100. {
  101. return ItemDataManager.GetItemNum(ConstItemID.GOLD); //GameGlobal.myNumericComponent.GetAsInt(NumericType.Gold);
  102. }
  103. }
  104. public static int exp
  105. {
  106. get
  107. {
  108. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  109. }
  110. }
  111. public static int lvl
  112. {
  113. get
  114. {
  115. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  116. }
  117. }
  118. public static long diaP
  119. {
  120. get
  121. {
  122. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_PURPLE); // GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondP);
  123. }
  124. }
  125. public static long diaR
  126. {
  127. get
  128. {
  129. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_RED); //GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondR);
  130. }
  131. }
  132. public static int vipLv
  133. {
  134. get
  135. {
  136. return GameGlobal.myNumericComponent.GetAsInt(NumericType.VipLevel);
  137. }
  138. }
  139. public static int vipExp
  140. {
  141. get
  142. {
  143. return GameGlobal.myNumericComponent.GetAsInt(NumericType.VipExp);
  144. }
  145. }
  146. public static int DailyLiveness
  147. {
  148. get
  149. {
  150. return GameGlobal.myNumericComponent.GetAsInt(NumericType.DailyLiveness);
  151. }
  152. }
  153. public static int WeeklyLiveness
  154. {
  155. get
  156. {
  157. return GameGlobal.myNumericComponent.GetAsInt(NumericType.WeeklyLiveness);
  158. }
  159. }
  160. /// <summary>
  161. /// 今日竞技场可挑战次数
  162. /// </summary>
  163. /// <value></value>
  164. public static int ArenaFightTimes
  165. {
  166. get
  167. {
  168. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaFightTimes);
  169. }
  170. }
  171. /// <summary>
  172. /// 玩家竞技场最大挑战存储量
  173. /// </summary>
  174. /// <value></value>
  175. public static int ArenaMaxStorageNum
  176. {
  177. get
  178. {
  179. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaMaxStorageNum);
  180. }
  181. }
  182. /// <summary>
  183. /// 今日竞技场可购买挑战的次数
  184. /// </summary>
  185. /// <value></value>
  186. public static int ArenaBuyFightTimes
  187. {
  188. get
  189. {
  190. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaBuyFightTimes);
  191. }
  192. }
  193. /// <summary>
  194. /// 今日竞技场可刷新次数
  195. /// </summary>
  196. /// <value></value>
  197. public static int ArenaFreshTimes
  198. {
  199. get
  200. {
  201. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaFreshTimes);
  202. }
  203. }
  204. /// <summary>
  205. /// 今日竞技场可获取特殊奖励的次数
  206. /// </summary>
  207. /// <value></value>
  208. public static int ArenaTimesBonusSpecial
  209. {
  210. get
  211. {
  212. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaTimesBonusSpecial);
  213. }
  214. }
  215. /// <summary>
  216. ///类型一今日祈福次数
  217. /// </summary>
  218. /// <value></value>
  219. public static int LeagueType1PrayTimes
  220. {
  221. get
  222. {
  223. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType1PrayTimes);
  224. }
  225. }
  226. /// <summary>
  227. ///类型二今日祈福次数
  228. /// </summary>
  229. /// <value></value>
  230. public static int LeagueType2PrayTimes
  231. {
  232. get
  233. {
  234. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType2PrayTimes);
  235. }
  236. }
  237. /// <summary>
  238. ///类型三今日祈福次数
  239. /// </summary>
  240. /// <value></value>
  241. public static int LeagueType3PrayTimes
  242. {
  243. get
  244. {
  245. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType3PrayTimes);
  246. }
  247. }
  248. /// <summary>
  249. /// 万水千山最大存储量
  250. /// </summary>
  251. public static int WanShuiQianShanMaxStorageCount
  252. {
  253. get { return GameGlobal.myNumericComponent.GetAsInt(NumericType.WanShuiQianShanMaxStorageCount); }
  254. }
  255. public static bool CheckPowerFull()
  256. {
  257. return RoleDataManager.power >= powerLimit;
  258. }
  259. public static void InitServerData()
  260. {
  261. roleId = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().CurrentRoleId;
  262. }
  263. /// <summary>
  264. /// 检测是否开通指定类型月卡
  265. /// </summary>
  266. /// <returns></returns>
  267. public static bool CheckIsMonthCardOpenByType(int monthCardType)
  268. {
  269. if (monthCardType == MonthCardType.Gold)
  270. {
  271. return TimeHelper.ServerNow() < GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardGoldEndTime);
  272. }
  273. else if (monthCardType == MonthCardType.BlackGold)
  274. {
  275. return TimeHelper.ServerNow() < GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime);
  276. }
  277. return true;
  278. }
  279. public static OtherRoleInfoData GetOtherRoleInfoData(OtherRoleInfoProto otherRoleInfo)
  280. {
  281. OtherRoleInfoData otherRoleInfoData = new OtherRoleInfoData();
  282. otherRoleInfoData.roleId = otherRoleInfo.RoleId;
  283. otherRoleInfoData.headId = otherRoleInfo.HeadItemId;
  284. otherRoleInfoData.headBorderId = otherRoleInfo.HeadBorderItemId;
  285. otherRoleInfoData.roleName = otherRoleInfo.RoleName;
  286. otherRoleInfoData.roleLv = otherRoleInfo.RoleLvl;
  287. otherRoleInfoData.offlineTimeSec = otherRoleInfo.OfflineTimeSec;
  288. return otherRoleInfoData;
  289. }
  290. public static OtherRoleInfoData GetMineRoleInfoData()
  291. {
  292. OtherRoleInfoData otherRoleInfoData = new OtherRoleInfoData();
  293. otherRoleInfoData.roleId = roleId;
  294. otherRoleInfoData.headId = headId;
  295. otherRoleInfoData.headBorderId = headBorderId;
  296. otherRoleInfoData.roleName = roleName;
  297. otherRoleInfoData.roleLv = lvl;
  298. return otherRoleInfoData;
  299. }
  300. private static int oldLvValue;
  301. public static void RoleLvUp(int oldValue)
  302. {
  303. oldLvValue = oldValue;
  304. Timers.inst.Remove(CheckUpLv);
  305. Timers.inst.Remove(OpenRoleLvUpView);
  306. Timers.inst.Add(0.2f, 0, CheckUpLv);
  307. CheckUpLv(null);
  308. }
  309. private static void CheckUpLv(object param)
  310. {
  311. if (GuideDataManager.currentGuideId > 0) return;//在新手引导中不弹
  312. if (ViewManager.isViewOpen(typeof(FunctionOpenView).Name)) return;//等功能开启展示完成后再展示角色升级
  313. if (ViewManager.isViewOpen(typeof(StoryFightSingleScoreView).Name)) return;//战斗界面关闭前不弹升级
  314. if (InstanceZonesDataManager.isQuicklyFighting == true) return;//速刷中不弹
  315. if (InstanceZonesDataManager.isResultFighting == true) return;//结算中经验进度结束前不弹
  316. OpenRoleLvUpView(null);
  317. }
  318. private static void OpenRoleLvUpView(object param)
  319. {
  320. ViewManager.Show<RoleLvUpView>(oldLvValue);
  321. Timers.inst.Remove(CheckUpLv);
  322. }
  323. public static bool HaveBadge(int id)
  324. {
  325. return ItemDataManager.GetItemNum(id) > 0;
  326. }
  327. public static string GetMainBgRes()
  328. {
  329. // 如果主界面ID大于最大物品ID,说明是主界面专属背景
  330. if(mainBgID > ConstItemID.MAX_ITEM_ID)
  331. {
  332. return ResPathUtil.GetBgImgPath(MainBackgroundCfgArray.Instance.GetCfg(mainBgID).res);
  333. }
  334. // 换装背景
  335. else
  336. {
  337. return ResPathUtil.GetSceneBgPath(ItemCfgArray.Instance.GetCfg(mainBgID).res);
  338. }
  339. }
  340. /// <summary>
  341. /// 检查是否应该保存换装背景到主界面背景
  342. /// </summary>
  343. /// <param name="dressUpBgID"></param>
  344. public static void CheckSaveDressUpBgToMainBg(int dressUpBgID)
  345. {
  346. // 小月卡
  347. float endTime = GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardGoldEndTime);
  348. if (endTime > TimeHelper.ServerNow() && saveDressUpBgToMainBg == 1)
  349. {
  350. SaveMainBgID(dressUpBgID);
  351. }
  352. }
  353. public static void SaveMainBgID(int bgID)
  354. {
  355. mainBgID = bgID;
  356. RoleInfoSProxy.ReqSaveMainBgID(bgID);
  357. }
  358. }
  359. }