本文整理汇总了C#中Aura.Channel.World.Entities.Creature.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.SetPosition方法的具体用法?C# Creature.SetPosition怎么用?C# Creature.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Channel.World.Entities.Creature
的用法示例。
在下文中一共展示了Creature.SetPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public void Use(Creature creature, Skill skill, Packet packet)
{
var targetPos = new Position(packet.GetLong());
// Check distance to target position
if (!creature.GetPosition().InRange(targetPos, (int)skill.RankData.Var2 + DistanceBuffer))
{
Send.Notice(creature, Localization.Get("Out of range."));
Send.SkillUse(creature, skill.Info.Id, 0);
return;
}
// Stop creature's movement.
creature.StopMove();
// Teleport effect (does not actually teleport)
Send.Effect(creature, Effect.SilentMoveTeleport, (byte)2, targetPos.X, targetPos.Y);
// Teleport player to target position
creature.SetPosition(targetPos.X, targetPos.Y);
Send.SkillTeleport(creature, targetPos.X, targetPos.Y);
Send.SkillUse(creature, skill.Info.Id, 1);
}
示例2: Shove
/// <summary>
/// Sets new position for target, based on attacker's position
/// and the distance, takes collision into consideration.
/// </summary>
/// <param name="target">Entity to be knocked back</param>
/// <param name="distance">Distance to knock back the target</param>
/// <returns>New position</returns>
public Position Shove(Creature target, int distance)
{
var attackerPosition = this.GetPosition();
var targetPosition = target.GetPosition();
var newPos = attackerPosition.GetRelative(targetPosition, distance);
Position intersection;
if (target.Region.Collisions.Find(targetPosition, newPos, out intersection))
newPos = targetPosition.GetRelative(intersection, -50);
target.SetPosition(newPos.X, newPos.Y);
return newPos;
}
示例3: Use
/// <summary>
/// Handles skill usage.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var targetEntityId = packet.GetLong();
// Similar to WM there is a case where these aren't sent.
// Apparently this can happen if you activate the skill while
// targetting an enemy.
var unk1 = (packet.Peek() != PacketElementType.None ? packet.GetInt() : 0);
var unk2 = (packet.Peek() != PacketElementType.None ? packet.GetInt() : 0);
if (_cm == null)
_cm = ChannelServer.Instance.SkillManager.GetHandler<CombatMastery>(SkillId.CombatMastery);
// TODO: Check duration
var attackResult = false;
var target = creature.Region.GetCreature(targetEntityId);
if (target != null && !creature.IsStunned && creature.CanTarget(target))
{
var pos = creature.GetPosition();
var targetPos = target.GetPosition();
var inRange = pos.InRange(targetPos, creature.AttackRangeFor(target));
if (!inRange)
{
var telePos = pos.GetRelative(targetPos, -creature.AttackRangeFor(target) + 100);
// Check teleport distance
if (pos.GetDistance(telePos) > skill.RankData.Var3 + 100)
{
Send.Notice(creature, "Out of range");
}
else
{
Send.Effect(creature, Effect.SilentMoveTeleport, targetEntityId, (byte)0);
creature.SetPosition(telePos.X, telePos.Y);
Send.SkillTeleport(creature, telePos.X, telePos.Y);
inRange = true;
}
}
if (inRange)
attackResult = (_cm.Use(creature, skill, targetEntityId) == CombatSkillResult.Okay);
}
Send.CombatAttackR(creature, attackResult);
Send.SkillUse(creature, skill.Info.Id, targetEntityId, unk1, unk2);
}
示例4: WarpInside
/// <summary>
/// Door's behavior when it's not locked.
/// </summary>
/// <param name="creature"></param>
/// <param name="prop"></param>
private void WarpInside(Creature creature, Prop prop)
{
var creaturePos = creature.GetPosition();
var cCoord = new Position(creaturePos.X / Dungeon.TileSize, creaturePos.Y / Dungeon.TileSize);
if (cCoord == _closedFrom)
{
Send.Notice(creature, NoticeType.MiddleSystem, Localization.Get("There is a monster still standing.\nYou must defeat all the monsters for the door to open."));
return;
}
var x = _closedFrom.X * Dungeon.TileSize + Dungeon.TileSize / 2;
var y = _closedFrom.Y * Dungeon.TileSize + Dungeon.TileSize / 2;
if (cCoord.X < _closedFrom.X)
x -= 1000;
else if (cCoord.X > _closedFrom.X)
x += 1000;
else if (cCoord.Y < _closedFrom.Y)
y -= 1000;
else if (cCoord.Y > _closedFrom.Y)
y += 1000;
creature.SetPosition(x, y);
Send.SetLocation(creature, x, y);
}
示例5: Use
public void Use(Creature creature, Skill skill, long targetEntityId, int unk1, int unk2)
{
if (_cm == null)
_cm = ChannelServer.Instance.SkillManager.GetHandler<CombatMastery>(SkillId.CombatMastery);
var attackResult = false;
var target = creature.Region.GetCreature(targetEntityId);
if (target != null && !creature.IsStunned && !creature.IsOnAttackDelay && creature.CanTarget(target) && creature.CanAttack(target))
{
var pos = creature.GetPosition();
var targetPos = target.GetPosition();
var inRange = (pos.InRange(targetPos, creature.AttackRangeFor(target))
&& !creature.Region.Collisions.Any(pos, targetPos) // Check collisions between position
&& !target.Conditions.Has(ConditionsA.Invisible)); // Check visiblility (GM)
if (!inRange && !target.IsNotReadyToBeHit)
{
var telePos = pos.GetRelative(targetPos, -creature.AttackRangeFor(target) + 100);
// Check teleport distance
if (pos.GetDistance(telePos) > skill.RankData.Var3 + 100)
{
Send.Notice(creature, "Out of range");
}
else
{
Send.Effect(creature, Effect.SilentMoveTeleport, targetEntityId, (byte)0);
creature.SetPosition(telePos.X, telePos.Y);
Send.SkillTeleport(creature, telePos.X, telePos.Y);
inRange = true;
}
}
if (inRange)
attackResult = (_cm.Use(creature, skill, targetEntityId) == CombatSkillResult.Okay);
}
Send.CombatAttackR(creature, attackResult);
Send.SkillUse(creature, skill.Info.Id, targetEntityId, unk1, unk2);
}