RoleDataManager.cs 11 KB

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