protected virtual void ActiveAttackPlay()
{
if (mAiInfo.nType != Define.MONSTER_TYPE_ACTIVE) return;//不是主动怪物-
//寻找目标需要时间--
if (System.Environment.TickCount - mnActiveAttackTick < Define.MONSTER_ACTIVEATTACK_TIME * 1000)
{
return;
}
mnActiveAttackTick = System.Environment.TickCount;
GameStruct.Point point = null;
GameStruct.Point newPoint = null;
BaseObject newObj = null;
if (TargetObj == null &&
System.Environment.TickCount - mnLastMoveTick > mAiInfo.nMove_Speed &&
SelObj.GetVisibleList().Count > 0
)
{
foreach (RefreshObject refobj in SelObj.GetVisibleList().Values)
{
if(refobj.obj.type != OBJECTTYPE.PLAYER && //只攻击角色与幻兽与暗黑龙骑的守护骑士
refobj.obj.type != OBJECTTYPE.EUDEMON &&
refobj.obj.type != OBJECTTYPE.GUARDKNIGHT &&
refobj.obj.type != OBJECTTYPE.MONSTER &&
refobj.obj.type != OBJECTTYPE.CALLOBJECT)
{
continue;
}
//如果是暗杀邪龙. 不攻击主人
if (!SelObj.CanPK(refobj.obj))
{
continue;
}
point = new GameStruct.Point();
point.x = (short)Math.Abs(refobj.obj.GetCurrentX() - SelObj.GetCurrentX());
point.y = (short)Math.Abs(refobj.obj.GetCurrentY() - SelObj.GetCurrentY());
if (newPoint == null)
{
newPoint = point;
newObj = refobj.obj;
}
if(point.x < newPoint.x &&
point.y < newPoint.y)
{
newPoint = point;
newObj = refobj.obj;
}
}
if (newObj != null)
{
//设置为攻击状态
TargetObj = newObj;
nState = BaseAI.ATTACK;
mnLastMoveTick = System.Environment.TickCount;
}
}
}