RoleDataManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. if(GameGlobal.myNumericComponent != null)
  116. {
  117. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  118. }
  119. return 1;
  120. }
  121. }
  122. public static long diaP
  123. {
  124. get
  125. {
  126. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_PURPLE); // GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondP);
  127. }
  128. }
  129. public static long diaR
  130. {
  131. get
  132. {
  133. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_RED); //GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondR);
  134. }
  135. }
  136. public static int vipLv
  137. {
  138. get
  139. {
  140. if(GameGlobal.myNumericComponent != null)
  141. {
  142. return GameGlobal.myNumericComponent.GetAsInt(NumericType.VipLevel);
  143. }
  144. return 0;
  145. }
  146. }
  147. public static int vipExp
  148. {
  149. get
  150. {
  151. return GameGlobal.myNumericComponent.GetAsInt(NumericType.VipExp);
  152. }
  153. }
  154. public static int DailyLiveness
  155. {
  156. get
  157. {
  158. return GameGlobal.myNumericComponent.GetAsInt(NumericType.DailyLiveness);
  159. }
  160. }
  161. public static int WeeklyLiveness
  162. {
  163. get
  164. {
  165. return GameGlobal.myNumericComponent.GetAsInt(NumericType.WeeklyLiveness);
  166. }
  167. }
  168. /// <summary>
  169. /// 今日竞技场可挑战次数
  170. /// </summary>
  171. /// <value></value>
  172. public static int ArenaFightTimes
  173. {
  174. get
  175. {
  176. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaFightTimes);
  177. }
  178. }
  179. /// <summary>
  180. /// 玩家竞技场最大挑战存储量
  181. /// </summary>
  182. /// <value></value>
  183. public static int ArenaMaxStorageNum
  184. {
  185. get
  186. {
  187. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaMaxStorageNum);
  188. }
  189. }
  190. /// <summary>
  191. /// 今日竞技场可购买挑战的次数
  192. /// </summary>
  193. /// <value></value>
  194. public static int ArenaBuyFightTimes
  195. {
  196. get
  197. {
  198. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaBuyFightTimes);
  199. }
  200. }
  201. /// <summary>
  202. /// 今日竞技场可刷新次数
  203. /// </summary>
  204. /// <value></value>
  205. public static int ArenaFreshTimes
  206. {
  207. get
  208. {
  209. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaFreshTimes);
  210. }
  211. }
  212. /// <summary>
  213. /// 今日竞技场可获取特殊奖励的次数
  214. /// </summary>
  215. /// <value></value>
  216. public static int ArenaTimesBonusSpecial
  217. {
  218. get
  219. {
  220. return GameGlobal.myNumericComponent.GetAsInt(NumericType.ArenaTimesBonusSpecial);
  221. }
  222. }
  223. /// <summary>
  224. ///类型一今日祈福次数
  225. /// </summary>
  226. /// <value></value>
  227. public static int LeagueType1PrayTimes
  228. {
  229. get
  230. {
  231. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType1PrayTimes);
  232. }
  233. }
  234. /// <summary>
  235. ///类型二今日祈福次数
  236. /// </summary>
  237. /// <value></value>
  238. public static int LeagueType2PrayTimes
  239. {
  240. get
  241. {
  242. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType2PrayTimes);
  243. }
  244. }
  245. /// <summary>
  246. ///类型三今日祈福次数
  247. /// </summary>
  248. /// <value></value>
  249. public static int LeagueType3PrayTimes
  250. {
  251. get
  252. {
  253. return GameGlobal.myNumericComponent.GetAsInt(NumericType.LeagueType3PrayTimes);
  254. }
  255. }
  256. /// <summary>
  257. /// 万水千山最大存储量
  258. /// </summary>
  259. public static int WanShuiQianShanMaxStorageCount
  260. {
  261. get { return GameGlobal.myNumericComponent.GetAsInt(NumericType.WanShuiQianShanMaxStorageCount); }
  262. }
  263. public static bool CheckPowerFull()
  264. {
  265. return RoleDataManager.power >= powerLimit;
  266. }
  267. public static void InitServerData()
  268. {
  269. roleId = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().CurrentRoleId;
  270. }
  271. /// <summary>
  272. /// 检测是否开通指定类型月卡
  273. /// </summary>
  274. /// <returns></returns>
  275. public static bool CheckIsMonthCardOpenByType(int monthCardType)
  276. {
  277. if (monthCardType == MonthCardType.Gold)
  278. {
  279. return TimeHelper.ServerNow() < GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardGoldEndTime);
  280. }
  281. else if (monthCardType == MonthCardType.BlackGold)
  282. {
  283. return TimeHelper.ServerNow() < GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime);
  284. }
  285. return true;
  286. }
  287. public static OtherRoleInfoData GetOtherRoleInfoData(OtherRoleInfoProto otherRoleInfo)
  288. {
  289. OtherRoleInfoData otherRoleInfoData = new OtherRoleInfoData();
  290. otherRoleInfoData.roleId = otherRoleInfo.RoleId;
  291. otherRoleInfoData.headId = otherRoleInfo.HeadItemId;
  292. otherRoleInfoData.headBorderId = otherRoleInfo.HeadBorderItemId;
  293. otherRoleInfoData.roleName = otherRoleInfo.RoleName;
  294. otherRoleInfoData.roleLv = otherRoleInfo.RoleLvl;
  295. otherRoleInfoData.offlineTimeSec = otherRoleInfo.OfflineTimeSec;
  296. return otherRoleInfoData;
  297. }
  298. public static OtherRoleInfoData GetMineRoleInfoData()
  299. {
  300. OtherRoleInfoData otherRoleInfoData = new OtherRoleInfoData();
  301. otherRoleInfoData.roleId = roleId;
  302. otherRoleInfoData.headId = headId;
  303. otherRoleInfoData.headBorderId = headBorderId;
  304. otherRoleInfoData.roleName = roleName;
  305. otherRoleInfoData.roleLv = lvl;
  306. return otherRoleInfoData;
  307. }
  308. private static int oldLvValue;
  309. public static void RoleLvUp(int oldValue)
  310. {
  311. oldLvValue = oldValue;
  312. Timers.inst.Remove(CheckUpLv);
  313. Timers.inst.Remove(OpenRoleLvUpView);
  314. Timers.inst.Add(0.2f, 0, CheckUpLv);
  315. CheckUpLv(null);
  316. }
  317. private static void CheckUpLv(object param)
  318. {
  319. if (GuideDataManager.currentGuideId > 0) return;//在新手引导中不弹
  320. if (ViewManager.isViewOpen(typeof(FunctionOpenView).Name)) return;//等功能开启展示完成后再展示角色升级
  321. if (ViewManager.isViewOpen(typeof(StoryFightSingleScoreView).Name)) return;//战斗界面关闭前不弹升级
  322. if (InstanceZonesDataManager.isQuicklyFighting == true) return;//速刷中不弹
  323. if (InstanceZonesDataManager.isResultFighting == true) return;//结算中经验进度结束前不弹
  324. OpenRoleLvUpView(null);
  325. }
  326. private static void OpenRoleLvUpView(object param)
  327. {
  328. ViewManager.Show<RoleLvUpView>(oldLvValue);
  329. Timers.inst.Remove(CheckUpLv);
  330. }
  331. public static bool HaveBadge(int id)
  332. {
  333. return ItemDataManager.GetItemNum(id) > 0;
  334. }
  335. public static string GetMainBgRes()
  336. {
  337. // 如果主界面ID大于最大物品ID,说明是主界面专属背景
  338. if(mainBgID > ConstItemID.MAX_ITEM_ID)
  339. {
  340. return ResPathUtil.GetBgImgPath(MainBackgroundCfgArray.Instance.GetCfg(mainBgID).res);
  341. }
  342. // 换装背景
  343. else
  344. {
  345. return ResPathUtil.GetSceneBgPath(ItemCfgArray.Instance.GetCfg(mainBgID).res);
  346. }
  347. }
  348. /// <summary>
  349. /// 检查是否应该保存换装背景到主界面背景
  350. /// </summary>
  351. /// <param name="dressUpBgID"></param>
  352. public static void CheckSaveDressUpBgToMainBg(int dressUpBgID)
  353. {
  354. bool canChange =
  355. GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardGoldEndTime) > TimeHelper.ServerNow()
  356. || GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime) > TimeHelper.ServerNow();
  357. if (canChange && saveDressUpBgToMainBg == 1)
  358. {
  359. SaveMainBgID(dressUpBgID);
  360. }
  361. }
  362. public static void SaveMainBgID(int bgID)
  363. {
  364. mainBgID = bgID;
  365. RoleInfoSProxy.ReqSaveMainBgID(bgID);
  366. }
  367. public static void UpdatePhotoData()
  368. {
  369. List<long> numArr = new List<long>();
  370. // 提取有数据的位置
  371. for (int i = 0; i < RoleDataManager.photoDatas.Count; i++)
  372. {
  373. if (RoleDataManager.photoDatas[i] > 0)
  374. {
  375. numArr.Add(RoleDataManager.photoDatas[i]);
  376. }
  377. }
  378. // 找到可用空位赋值
  379. int index = 0;
  380. for (int i = 0; i < photoDatas.Count; i++)
  381. {
  382. if (RoleInfoManager.GetPosType(i) == MonthCardType.Gold && !CheckIsMonthCardOpenByType(MonthCardType.Gold)
  383. || RoleInfoManager.GetPosType(i) == MonthCardType.BlackGold && !CheckIsMonthCardOpenByType(MonthCardType.BlackGold))
  384. {
  385. photoDatas[i] = -1;
  386. continue;
  387. }
  388. if (index < numArr.Count)
  389. {
  390. photoDatas[i] = numArr[index++];
  391. }
  392. else
  393. {
  394. photoDatas[i] = 0;
  395. }
  396. }
  397. }
  398. }
  399. }