本文整理汇总了C#中Aura.World.World.MabiCreature.GetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C# MabiCreature.GetSpeed方法的具体用法?C# MabiCreature.GetSpeed怎么用?C# MabiCreature.GetSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.World.World.MabiCreature
的用法示例。
在下文中一共展示了MabiCreature.GetSpeed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActivateMobs
public void ActivateMobs(MabiCreature creature, MabiVertex from, MabiVertex to)
{
IEnumerable<MabiCreature> mobsInRange = _creatures.Where(c =>
c.Region == creature.Region
&& c is MabiNPC
&& ((MabiNPC)c).AIScript != null);
long leftX, rightX, topY, bottomY; //Bounding rectangle coordinates
if (from.X < to.X) //Moving right
{
leftX = from.X - 2600;
rightX = to.X + 2600;
}
else
{
leftX = to.X - 2600;
rightX = from.X + 2600;
}
if (from.Y < to.Y) //Moving up
{
bottomY = from.Y - 2600;
topY = to.Y + 2600;
}
else
{
bottomY = to.Y - 2600;
topY = from.Y + 2600;
}
//Linear movement equation
double slope;
if (to.Y == from.Y)
{
slope = .001; //double.MinValue produces infinity in B
}
else
{
slope = ((double)to.Y - from.Y) / ((double)to.X - from.X);
}
double b = from.Y - slope * from.X;
mobsInRange = mobsInRange.Where((c) =>
{
var pos = c.GetPosition();
return (leftX < pos.X && pos.X < rightX && bottomY < pos.Y && pos.Y < topY && (Math.Abs(pos.Y - (long)(slope * pos.X + b)) < 2600));
});
double dist = Math.Sqrt(((to.X - from.X) * (to.X - from.X)) + ((to.Y - from.Y) * (to.Y - from.Y)));
uint time = (uint)Math.Ceiling(dist / creature.GetSpeed());
foreach (var mob in mobsInRange)
{
((MabiNPC)mob).AIScript.Activate(time);
}
}