RoleDataManager.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using UnityEngine;
  3. using FairyGUI;
  4. using ET;
  5. using System.Collections.Generic;
  6. namespace GFGGame
  7. {
  8. public class RoleDataManager
  9. {
  10. public static bool powerTimeServerLock;
  11. public static long roleId;
  12. public static string roleName;
  13. public static int rechargeTotal;
  14. public static int rechargeTotalMon;
  15. public static int power
  16. {
  17. get
  18. {
  19. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Power);
  20. }
  21. }
  22. public static int gold
  23. {
  24. get
  25. {
  26. return ItemDataManager.GetItemNum(ConstItemID.GOLD); //GameGlobal.myNumericComponent.GetAsInt(NumericType.Gold);
  27. }
  28. }
  29. private static int _exp = 0;
  30. public static int exp
  31. {
  32. get
  33. {
  34. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  35. }
  36. }
  37. public static int lvl
  38. {
  39. get
  40. {
  41. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  42. }
  43. }
  44. public static int diaP
  45. {
  46. get
  47. {
  48. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_PURPLE); // GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondP);
  49. }
  50. }
  51. public static int diaR
  52. {
  53. get
  54. {
  55. return ItemDataManager.GetItemNum(ConstItemID.DIAMOND_RED); //GameGlobal.myNumericComponent.GetAsInt(NumericType.DiamondR);
  56. }
  57. }
  58. public static int Liveness
  59. {
  60. get
  61. {
  62. return GameGlobal.myNumericComponent.GetAsInt(NumericType.Liveness);
  63. }
  64. }
  65. private static string _lastRandomName = null;
  66. public static string RandomRoleName()
  67. {
  68. string randomName = null;
  69. while (_lastRandomName == randomName || randomName == null)
  70. {
  71. int len = GameConst.ROLE_NAME_LIST.Length;
  72. System.Random random = new System.Random();
  73. int i = random.Next(len);
  74. randomName = GameConst.ROLE_NAME_LIST[i];
  75. }
  76. _lastRandomName = randomName;
  77. return randomName;
  78. }
  79. public static bool CheckPowerFull()
  80. {
  81. return RoleDataManager.power >= GameGlobal.myNumericComponent.GetAsInt(NumericType.PowerLimit);
  82. }
  83. public static void InitServerData()
  84. {
  85. roleName = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRoleName();
  86. }
  87. private static int oldLvValue;
  88. public static void RoleLvUp(int oldValue)
  89. {
  90. oldLvValue = oldValue;
  91. Timers.inst.Remove(CheckUpLv);
  92. Timers.inst.Remove(OpenRoleLvUpView);
  93. Timers.inst.Add(1, 0, CheckUpLv);
  94. }
  95. private static void CheckUpLv(object param)
  96. {
  97. if (GuideDataManager.currentGuideId > 0) return;
  98. if (ViewManager.isViewOpen(typeof(FunctionOpenView).Name)) return;//等功能开启展示完成后在展示角色升级
  99. // if (ViewManager.isViewOpen(typeof(GuideView).Name)) return;
  100. if (GRoot.inst.GetTopWindow() == null)
  101. {
  102. OpenRoleLvUpView(null);
  103. Timers.inst.Remove(CheckUpLv);
  104. // roleLastLv = lvl;
  105. }
  106. if (ViewManager.isViewOpen(typeof(StroyFightResultView).Name))
  107. {
  108. Timers.inst.Add(0.2f, 1, OpenRoleLvUpView);
  109. }
  110. }
  111. private static void OpenRoleLvUpView(object param)
  112. {
  113. ViewManager.Show<RoleLvUpView>(oldLvValue);
  114. Timers.inst.Remove(CheckUpLv);
  115. }
  116. }
  117. }