本文整理汇总了C#中wServer.realm.Entity类的典型用法代码示例。如果您正苦于以下问题:C# Entity类的具体用法?C# Entity怎么用?C# Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于wServer.realm命名空间,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
int index;
if (state == null) index = -1;
else index = (int) state;
if (index < 0) //select
{
index = 0;
for (int i = 0; i < children.Length; i++)
{
children[i].Tick(host, time);
if (children[i].Status == CycleStatus.InProgress)
{
index = i;
break;
}
}
}
else //run a cycle
{
children[index].Tick(host, time);
if (children[index].Status == CycleStatus.Completed ||
children[index].Status == CycleStatus.NotStarted)
index = -1;
}
state = index;
}
示例2: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
Pet pet;
if (!isValidPet(host, out pet)) return;
if (Pet == null) Pet = pet;
TickCore(pet, time, ref state);
}
示例3: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
Entity[] ens = host.GetNearestEntities(dist).ToArray();
foreach (Entity e in ens)
if (e.ObjectType == host.Manager.GameData.IdToObjectType[children])
host.Owner.LeaveWorld(e);
}
示例4: 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;
}
示例5: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
condition.Tick(host, time);
if (condition.Result)
foreach (var i in behaviors)
i.Tick(host, time);
}
示例6: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
var storage = (BuzzStorage) state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;
if (storage.RemainingTime > 0)
{
storage.RemainingTime -= time.thisTickTimes;
Status = CycleStatus.NotStarted;
}
else
{
Status = CycleStatus.InProgress;
if (storage.RemainingDistance <= 0)
{
do
{
storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
} while (storage.Direction.X == 0 && storage.Direction.Y == 0);
storage.Direction.Normalize();
storage.RemainingDistance = this.dist;
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;
}
示例7: 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;
}
示例8: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
WanderStorage storage;
if (state == null) storage = new WanderStorage();
else storage = (WanderStorage) state;
Status = CycleStatus.NotStarted;
if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;
Status = CycleStatus.InProgress;
if (storage.RemainingDistance <= 0)
{
storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
storage.Direction.Normalize();
storage.RemainingDistance = period.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;
}
示例9: 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);
}
示例10: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
if ((host as Enemy).AltTextureIndex != index)
{
(host as Enemy).AltTextureIndex = index;
host.UpdateCount++;
}
}
示例11: OnStateEntry
protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
{
host.ApplyConditionEffect(new ConditionEffect
{
Effect = effect,
DurationMS = -1
});
}
示例12: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
Entity entity = Entity.Resolve(host.Manager, target);
entity.Move(host.X, host.Y);
host.Owner.EnterWorld(entity);
host.Owner.LeaveWorld(host);
}
示例13: 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;
}
示例14: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
if (targetState == null)
targetState = FindState(host.Manager.Behaviors.Definitions[(ushort) children].Item1, targetStateName);
foreach (Entity i in host.GetNearestEntities(range, children))
if (!i.CurrentState.Is(targetState))
i.SwitchTo(targetState);
}
示例15: isValidPet
private bool isValidPet(Entity host, out Pet p)
{
p = null;
if (!(host is Pet)) return false;
var pet = (Pet)host;
if (PlayerOwnerRequired && pet.PlayerOwner == null) return false;
p = pet;
return true;
}