本文整理汇总了C#中wServer.realm.Entity.GetNearestEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetNearestEntity方法的具体用法?C# Entity.GetNearestEntity怎么用?C# Entity.GetNearestEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wServer.realm.Entity
的用法示例。
在下文中一共展示了Entity.GetNearestEntity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TickCore
protected override bool TickCore(Entity host, RealmTime time, ref object state)
{
if (host.GetNearestEntity(dist, target) == null && host.GetNearestEntity(dist, target2) == null)
{
return true;
}
return false;
}
示例2: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
int cooldown;
if (state == null) cooldown = 1000;
else cooldown = (int)state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
Player player = (Player)host.GetNearestEntity(distance, null);
if (player != null)
{
Vector2 vect;
vect = new Vector2(player.X - host.X, player.Y - host.Y);
vect.Normalize();
float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist);
host.UpdateCount++;
if (cooldown <= 0)
{
Status = CycleStatus.Completed;
cooldown = 1000;
}
else
{
Status = CycleStatus.InProgress;
cooldown -= time.thisTickTimes;
}
}
state = cooldown;
}
示例3: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
ProtectState s;
if (state == null) s = ProtectState.DontKnowWhere;
else s = (ProtectState) state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
Entity entity = host.GetNearestEntity(acquireRange, protectee);
Vector2 vect;
switch (s)
{
case ProtectState.DontKnowWhere:
if (entity != null)
{
s = ProtectState.Protecting;
goto case ProtectState.Protecting;
}
break;
case ProtectState.Protecting:
if (entity == null)
{
s = ProtectState.DontKnowWhere;
break;
}
vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
if (vect.Length > reprotectRange)
{
Status = CycleStatus.InProgress;
vect.Normalize();
float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
host.UpdateCount++;
}
else
{
Status = CycleStatus.Completed;
s = ProtectState.Protected;
}
break;
case ProtectState.Protected:
if (entity == null)
{
s = ProtectState.DontKnowWhere;
break;
}
Status = CycleStatus.Completed;
vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
if (vect.Length > protectionRange)
{
s = ProtectState.Protecting;
goto case ProtectState.Protecting;
}
break;
}
state = s;
}
示例4: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
if (host.GetNearestEntity(100, 0x5e4b) != null) return;
Entity opener = Entity.Resolve(host.Manager, "Realm Portal Opener");
host.Owner.EnterWorld(opener);
opener.Move(host.X, host.Y);
}
示例5: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
ChargeState s;
if (state == null) s = new ChargeState();
else s = (ChargeState) state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
if (s.RemainingTime <= 0)
{
if (s.Direction == Vector2.Zero)
{
var player = (Player) host.GetNearestEntity(range, null);
if (player != null && player.X != host.X && player.Y != host.Y)
{
s.Direction = new Vector2(player.X - host.X, player.Y - host.Y);
float d = s.Direction.Length;
s.Direction.Normalize();
s.RemainingTime = coolDown.Next(Random);
if (d/host.GetSpeed(speed) < s.RemainingTime)
s.RemainingTime = (int) (d/host.GetSpeed(speed)*1000);
Status = CycleStatus.InProgress;
}
}
else
{
s.Direction = Vector2.Zero;
s.RemainingTime = coolDown.Next(Random);
Status = CycleStatus.Completed;
}
}
if (s.Direction != Vector2.Zero)
{
float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
host.ValidateAndMove(host.X + s.Direction.X*dist, host.Y + s.Direction.Y*dist);
host.UpdateCount++;
Status = CycleStatus.InProgress;
}
s.RemainingTime -= time.thisTickTimes;
state = s;
}
示例6: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
FollowState s;
if (state == null) s = new FollowState();
else s = (FollowState) state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;
var player = host.GetNearestEntity(acquireRange, null);
Vector2 vect;
switch (s.State)
{
case F.DontKnowWhere:
if (player != null && s.RemainingTime <= 0)
{
s.State = F.Acquired;
if (duration > 0)
s.RemainingTime = duration;
goto case F.Acquired;
}
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
break;
case F.Acquired:
if (player == null)
{
s.State = F.DontKnowWhere;
s.RemainingTime = 0;
break;
}
if (s.RemainingTime <= 0 && duration > 0)
{
s.State = F.DontKnowWhere;
s.RemainingTime = coolDown.Next(Random);
Status = CycleStatus.Completed;
break;
}
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
vect = new Vector2(player.X - host.X, player.Y - host.Y);
if (vect.Length() > range)
{
Status = CycleStatus.InProgress;
vect.X -= Random.Next(-2, 2)/2f;
vect.Y -= Random.Next(-2, 2)/2f;
vect.Normalize();
float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
host.UpdateCount++;
}
else
{
Status = CycleStatus.Completed;
s.State = F.Resting;
s.RemainingTime = 0;
}
break;
case F.Resting:
if (player == null)
{
s.State = F.DontKnowWhere;
if (duration > 0)
s.RemainingTime = duration;
break;
}
Status = CycleStatus.Completed;
vect = new Vector2(player.X - host.X, player.Y - host.Y);
if (vect.Length() > range + 1)
{
s.State = F.Acquired;
s.RemainingTime = duration;
goto case F.Acquired;
}
break;
}
state = s;
}
示例7: TickCore
protected override bool TickCore(Entity host, RealmTime time, ref object state)
{
return host.GetNearestEntity(dist, target) != null;
}
示例8: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if (checkForStates && !states.ToList().Contains(host.CurrentState.Name)) return;
if (state != null && cooldown.CoolDown == 0) return; //cooldown = 0 -> once per state entry
int c;
if (state == null) c = cooldown.Next(Random);
else c = (int)state;
c -= time.thisTickTimes;
state = c;
if (c > 0) return;
c = cooldown.Next(Random);
state = c;
if (Random.NextDouble() >= probability) return;
string taunt = text.Length == 1 ? text[0] : text[Random.Next(text.Length)];
if (taunt.Contains("{PLAYER}"))
{
Entity player = host.GetNearestEntity(10, null);
if (player == null) return;
taunt = taunt.Replace("{PLAYER}", player.Name);
}
taunt = taunt.Replace("{HP}", (host as Enemy).HP.ToString());
TextPacket packet = new TextPacket
{
Name = "#" + (host.ObjectDesc.DisplayId ?? host.ObjectDesc.ObjectId),
ObjectId = host.Id,
Stars = -1,
BubbleTime = 5,
Recipient = "",
Text = taunt,
CleanText = ""
};
if (broadcast)
host.Owner.BroadcastPacket(packet, null);
else
foreach (Player i in host.Owner.PlayersCollision.HitTest(host.X, host.Y, 15).OfType<Player>())
if (host.Dist(i) < 15)
i.Client.SendPacket(packet);
}
示例9: TickCore
protected override bool TickCore(Entity host, RealmTime time, ref object state)
{
foreach (string children in childrens)
if (host.GetNearestEntity(dist, host.Manager.GameData.IdToObjectType[children]) != null) return false;
return true;
}