X2BattleManagert.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityGameFramework.Runtime;
  5. using GameFramework.Event;
  6. namespace X2Battle
  7. {
  8. /// <summary>
  9. /// 战斗管理
  10. /// </summary>
  11. public partial class X2BattleManager : Singleton<X2BattleManager>
  12. {
  13. /// <summary>
  14. /// 战斗上下文环境信息
  15. /// </summary>
  16. protected YLBattle.BattleParam mBattleParam = null;
  17. /// <summary>
  18. /// (技能)子弹管理器
  19. /// </summary>
  20. public BulletManager mBulletModel = new BulletManager();
  21. public YLBattle.BuffManager mBuffModel = new YLBattle.BuffManager();
  22. //public RoleManager mRoleManager;
  23. /// <summary>
  24. /// 返回上下文环境信息
  25. /// </summary>
  26. /// <returns>上下文环境信息</returns>
  27. public YLBattle.BattleParam Env()
  28. {
  29. return this.mBattleParam;
  30. }
  31. /// <summary>
  32. /// 开始一场战斗
  33. /// </summary>
  34. /// <param name="param">战斗参数</param>
  35. public void BattleStart(YLBattle.BattleParam param)
  36. {
  37. ///战场模块数据间的交互
  38. this.mBattleParam = param;
  39. this.mBattleParam.mBulletManagerOpr = mBulletModel;
  40. ///交互模块的初始化
  41. this.mBulletModel.Initialize(this.mBattleParam);
  42. ///buff模块的初始化
  43. this.mBuffModel.Initialize(this.mBattleParam);
  44. this.mBattleParam.TimeCenter().Start();
  45. //this.mRoleManager = RoleManager.Instance;
  46. }
  47. /// <summary>
  48. /// 帧调度
  49. /// </summary>
  50. /// <returns>调度结果</returns>
  51. public void Update()
  52. {
  53. //TimeControl.Instance.GameNormal
  54. /// 计时器调度
  55. //this.mBattleParam.TimeCenter().Update();
  56. /// 时间
  57. //long now = this.Env().TimeCenter().Now();
  58. //RoleManager.Instance.OnUpdateRoles();
  59. /// buff调度
  60. this.mBuffModel.OnUpdateBuffs(0);
  61. /// 技能调度
  62. this.mBulletModel.OnUpdateBullet(0);
  63. }
  64. static public void EquipWeapOrYanling(object sender, GameEventArgs e)
  65. {
  66. User_AddItemEvent itemEvent = e as User_AddItemEvent;
  67. ItemVo vo = itemEvent.Item;
  68. int heroId = int.Parse(UserProxy.Instance.player.heroTeamConfig.CurTeam.CurTeamLeaderUID);
  69. int heroTypeId =int.Parse( UserProxy.Instance.player.collectHero.GetHeroGameInfoByHeroUId(heroId.ToString()).typeId);
  70. int heroLevel = UserProxy.Instance.player.collectHero.GetHeroGameInfoByHeroUId(heroId.ToString()).level;
  71. if (vo.nMo.subType == (int)EItemSubType.YanLing)
  72. {
  73. if (ItemProxy.Instance.TestWearYanlingToHeroCanImproveFightPower(int.Parse(vo.uid), heroId) &&
  74. vo.nMo.GetYanlingExt().require_herolvl <= heroLevel && vo.nMo.GetYanlingExt().CanbeUsedForHero(heroTypeId))////按刘海的需求,这里让王刚找到方法.检测该言灵是否可以让该英雄用
  75. {
  76. if(GameDateManager.Instance.lastBattleType == BattleDefine.EBattleSceneType.EBattleType_Safe)
  77. {
  78. return;
  79. }
  80. PanelHelper.Instance.ShowPanel("UI_ChangeEquipWindow", (GameObject panel) =>
  81. {
  82. if (panel)
  83. {
  84. UI_ChangeEquipWindow equipWind = panel.GetComponent<UI_ChangeEquipWindow>();
  85. equipWind.InitData(vo as UserYanlingVo);
  86. }
  87. });
  88. }
  89. }
  90. else if (vo.nMo.subType == (int)EItemSubType.Weapon)
  91. {
  92. if (ItemProxy.Instance.TestWearEquipToHeroCanImproveFightPower(int.Parse(vo.uid), heroId) &&
  93. vo.nMo.GetWeaponExt().require_herolvl <= heroLevel && vo.nMo.GetWeaponExt().CanbeEquipedOnHero(heroTypeId))////按刘海的需求,这里让王刚加了一个方法.检测该武器是否可以让该英雄用
  94. {
  95. if (GameDateManager.Instance.lastBattleType == BattleDefine.EBattleSceneType.EBattleType_Safe)
  96. {
  97. return;
  98. }
  99. PanelHelper.Instance.ShowPanel("UI_ChangeEquipWindow", (GameObject panel) =>
  100. {
  101. if (panel)
  102. {
  103. UI_ChangeEquipWindow equipWind = panel.GetComponent<UI_ChangeEquipWindow>();
  104. equipWind.InitData(vo as UserEquipmentVo);
  105. }
  106. });
  107. }
  108. }
  109. }
  110. }
  111. }