BattleManagerSkill.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. namespace YLBattle
  6. {
  7. /// <summary>
  8. /// 战场技能
  9. /// </summary>
  10. public partial class BattleManager : IBattleGlobalOper
  11. {
  12. /// <summary>
  13. /// 释放技能
  14. /// </summary>
  15. /// <param name="who"></param>
  16. /// <param name="skillTid"></param>
  17. /// <param name="_type">0=普攻 1=技能</param>
  18. /// <param name="triggerParm">触发参数</param>
  19. public void OnCastBullet(string who, string skillTid, string trg = "", bool ismarktrg = false)
  20. {
  21. if (string.IsNullOrEmpty(who) || string.IsNullOrEmpty(skillTid))
  22. {
  23. this.Env().DebugHelper().Warning("错误:对象:" + who + "模板id:" + who + "释放技能id:" + skillTid);
  24. return;
  25. }
  26. //Debug.Log(who + " castBullet " + skillTid);
  27. //this.mBulletModel.OnCastSkill(who, skillTid, trg, ismarktrg);
  28. }
  29. /// <summary>
  30. /// 释放技能 (带动作)
  31. /// </summary>
  32. /// <param name="who"></param>
  33. /// <param name="skillId"></param>
  34. /// <param name="target"></param>
  35. public void OnCastSkill(string who, string skillId, bool ismark = false)
  36. {
  37. if (skillId == string.Empty || skillId.Trim().Length <= 0)
  38. {
  39. return;
  40. }
  41. /// 需优化对象创建
  42. FieldEvent ev = this.Env().EventDisp().MakeEvent(EFieldEventType.EFIELD_EVENT_CASTSKILL);
  43. ev.PutValue("caster", who);
  44. ev.PutValue("skill", skillId);
  45. ev.PutValue("isskill", "true");
  46. ev.PutValue("ismarktrg", ismark.ToString());
  47. //LogHelper.Log(who + " skill=" + skillId);
  48. this.Env().EventDisp().PostEvent(ev);
  49. }
  50. /// <summary>
  51. /// 触发被动技能
  52. /// </summary>
  53. /// <param name="triggerType">当前事件类型</param>
  54. /// <param name="triggerParm">事件参数</param>
  55. /// <param name="casterId">释放者</param>
  56. /// <param name="targetIds">受影响ID列</param>
  57. public void OnTriggerPassiveSkill(int triggerType, string triggerParm = "", string casterId = "", string targetIds = "")
  58. {
  59. FieldEvent ev = this.Env().EventDisp().MakeEvent(EFieldEventType.EFIELD_EVENT_PASSIVE);
  60. ev.PutValue("markType", triggerType.ToString());
  61. /**
  62. * caster=单项时为事件当前触发者。
  63. */
  64. ev.PutValue("caster", casterId);
  65. /**
  66. * targets=所有受影响的角色
  67. */
  68. ev.PutValue("targets", targetIds);
  69. ev.PutValue("parm", triggerParm);
  70. /**
  71. * 这里不采用事件,主要是为了解决被动技能可以及时触发,否则如果压栈到事件里,会慢半拍~~
  72. */
  73. //------------------------2017-09-04关闭被动技能触发
  74. //this.Env().mSkillManagerOpr.OnTrigger(ev);
  75. //
  76. }
  77. ///// <summary>
  78. ///// 对象向目标【释放】技能
  79. ///// </summary>
  80. ///// <param name="who">释放者</param>
  81. ///// <param name="_skillId">技能Id</param>
  82. //public void OnCastSkillByConsumePower(string who,bool ismark=false)
  83. //{
  84. // LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
  85. // if (BattleSwitch.IsConsumePower)
  86. // {
  87. // ///能量消失
  88. // fighter.SetProperty(EBattleProperty.NPOWER, 0);
  89. // }
  90. // //Debug.LogError(who + " OnCastSkillByConsumePower " + fighter.ManuSkill1());
  91. // this.OnCastSkill(who, fighter.ManuSkill1(),ismark);
  92. //}
  93. /// <summary>
  94. /// 是否可释放技能
  95. /// </summary>
  96. /// <param name="who"></param>
  97. /// <returns></returns>
  98. public bool ToCheckCouldCastSkill(string who)
  99. {
  100. if (this.mFieldModule.CurrentPoilcy() == null ||
  101. this.mFieldModule.CurrentPoilcy().Type() != EBattleStaus.EBATTLE_STATUS_FIGHTING)
  102. {
  103. return false;
  104. }
  105. if (this.mFieldModule.CurrentSubPolicy() != null)
  106. {
  107. //己方通过UI释放技能时,待技能释放(bomb)完毕后,才可再次点击,敌方才可以继续轮询
  108. return false;
  109. }
  110. LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
  111. if (fighter == null || fighter.IsDead())
  112. {
  113. return false;
  114. }
  115. List<LogicFighter> targets = this.Env().mLogicFighterOper.FindTeamAliveFighter(fighter.Team() == EBattleTeam.BLUETEAM ? EBattleTeam.REDTEAM : EBattleTeam.BLUETEAM);
  116. if (targets == null || targets.Count <= 0)
  117. {
  118. LogHelper.Log("无法释放技能:" + (fighter.Team() == EBattleTeam.BLUETEAM ? "红对" : "蓝队") + "敌方全部死亡,战斗结束");
  119. return false;
  120. }
  121. if (fighter.GetBuffEffectProperty(EBuffEffect.EBUFF_EFFECT_Silent) != 0)
  122. {
  123. return false;
  124. }
  125. if (fighter.GetBuffEffectProperty(EBuffEffect.EBUFF_EFFECT_Stun) != 0)
  126. {
  127. return false;
  128. }
  129. return true;
  130. }
  131. #region UI_TipWindow
  132. /// <summary>
  133. /// [UI]角色释放必杀技能准备【提示】
  134. /// </summary>
  135. /// <param name="who">释放者</param>
  136. /// <param name="_skillId">技能Id</param>
  137. public void OnManualSkillTipFromUnity(string who)
  138. {
  139. if (!ToCheckCouldCastSkill(who))
  140. {
  141. return;
  142. }
  143. LogicFighter fighter = this.Env().mLogicFighterOper.FindFighter(who);
  144. if (BattleSwitch.IsConsumePower)
  145. {
  146. if (fighter.RoleType() == 0)
  147. {
  148. fighter.SetProperty(EBattleProperty.NPOWER, 0);
  149. }
  150. else
  151. {
  152. this.Env().BattleBlueTeamSkillPower -= long.Parse(fighter.GetProperty(EBattleProperty.NMAXPOWER).ToString());
  153. }
  154. }
  155. if (fighter.Team() == EBattleTeam.BLUETEAM && this.Env().levelMode != 2 && this.Env().levelMode != 4)
  156. {
  157. this.Env().BattleCOMBOPower += this.Env().IncreasePowerByCastSkill;
  158. }
  159. this.Env().mBlueSkillFighterId = who;
  160. }
  161. #endregion
  162. #region bullet 实时位置 碰撞事件 死亡
  163. /// <summary>
  164. /// [Bullet=>ProjectileBase-Update]修改子弹当前位置
  165. /// </summary>
  166. /// <param name="id">子弹实例ID</param>
  167. /// <param name="pos">坐标</param>
  168. public void ModifyBulletPostion(string id, Vector3 pos)
  169. {
  170. //CBullet bullet = this.mBulletModel.FindBullet(id);
  171. //if (null == bullet)
  172. //{
  173. // return;
  174. //}
  175. //bullet.ModifyCurrentPos(pos);
  176. }
  177. /// <summary>
  178. /// [SkillControl.createSkillExplode]子弹碰撞事件
  179. /// </summary>
  180. /// <param name="id">子弹实例ID</param>
  181. /// <param name="target">碰撞到的目标实例ID, 没有则传递string.Empty</param>
  182. public void OnBulletCollideEvent(string id, string target)
  183. {
  184. //CBullet bullet = this.mBulletModel.FindBullet(id);
  185. //if (null == bullet)
  186. //{
  187. // this.Env().DebugHelper().Error("无法查找到指定子弹:" + id);
  188. // return;
  189. //}
  190. //int delay = int.Parse(this.Env().SkillAdapter().GetSkillProperty(bullet.TID(), ESkillProperty.ESKILL_PROPERTY_BOMBTIME));
  191. //BulletCollideEvent bce = new BulletCollideEvent();
  192. //bce.id = id;
  193. //bce.time = this.Env().TimeCenter().Now();
  194. //bce.bombtime = bce.time + delay;
  195. //bce.target = target;
  196. //bce.postion = bullet.CurrentPos();
  197. //bullet.EnqueueCollideEvent(bce);
  198. }
  199. /// <summary>
  200. /// 标记子弹为消亡状态
  201. /// </summary>
  202. /// <param name="id">子弹实例ID</param>
  203. public void MarkBulletDead(string id)
  204. {
  205. //CBullet bullet = this.mBulletModel.FindBullet(id);
  206. //if (null == bullet)
  207. //{
  208. // this.Env().DebugHelper().Warning("无法查找到指定子弹:" + id);
  209. // return;
  210. //}
  211. //this.Env().mBattleGlobalOper.ConfirmSkillBombComplete(bullet.Owner(), bullet.TID());
  212. //bullet.MarkBulletDead();
  213. }
  214. #endregion
  215. }
  216. }