本文整理汇总了C#中wServer.realm.RealmTime类的典型用法代码示例。如果您正苦于以下问题:C# RealmTime类的具体用法?C# RealmTime怎么用?C# RealmTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealmTime类属于wServer.realm命名空间,在下文中一共展示了RealmTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: TickCore
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) return true;
var speed = this.speed * GetSpeedMultiplier(Host.Self);
WanderingState state;
object o;
if (!Host.StateStorage.TryGetValue(Key, out o))
Host.StateStorage[Key] = state = new WanderingState();
else
{
state = (WanderingState)o;
var dist = speed / 1.5f * (time.thisTickTimes / 1000f);
state.remainingDist -= dist;
ValidateAndMove(Host.Self.X + state.x * dist, Host.Self.Y + state.y * dist);
Host.Self.UpdateCount++;
}
bool ret;
if (state.remainingDist <= 0)
{
state.x = rand.Next(-1, 2);
state.y = rand.Next(-1, 2);
state.remainingDist = dist + dist * (float)(rand.NextDouble() * 0.1 - 0.05);
ret = true;
}
else
ret = false;
return ret;
}
示例3: 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;
}
示例4: 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(ConditionEffects.Paralyzed)) return;
var 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;
}
示例5: TickCore
protected override bool TickCore(RealmTime time)
{
var radius = dist;
var entity = GetNearestEntityPet(ref radius) as Enemy;
if (entity != null)
{
entity.Owner.BroadcastPacket(new ShowEffectPacket
{
EffectType = EffectType.AreaBlast,
Color = new ARGB(0x3E3A78),
TargetId = entity.Id,
PosA = new Position { X = 1 }
}, null);
entity.Owner.BroadcastPacket(new ShowEffectPacket
{
EffectType = EffectType.Trail,
TargetId = Host.Self.Id,
PosA = new Position { X = entity.X, Y = entity.Y },
Color = new ARGB(0x3E3A78)
}, null);
entity.Damage(Host.Self.PlayerOwner, time, 35, false);
}
return false;
}
示例6: TickCore
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) return true;
var speed = this.speed*GetSpeedMultiplier(Host.Self);
var dist = radius;
var entity = GetNearestEntity(ref dist, objType);
if (entity != null && dist > targetRadius)
{
var tx = entity.X + rand.Next(-2, 2)/2f;
var ty = entity.Y + rand.Next(-2, 2)/2f;
if (tx != Host.Self.X || ty != Host.Self.Y)
{
var x = Host.Self.X;
var y = Host.Self.Y;
var vect = new Vector2(tx, ty) - new Vector2(Host.Self.X, Host.Self.Y);
vect.Normalize();
vect *= (speed/1.5f)*(time.thisTickTimes/1000f);
ValidateAndMove(Host.Self.X + vect.X, Host.Self.Y + vect.Y);
Host.Self.UpdateCount++;
}
return true;
}
return false;
}
示例7: TickCore
protected override bool TickCore(RealmTime time)
{
float dist = 8;
var entity = GetNearestEntityByGroup(ref dist, "Golem");
if (entity != null && dist > 4)
{
ValidateAndMove(entity.X, entity.Y);
Host.StateStorage[Key] = 30*1000;
return true;
}
if (entity == null)
{
int remainingTick;
object obj;
if (!Host.StateStorage.TryGetValue(Key, out obj))
remainingTick = 30*1000;
else
remainingTick = (int) obj;
remainingTick -= time.thisTickTimes;
if (remainingTick <= 0)
Host.Self.Owner.LeaveWorld(Host.Self);
Host.StateStorage[Key] = remainingTick;
return false;
}
Host.StateStorage[Key] = 30*1000;
return true;
}
示例8: TickCore
protected override void TickCore(Entity host, RealmTime time, ref object state)
{
BuzzStorage 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;
}
示例9: TickCore
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Stunned)) return false;
var chr = Host as Character;
var startAngle = angle - projAngle * (numShot - 1) / 2;
var desc = chr.ObjectDesc.Projectiles[projectileIndex];
byte prjId = 0;
Position prjPos = new Position() { X = chr.X, Y = chr.Y };
var dmg = chr.Random.Next(desc.MinDamage, desc.MaxDamage);
for (int i = 0; i < numShot; i++)
{
var prj = chr.CreateProjectile(
desc, chr.ObjectType, dmg, time.tickTimes,
prjPos, (float)(startAngle + projAngle * i));
chr.Owner.EnterWorld(prj);
if (i == 0)
prjId = prj.ProjectileId;
}
chr.Owner.BroadcastPacket(new MultiShootPacket()
{
BulletId = prjId,
OwnerId = Host.Self.Id,
BulletType = (byte)desc.BulletType,
Position = prjPos,
Angle = (float)startAngle,
Damage = (short)dmg,
NumShots = (byte)numShot,
AngleIncrement = (float)projAngle,
}, null);
return true;
}
示例10: BehaveCore
protected override void BehaveCore(BehaviorCondition cond, RealmTime? time, object state)
{
if (Host.Self.Owner.Name != "Battle Arena" && Host.Self.Owner.Name != "Free Battle Arena")
{
if (new Random().Next(1, 100) <= percent)
{
var entity = Entity.Resolve(objType) as Portal;
var parent = Host as Entity;
entity.Move(parent.X, parent.Y);
parent.Owner.EnterWorld(entity);
var w = RealmManager.GetWorld(Host.Self.Owner.Id);
w.Timers.Add(new WorldTimer(timeExist*1000, (world, t) =>
{
if (timeExist > 0)
try
{
w.LeaveWorld(entity);
}
catch
{
}
}));
}
}
}
示例11: TickCore
protected override bool TickCore(RealmTime time)
{
var chr = Host as Character;
var target = new Position
{
X = Host.Self.X,
Y = Host.Self.Y
};
target.X += (float) Math.Cos(angle)*range;
target.Y += (float) Math.Sin(angle)*range;
chr.Owner.BroadcastPacket(new ShowEffectPacket
{
TargetId = Host.Self.Id,
PosA = target
}, null);
chr.Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
{
var entity = Entity.Resolve(objType);
entity.Move(target.X, target.Y);
(entity as Enemy).Terrain = (chr as Enemy).Terrain;
world.EnterWorld(entity);
}));
return true;
}
示例12: TickCore
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) return true;
var speed = this.speed * GetSpeedMultiplier(Host.Self);
float dist = radius;
Entity entity = GetNearestEntity(ref dist, objType);
Character chr = Host as Character;
if (entity != null && chr.HP < threshold)
{
var x = Host.Self.X;
var y = Host.Self.Y;
Vector2 vect = new Vector2(entity.X, entity.Y) - new Vector2(Host.Self.X, Host.Self.Y);
vect.Normalize();
vect *= -1 * (speed / 1.5f) * (time.thisTickTimes / 1000f);
ValidateAndMove(Host.Self.X + vect.X, Host.Self.Y + vect.Y);
Host.Self.UpdateCount++;
if (!Host.StateStorage.ContainsKey(Key))
{
chr.Owner.BroadcastPacket(new ShowEffectPacket()
{
EffectType = EffectType.Flashing,
PosA = new Position() { X = 1, Y = 1000000 },
TargetId = chr.Id,
Color = new ARGB(0xff303030)
}, null);
Host.StateStorage[Key] = true;
}
return true;
}
else return false;
}
示例13: TickCore
protected override bool TickCore(RealmTime time)
{
int remainingTick;
object o;
if (!Host.StateStorage.TryGetValue(Key, out o))
remainingTick = 0;
else
remainingTick = (int)o;
remainingTick -= time.thisTickTimes;
bool ret;
if (remainingTick <= 0)
{
if (CountEntity(radius, objType) < maxCount)
{
Entity entity = Entity.Resolve(objType);
entity.Move(Host.Self.X, Host.Self.Y);
(entity as Enemy).Terrain = (Host as Enemy).Terrain;
Host.Self.Owner.EnterWorld(entity);
}
remainingTick = rand.Next(minTick, maxTick);
ret = true;
}
else
ret = false;
Host.StateStorage[Key] = remainingTick;
return ret;
}
示例14: 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);
}
示例15: TickCore
protected override bool TickCore(RealmTime time)
{
if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) return true;
var speed = this.speed * GetSpeedMultiplier(Host.Self);
float d;
object o;
if (!Host.StateStorage.TryGetValue(Key, out o))
Host.StateStorage[Key] = d = dist;
else
{
d = (float)o;
float dd = (speed / 1.5f) * (time.thisTickTimes / 1000f);
d -= dd;
ValidateAndMove(Host.Self.X + (float)Math.Cos(angle) * dd, Host.Self.Y + (float)Math.Sin(angle) * dd);
Host.Self.UpdateCount++;
}
bool ret;
if (d <= 0)
{
d = dist;
ret = true;
}
else
ret = false;
Host.StateStorage[Key] = d;
return ret;
}