XmdsVirtual.Picking.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using CommonAI.Zone.Instance;
  2. using CommonAI.Zone.Formula;
  3. using XmdsCommon.Message;
  4. using XmdsCommon.Plugin;
  5. using XmdsCommonServer.Message;
  6. using XmdsCommon.EditorData;
  7. using XmdsCommonServer.Plugin.Units;
  8. using CommonAI.Zone;
  9. namespace XmdsCommonServer.Plugin
  10. {
  11. /// <summary>
  12. /// FileName: XmdsVirtual.cs
  13. /// Author: Alex.Yu
  14. /// Corporation:...
  15. /// Description: 用于伤害数值计算.
  16. /// DateTime: 2015/5/13 14:17:23
  17. /// </summary>
  18. partial class XmdsVirtual
  19. {
  20. #region PickUnit复活.
  21. protected void mUnit_OnPickUnit(InstanceUnit obj, InstanceUnit pickable, int time)
  22. {
  23. //点击已方阵营死亡玩家//
  24. if (pickable is InstancePlayer && pickable.Force == mUnit.Force && pickable.IsDead())
  25. {
  26. XmdsUnitProperties prop = (XmdsUnitProperties)(pickable.Info.Properties);
  27. XmdsVirtual zv = (XmdsVirtual)obj.Virtual;
  28. //开始读条复活死亡单位//
  29. CommonAI.Zone.Instance.InstanceUnit.StatePickObject spo = mUnit.startPickProgressObject(pickable, time, (s, p) =>
  30. {
  31. //如果单位已经处于活状态,则中断.
  32. if (pickable.IsDead() == true)
  33. {
  34. SendSaveMessage(obj, pickable);
  35. }
  36. });
  37. if (spo != null)
  38. {
  39. spo.SetCheckTargetAcvite(OnCheckPickable);
  40. }
  41. }
  42. }
  43. private bool OnCheckPickable(InstanceUnit unit, InstanceZoneObject pickable, ref string reason)
  44. {
  45. bool ret = false;
  46. if (pickable is InstanceUnit)
  47. {
  48. InstanceUnit iu = (InstanceUnit)pickable;
  49. if (iu.IsDead() == false)//如果单位复活则立即中断.
  50. {
  51. ret = true;
  52. }
  53. }
  54. return ret;
  55. }
  56. private void SendSaveMessage(InstanceUnit obj, InstanceUnit pickable)
  57. {
  58. }
  59. /// <summary>
  60. /// 发送施救信息.
  61. /// </summary>
  62. /// <param name="evt"></param>
  63. public void SendSaveMessage(ShowRebirthDialogueB2R evt)
  64. {
  65. if (evt != null)
  66. {
  67. this.mUnit.queueEvent(evt);
  68. }
  69. }
  70. #endregion
  71. #region 上下坐骑.
  72. /// <summary>
  73. /// 开始召唤坐骑.
  74. /// </summary>
  75. /// <param name="timeMS"></param>
  76. /// <param name="isSummonMount"></param>
  77. /// <param name="status"></param>
  78. public void StartSummonMount(int timeMS, bool isSummonMount, string status)
  79. {
  80. if (isSummonMount == false)
  81. {
  82. TakeOffMount();
  83. }
  84. else
  85. {
  86. //时间为0.不做动作,直接上坐骑.
  87. if (timeMS == 0)
  88. {
  89. SyncMountStatus(isSummonMount);
  90. }
  91. else
  92. {
  93. this.mUnit.startPickProgressSelf(timeMS, (s, p) =>
  94. {
  95. SyncMountStatus(isSummonMount);
  96. }, status);
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 通知游戏服单位坐骑状态变更.
  102. /// </summary>
  103. /// <param name="isSummonMount"></param>
  104. private void SendSummonMountNotify(bool isSummonMount)
  105. {
  106. if (this.mUnit is InstancePlayer)
  107. {
  108. SummonMountEventB2R evt = new SummonMountEventB2R();
  109. evt.playerId = (this.mUnit as InstancePlayer).PlayerUUID;
  110. evt.IsSummonMount = isSummonMount;
  111. this.mUnit.queueEvent(evt);
  112. var teamVirtual = (this.mUnit as XmdsInstancePlayer).TeamVirtual;
  113. //XmdsTeamInfo TeamInfo = (this.mUnit as XmdsInstancePlayer).TeamInfo;
  114. if (teamVirtual != null && isSummonMount && teamVirtual.TeamLeader == this.mUnit)
  115. {
  116. teamVirtual.notifyTeamerRide();
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// 同步坐骑状态.
  122. /// </summary>
  123. /// <param name="isSummonMount"></param>
  124. private void SyncMountStatus(bool isSummonMount)
  125. {
  126. IsMounted = isSummonMount;
  127. //通知游戏服.
  128. SendSummonMountNotify(isSummonMount);
  129. }
  130. /// <summary>
  131. /// 检查坐骑状态.
  132. /// </summary>
  133. /// <param name="attacker"></param>
  134. private void MountOnHitCheck(XmdsVirtual attacker)
  135. {
  136. if (!IsMounted) { return; }
  137. //被玩家单位或BOSS攻击时下马.
  138. //bool IsBoss = false;
  139. //if (attacker is XmdsVirtual_Monster)
  140. //{
  141. // MonsterVisibleDataB2C edata = attacker.mUnit.GenSyncInfo(false).ExtData as MonsterVisibleDataB2C;
  142. // if (edata != null && edata.MType == MonsterVisibleDataB2C.MonsterType.MType4)
  143. // {
  144. // IsBoss = true;
  145. // }
  146. //}
  147. // if (attacker.IsPlayerUnit() || IsBoss)
  148. {
  149. SendMsgToClient(CommonAI.XmdsConstConfig.TIPS_UNDER_ATTACK);
  150. this.TakeOffMount();
  151. }
  152. }
  153. /// <summary>
  154. /// 放技能时检查影响坐骑状态.
  155. /// </summary>
  156. private void MountOnLaunchSkillCheck()
  157. {
  158. if (!IsMounted) { return; }
  159. this.TakeOffMount();
  160. }
  161. /// <summary>
  162. /// 中BUFF时检查是否影响坐骑状态.
  163. /// </summary>
  164. /// <param name="node"></param>
  165. private void MountOnBuffBegin(BuffTemplate buff)
  166. {
  167. if (!IsMounted) { return; }
  168. //控制类BUFF,会强制取消坐骑状态.
  169. if (XmdsInstanceUtils.IsControlBuff(buff))
  170. {
  171. this.TakeOffMount();
  172. }
  173. }
  174. /// <summary>
  175. /// 被攻击时检查是否影响坐骑状态.
  176. /// </summary>
  177. /// <param name="source"></param>
  178. private void MountOnHit(AttackSource source)
  179. {
  180. if (!IsMounted) { return; }
  181. if (source.OutIsDamage == true)
  182. {
  183. this.TakeOffMount();
  184. }
  185. }
  186. #endregion
  187. }
  188. }