本文整理汇总了C#中wServer.realm.Entity.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.Move方法的具体用法?C# Entity.Move怎么用?C# Entity.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wServer.realm.Entity
的用法示例。
在下文中一共展示了Entity.Move方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if (!returned)
{
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
var spd = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
Position pos = (host as Enemy).SpawnPoint;
var tx = pos.X;
var ty = pos.Y;
if (Math.Abs(tx - host.X) > 1 || Math.Abs(ty - host.Y) > 1)
{
var x = host.X;
var y = host.Y;
Vector2 vect = new Vector2(tx, ty) - new Vector2(host.X, host.Y);
vect.Normalize();
vect *= spd;
host.Move(host.X + vect.X, host.Y + vect.Y);
host.UpdateCount++;
}
if (host.X == pos.X && host.Y == pos.Y && once)
{
once = true;
returned = true;
}
}
}
示例2: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
if (!isMapPosition)
{
X = baseX + host.X;
Y = baseY + host.Y;
}
else
{
X = baseX;
Y = baseY;
}
if (instant)
{
host.Move(X, Y);
host.UpdateCount++;
}
}
示例3: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if (host is Pet) if ((host as Pet).PlayerOwner != null) return;
WmapTile tile = host.Owner.Map[(int)host.X, (int)host.Y].Clone();
if (tile.Region == TileRegion.None && host.Owner is PetYard)
{
Position pos = (host as Pet).SpawnPoint;
host.Move(pos.X, pos.Y);
return;
}
if (host.GetNearestEntity(1, null) == null)
{
WanderStorage storage;
if (state == null) storage = new WanderStorage();
else storage = (WanderStorage)state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
Status = CycleStatus.InProgress;
if (storage.RemainingDistance <= 0)
{
storage.Direction = new Vector2(Random.Next(-2, 2), Random.Next(-2, 2));
storage.Direction.Normalize();
storage.RemainingDistance = coolDown.Next(Random) / 1000f;
Status = CycleStatus.Completed;
}
float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist);
host.UpdateCount++;
storage.RemainingDistance -= dist;
state = storage;
}
}
示例4: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if (instant) return;
if (!returned)
{
if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
var spd = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
if (Math.Abs(X - host.X) > 0.5 || Math.Abs(Y - host.Y) > 0.5)
{
Vector2 vect = new Vector2(X, Y) - new Vector2(host.X, host.Y);
vect.Normalize();
vect *= spd;
host.Move(host.X + vect.X, host.Y + vect.Y);
host.UpdateCount++;
if (host.X == X && host.Y == Y && once)
{
once = true;
returned = true;
}
}
}
}
示例5: 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;
Player player = host.GetPlayerOwner();
if (player.Owner == null)
{
host.Owner.LeaveWorld(host);
return;
}
Vector2 vect;
switch (s.State)
{
case F.DontKnowWhere:
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
else
s.State = F.Acquired;
break;
case F.Acquired:
if (player == null)
{
s.State = F.DontKnowWhere;
s.RemainingTime = 0;
break;
}
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
vect = new Vector2(player.X - host.X, player.Y - host.Y);
if (vect.Length > 20)
{
host.Move(player.X, player.Y);
host.UpdateCount++;
}
else if (vect.Length > 1)
{
float dist = host.GetSpeed(1.2f) * (time.thisTickTimes / 1000f);
if (vect.Length > 2)
dist = host.GetSpeed(1.2f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 3.5)
dist = host.GetSpeed(1.2f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 5)
dist = host.GetSpeed(1.3f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 6)
dist = host.GetSpeed(1.4f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 7)
dist = host.GetSpeed(1.5f + ((float)player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
Status = CycleStatus.InProgress;
vect.X -= Random.Next(-2, 2) / 2f;
vect.Y -= Random.Next(-2, 2) / 2f;
vect.Normalize();
host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist);
host.UpdateCount++;
}
break;
}
state = s;
}
示例6: ValidateAndMove
public static bool ValidateAndMove(Entity entity, float x, float y)
{
if (entity.Owner == null ||
entity.HasConditionEffect(ConditionEffects.Paralyzed))
return false;
if (Validate(entity, x, y))
entity.Move(x, y);
else if (Validate(entity, entity.X, y))
entity.Move(entity.X, y);
else if (Validate(entity, x, entity.Y))
entity.Move(x, entity.Y);
else
return false;
return true;
}
示例7: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if ((host as Pet)?.PlayerOwner == null) return;
var pet = (Pet)host;
FollowState s;
if (state == null) s = new FollowState();
else s = (FollowState)state;
Status = CycleStatus.NotStarted;
var player = host.GetEntity(pet.PlayerOwner.Id) as Player;
if (player == null)
{
var tile = host.Owner.Map[(int)host.X, (int)host.Y].Clone();
if (tile.Region != TileRegion.PetRegion)
{
if (!(host.Owner is PetYard))
{
host.Owner.LeaveWorld(host);
return;
}
if (tile.Region != TileRegion.Spawn)
{
host.Owner.LeaveWorld(host);
return;
}
}
}
switch (s.State)
{
case F.DontKnowWhere:
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
else
s.State = F.Acquired;
break;
case F.Acquired:
if (player == null)
{
s.State = F.DontKnowWhere;
s.RemainingTime = 0;
break;
}
if (s.RemainingTime > 0)
s.RemainingTime -= time.thisTickTimes;
var vect = new Vector2(player.X - host.X, player.Y - host.Y);
if (vect.Length > 20)
{
host.Move(player.X, player.Y);
host.UpdateCount++;
}
else if (vect.Length > 1)
{
var dist = host.GetSpeed(0.5f) * (time.thisTickTimes / 1000f);
if (vect.Length > 2)
dist = host.GetSpeed(0.5f + ((float)player.Stats[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 3.5)
dist = host.GetSpeed(0.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 5)
dist = host.GetSpeed(1.0f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 6)
dist = host.GetSpeed(1.35f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 7)
dist = host.GetSpeed(1.5f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
else if (vect.Length > 10)
dist = host.GetSpeed(2f + (player.Stats[4] + (float)player.Boost[4] / 100)) * (time.thisTickTimes / 1000f);
Status = CycleStatus.InProgress;
vect.Normalize();
host.ValidateAndMove(host.X + vect.X * dist, host.Y + vect.Y * dist);
host.UpdateCount++;
}
break;
}
state = s;
}
示例8: SpawnEntity
public virtual void SpawnEntity(Entity entity)
{
IntPoint tile = GetRandomTile(TileRegion.Spawn);
entity.Move(tile.X + 0.5f, tile.Y + 0.5f);
}
示例9: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
host.Move(host.X + Random.Next(minX, maxX), host.Y + Random.Next(minY, maxY));
host.UpdateCount++;
}