using CommonAI.Zone.Instance;
using CommonAI.Zone.Formula;
using XmdsCommon.Message;
using XmdsCommon.Plugin;
using XmdsCommonServer.Message;
using XmdsCommon.EditorData;
using XmdsCommonServer.Plugin.Units;
using CommonAI.Zone;
namespace XmdsCommonServer.Plugin
{
///
/// FileName: XmdsVirtual.cs
/// Author: Alex.Yu
/// Corporation:...
/// Description: 用于伤害数值计算.
/// DateTime: 2015/5/13 14:17:23
///
partial class XmdsVirtual
{
#region PickUnit复活.
protected void mUnit_OnPickUnit(InstanceUnit obj, InstanceUnit pickable, int time)
{
//点击已方阵营死亡玩家//
if (pickable is InstancePlayer && pickable.Force == mUnit.Force && pickable.IsDead())
{
XmdsUnitProperties prop = (XmdsUnitProperties)(pickable.Info.Properties);
XmdsVirtual zv = (XmdsVirtual)obj.Virtual;
//开始读条复活死亡单位//
CommonAI.Zone.Instance.InstanceUnit.StatePickObject spo = mUnit.startPickProgressObject(pickable, time, (s, p) =>
{
//如果单位已经处于活状态,则中断.
if (pickable.IsDead() == true)
{
SendSaveMessage(obj, pickable);
}
});
if (spo != null)
{
spo.SetCheckTargetAcvite(OnCheckPickable);
}
}
}
private bool OnCheckPickable(InstanceUnit unit, InstanceZoneObject pickable, ref string reason)
{
bool ret = false;
if (pickable is InstanceUnit)
{
InstanceUnit iu = (InstanceUnit)pickable;
if (iu.IsDead() == false)//如果单位复活则立即中断.
{
ret = true;
}
}
return ret;
}
private void SendSaveMessage(InstanceUnit obj, InstanceUnit pickable)
{
}
///
/// 发送施救信息.
///
///
public void SendSaveMessage(ShowRebirthDialogueB2R evt)
{
if (evt != null)
{
this.mUnit.queueEvent(evt);
}
}
#endregion
#region 上下坐骑.
///
/// 开始召唤坐骑.
///
///
///
///
public void StartSummonMount(int timeMS, bool isSummonMount, string status)
{
if (isSummonMount == false)
{
TakeOffMount();
}
else
{
//时间为0.不做动作,直接上坐骑.
if (timeMS == 0)
{
SyncMountStatus(isSummonMount);
}
else
{
this.mUnit.startPickProgressSelf(timeMS, (s, p) =>
{
SyncMountStatus(isSummonMount);
}, status);
}
}
}
///
/// 通知游戏服单位坐骑状态变更.
///
///
private void SendSummonMountNotify(bool isSummonMount)
{
if (this.mUnit is InstancePlayer)
{
SummonMountEventB2R evt = new SummonMountEventB2R();
evt.playerId = (this.mUnit as InstancePlayer).PlayerUUID;
evt.IsSummonMount = isSummonMount;
this.mUnit.queueEvent(evt);
var teamVirtual = (this.mUnit as XmdsInstancePlayer).TeamVirtual;
//XmdsTeamInfo TeamInfo = (this.mUnit as XmdsInstancePlayer).TeamInfo;
if (teamVirtual != null && isSummonMount && teamVirtual.TeamLeader == this.mUnit)
{
teamVirtual.notifyTeamerRide();
}
}
}
///
/// 同步坐骑状态.
///
///
private void SyncMountStatus(bool isSummonMount)
{
IsMounted = isSummonMount;
//通知游戏服.
SendSummonMountNotify(isSummonMount);
}
///
/// 检查坐骑状态.
///
///
private void MountOnHitCheck(XmdsVirtual attacker)
{
if (!IsMounted) { return; }
//被玩家单位或BOSS攻击时下马.
//bool IsBoss = false;
//if (attacker is XmdsVirtual_Monster)
//{
// MonsterVisibleDataB2C edata = attacker.mUnit.GenSyncInfo(false).ExtData as MonsterVisibleDataB2C;
// if (edata != null && edata.MType == MonsterVisibleDataB2C.MonsterType.MType4)
// {
// IsBoss = true;
// }
//}
// if (attacker.IsPlayerUnit() || IsBoss)
{
SendMsgToClient(CommonAI.XmdsConstConfig.TIPS_UNDER_ATTACK);
this.TakeOffMount();
}
}
///
/// 放技能时检查影响坐骑状态.
///
private void MountOnLaunchSkillCheck()
{
if (!IsMounted) { return; }
this.TakeOffMount();
}
///
/// 中BUFF时检查是否影响坐骑状态.
///
///
private void MountOnBuffBegin(BuffTemplate buff)
{
if (!IsMounted) { return; }
//控制类BUFF,会强制取消坐骑状态.
if (XmdsInstanceUtils.IsControlBuff(buff))
{
this.TakeOffMount();
}
}
///
/// 被攻击时检查是否影响坐骑状态.
///
///
private void MountOnHit(AttackSource source)
{
if (!IsMounted) { return; }
if (source.OutIsDamage == true)
{
this.TakeOffMount();
}
}
#endregion
}
}