GameDateManager.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 游戏数据管理
  6. /// </summary>
  7. public class GameDateManager
  8. {
  9. // <summary>
  10. /// 单键
  11. /// </summary>
  12. private static GameDateManager m_Instance;
  13. /// <summary>
  14. /// 单键
  15. /// </summary>
  16. public static GameDateManager Instance
  17. {
  18. get
  19. {
  20. if (m_Instance == null)
  21. {
  22. m_Instance = new GameDateManager();
  23. }
  24. return m_Instance;
  25. }
  26. }
  27. /// <summary>
  28. /// 游戏开始时间
  29. /// </summary>
  30. private float _gameStartTime = 0;
  31. /// <summary>
  32. /// 游戏时间
  33. /// </summary>
  34. public void SetGameTime(float runTime)
  35. {
  36. _gameStartTime = runTime;
  37. }
  38. /// <summary>
  39. /// 获取游戏时间
  40. /// </summary>
  41. /// <returns></returns>
  42. public float GetGameTime()
  43. {
  44. return _gameStartTime;
  45. }
  46. /// <summary>
  47. /// 玩家死亡人数
  48. /// </summary>
  49. public int PlayerDeathNumber { get; set; }
  50. /// <summary>
  51. /// 玩家受击次数
  52. /// </summary>
  53. public int PlayerBehitCount { get; set; }
  54. /// <summary>
  55. /// 指定玩家
  56. /// </summary>
  57. public bool HaveAppointPlayer { get; set; }
  58. /// <summary>
  59. /// 对战信息
  60. /// </summary>
  61. public VSHeroInfo VsInfo { get; set; }
  62. /// <summary>
  63. /// 指定玩家
  64. /// </summary>
  65. public List<int> appointPlayers = new List<int>();
  66. public bool isMultiRoom = false;
  67. /// <summary>
  68. /// 检测是否有指定玩家
  69. /// </summary>
  70. /// <param name="heros"></param>
  71. public void CheckHaveAppointPlayers(List<GameHeroVo> heros)
  72. {
  73. for (int i = 0; i < heros.Count; i++)
  74. {
  75. if (heros[i] == null)
  76. {
  77. continue;
  78. }
  79. if (appointPlayers.Contains(int.Parse(heros[i].typeId)))
  80. {
  81. HaveAppointPlayer = true;
  82. return;
  83. }
  84. }
  85. HaveAppointPlayer = false;
  86. }
  87. /// <summary>
  88. /// 玩家总连击次数
  89. /// </summary>
  90. public int PlayerComboCount { get; set; }
  91. /// <summary>
  92. /// 玩家使用必杀技的次数
  93. /// </summary>
  94. public int PlayerUseSkillCount { get; set; }
  95. public BattleDefine.EBattleSceneType lastBattleType = BattleDefine.EBattleSceneType.EBattleType_Default;
  96. public bool IsNotBattleScene()
  97. {
  98. if(lastBattleType == BattleDefine.EBattleSceneType.EBattleType_Safe)
  99. {
  100. return true;
  101. }
  102. else if (lastBattleType == BattleDefine.EBattleSceneType.EBattleType_YanJiuSuo)
  103. {
  104. return true;
  105. }
  106. else if (lastBattleType == BattleDefine.EBattleSceneType.EBattleType_HuanLingShi)
  107. {
  108. return true;
  109. }
  110. return false;
  111. }
  112. /// <summary>
  113. /// 清理
  114. /// </summary>
  115. public void Clear()
  116. {
  117. _gameStartTime = 0;
  118. PlayerDeathNumber = 0;
  119. PlayerBehitCount = 0;
  120. PlayerComboCount = 0;
  121. PlayerUseSkillCount = 0;
  122. GateStar = 3;
  123. }
  124. /// <summary>
  125. /// 前往关卡
  126. /// </summary>
  127. public bool gotoGate = false;
  128. /// <summary>
  129. /// 大陆 ID
  130. /// </summary>
  131. public int LandID { get; set; }
  132. /// <summary>
  133. /// 关卡章节
  134. /// </summary>
  135. public int ZoneID { get; set; }
  136. /// <summary>
  137. /// 即将前往的 关卡 ID
  138. /// </summary>
  139. public int GateID { get; set; }
  140. /// <summary>
  141. /// 前往下一张地图之前的ID
  142. /// </summary>
  143. public int OldGateID { get; set; }
  144. /// <summary>
  145. /// 角色地图 出生点(场景切换器)
  146. /// </summary>
  147. public int CreateMapSwitchPoint { get; set; }
  148. /// <summary>
  149. /// 是否 传送门 返回传送点
  150. /// </summary>
  151. public bool IsBackDoor { get; set; }
  152. /// <summary>
  153. /// 回城
  154. /// </summary>
  155. public bool isBackTicket { get; set; }
  156. /// <summary>
  157. /// 死亡回城
  158. /// </summary>
  159. public bool isBackDie = false;
  160. public int CreateMapId { get; set; }
  161. /// <summary>
  162. /// 返回 回城点的位置
  163. /// </summary>
  164. public Vector3 CreatePosition { get; set; }
  165. /// <summary>
  166. /// 世界BOSS ID
  167. /// </summary>
  168. public int WordBossID { get; set; }
  169. /// <summary>
  170. /// 关卡难度
  171. /// </summary>
  172. public int GateDifficulty { get; set; }
  173. /// <summary>
  174. /// 关卡星级
  175. /// </summary>
  176. public int GateStar = 3;
  177. /// <summary>
  178. /// 当前无尽任务进度序号
  179. /// </summary>
  180. public int EndlessIndex = 1;
  181. /// <summary>
  182. /// 关卡数据
  183. /// </summary>
  184. public UIVO_Gate.SelectGateVo GateVO = null;
  185. /// <summary>
  186. /// 当前选中的英雄龙骨资源名称
  187. /// </summary>
  188. public string HeroDragonBonesName { get; set; }
  189. /// <summary>
  190. /// 通关条件是否OK
  191. /// </summary>
  192. /// <param name="conditionType">通关条件类型</param>
  193. /// 1.通关耗时不超过n秒, 参数: n秒
  194. /// 2.无人阵亡下通关, 参数: 无
  195. /// 3.唤灵师血量高于n%, 参数: n
  196. /// 4.装备指定言灵,参数: 言灵TypeId
  197. /// 5.至少装备n个指定x属性的言灵,参数: 数量n,元素类型s(见言灵表weaktype)
  198. /// 6.开启关卡内所有宝箱, 参数: 无 default(0)
  199. /// <param name="conditionParas">参数</param>
  200. /// <returns></returns>
  201. public bool GameGateOK(sm_gate_passCondition condition)
  202. {
  203. int conditionType = condition.conditionType;
  204. List<int> iParas = condition.GetParas();
  205. int val1 = 0;
  206. int val2 = 0;
  207. if (iParas.Count >= 2)
  208. {
  209. val1 = iParas[0];
  210. val2 = iParas[1];
  211. }
  212. else if (iParas.Count >= 1)
  213. {
  214. val1 = iParas[0];
  215. }
  216. switch (conditionType)
  217. {
  218. case 1:// 通关耗时不超过n秒, 参数: n秒
  219. {
  220. if (GetGameTime() <= val1)
  221. {
  222. return true;
  223. }
  224. }
  225. break;
  226. case 2:// 无人阵亡下通关, 参数: 无
  227. {
  228. if (PlayerDeathNumber <= val1)
  229. {
  230. return true;
  231. }
  232. }
  233. break;
  234. case 3:// 唤灵师血量高于n%, 参数: n
  235. Role role = RoleManager.Instance.GetPlayer();
  236. int hpVal = 100;
  237. if (role != null)
  238. {
  239. hpVal = role.mData.HP_Final * 100 / role.mData.MaxHP_Final;
  240. }
  241. if (hpVal >= val1)
  242. {
  243. return true;
  244. }
  245. break;
  246. case 4:// 装备指定言灵,参数: 言灵TypeId
  247. {
  248. return UserProxy.Instance.player.heroTeamConfig.CurTeam.IsWearingXYanling(val1);
  249. }
  250. break;
  251. case 5:// 至少装备n个指定x属性的言灵,参数: 数量n,元素类型s(见言灵表weaktype)
  252. {
  253. return UserProxy.Instance.player.heroTeamConfig.CurTeam.IsWearingN_XProperty_Yanling(val1, val2);
  254. }
  255. break;
  256. case 6:// 开启关卡内所有宝箱, 参数: 无 default(0)
  257. {
  258. return SceneCmptManager.Instance.IsAllTreasureBoxFinish();
  259. }
  260. break;
  261. }
  262. return false;
  263. }
  264. }