本文整理汇总了C#中Aura.World.World.MabiCreature.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MabiCreature.GetPosition方法的具体用法?C# MabiCreature.GetPosition怎么用?C# MabiCreature.GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.World.World.MabiCreature
的用法示例。
在下文中一共展示了MabiCreature.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIceSpearLOSChain
public List<MabiCreature> GetIceSpearLOSChain(MabiCreature attacker, MabiCreature target, uint range)
{
var aPos = attacker.GetPosition();
var tPos = target.GetPosition();
var minX = Math.Min(aPos.X, tPos.X) - range;
var maxX = Math.Max(aPos.X, tPos.X) + range;
var m = ((double)tPos.Y - aPos.Y) / ((double)tPos.X - aPos.X);
var bL = (double)aPos.Y - aPos.X * m - (range / 2);
var bH = bL + range;
var targets = WorldManager.Instance.GetCreaturesInRange(attacker, maxX - minX); // Rough filter
targets = targets.FindAll((c) =>
{
var pos = c.GetPosition();
return !c.IsDead && c.IsAttackableBy(attacker) && (minX < pos.X && pos.X < maxX) && ((m * pos.X + bL) < pos.Y && pos.Y < (m * pos.X + bH));
});
if (!targets.Contains(target))
targets.Add(target);
return targets;
}
示例2: OnCreatureKilled
public void OnCreatureKilled(MabiCreature victim, MabiCreature killer)
{
if((victim is MabiPC && players) || (victim is MabiNPC && npcs))
{
var pos = victim.GetPosition();
var prop = new MabiProp(50, victim.Region, pos.X, pos.Y, (float)Math.PI * 2 / 255 * victim.Direction);
if(!permanent)
prop.DisappearTime = DateTime.Now.AddMinutes(duration);
WorldManager.Instance.AddProp(prop);
}
}
示例3: Start
public override SkillResults Start(MabiCreature creature, MabiSkill skill)
{
creature.Activate(CreatureConditionB.Demigod);
creature.StopMove();
// Spawn eruption
{
var pos = creature.GetPosition();
var targets = WorldManager.Instance.GetAttackableCreaturesInRange(creature, EruptionRadius);
var cap = new CombatActionPack(creature, skill.Id);
var aAction = new AttackerAction(CombatActionType.SpecialHit, creature, skill.Id, SkillHelper.GetAreaTargetID(creature.Region, pos.X, pos.Y));
aAction.Options |= AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect;
cap.Add(aAction);
foreach (var target in targets)
{
target.StopMove();
// Officials use CM skill id.
var tAction = new TargetAction(CombatActionType.TakeHit, target, creature, skill.Id);
tAction.StunTime = EruptionStun;
tAction.Delay = 1000;
// Supposedly it's magic damage
tAction.Damage = creature.GetMagicDamage(null, EruptionDamage);
target.TakeDamage(tAction.Damage);
tAction.OldPosition = CombatHelper.KnockBack(target, creature, EruptionKnockBack);
if (target.IsDead)
tAction.Options |= TargetOptions.FinishingKnockDown;
cap.Add(tAction);
}
WorldManager.Instance.HandleCombatActionPack(cap);
}
Send.EffectDelayed(Effect.AwakeningOfLight1, 800, creature);
Send.EffectDelayed(Effect.AwakeningOfLight2, 800, creature);
Send.UseMotion(creature, 67, 3, false, false);
creature.StatRegens.Add(creature.Temp.DemiHpRegen = new MabiStatRegen(Stat.Life, skill.RankInfo.Var3, creature.LifeMax));
creature.StatRegens.Add(creature.Temp.DemiMpRegen = new MabiStatRegen(Stat.Mana, skill.RankInfo.Var4, creature.ManaMax));
creature.StatRegens.Add(creature.Temp.DemiStmRegen = new MabiStatRegen(Stat.Stamina, skill.RankInfo.Var5, creature.StaminaMax));
WorldManager.Instance.CreatureStatsUpdate(creature);
return SkillResults.Okay;
}
示例4: Start
public override SkillResults Start(MabiCreature creature, MabiSkill skill, MabiTags tags)
{
ulong chairOId = 0;
if (tags.Has("ITEMID"))
chairOId = (ulong)tags.Get("ITEMID");
if (chairOId > 0)
{
// Check item
var item = creature.GetItem(chairOId);
if (item != null && item.Type == ItemType.Misc)
{
// Get chair prop id
var propId = 0u;
var chairInfo = MabiData.ChairDb.Find(item.Info.Class);
if (chairInfo != null)
propId = (!creature.IsGiant ? chairInfo.PropId : chairInfo.GiantPropId);
var pos = creature.GetPosition();
// Effect
if (chairInfo.Effect != 0)
Send.Effect(chairInfo.Effect, creature, true);
// Chair prop
var prop = new MabiProp(propId, creature.Region, pos.X, pos.Y, MabiMath.DirToRad(creature.Direction));
prop.State = "stand";
WorldManager.Instance.AddProp(prop);
// Move char
Send.AssignChair(creature, prop.Id, 1);
// Update chair
prop.ExtraData = string.Format("<xml OWNER='{0}' SITCHAR='{0}'/>", creature.Id);
Send.PropUpdate(prop);
creature.Temp.CurrentChair = chairInfo;
creature.Temp.SittingProp = prop;
}
}
creature.State |= CreatureStates.SitDown;
Send.SitDown(creature);
SkillHelper.GiveSkillExp(creature, skill, 20);
return SkillResults.Okay;
}
示例5: Command_spawn
private CommandResult Command_spawn(WorldClient client, MabiCreature creature, string[] args, string msg)
{
if (args.Length < 2)
return CommandResult.WrongParameter;
uint raceId = 0;
if (!uint.TryParse(args[1], out raceId))
return CommandResult.Fail;
byte amount = 1;
if (args.Length > 2)
{
if (!byte.TryParse(args[2], out amount))
return CommandResult.Fail;
if (amount < 1)
amount = 1;
else if (amount > 100)
amount = 100;
}
uint radius = 300;
radius += (uint)(amount / 10 * 50);
WorldManager.Instance.SpawnCreature(raceId, amount, creature.Region, creature.GetPosition(), radius, true);
return CommandResult.Okay;
}
示例6: AddCreatureInfo
/// <summary>
/// Test. Combination of public and private creature data.
/// </summary>
/// <param name="packet"></param>
/// <param name="creature"></param>
/// <param name="type"></param>
public static void AddCreatureInfo(this MabiPacket packet, MabiCreature creature, CreaturePacketType type)
{
// Check for MabiPC for private data.
var character = creature as MabiPC;
if (type == CreaturePacketType.Private && character == null)
throw new Exception("MabiPC required for private creature packet.");
// Get incomplete quests only once, if we need them.
IEnumerable<MabiQuest> incompleteQuests = null;
int incompleteQuestsCount = 0;
if (type == CreaturePacketType.Private && character != null)
{
incompleteQuests = character.Quests.Values.Where(quest => quest.State < MabiQuestState.Complete);
incompleteQuestsCount = incompleteQuests.Count();
}
var loc = creature.GetPosition();
// Start
// --------------------------------------------------------------
packet.PutLong(creature.Id);
packet.PutByte((byte)type);
// Looks/Location
// --------------------------------------------------------------
packet.PutString(creature.Name);
packet.PutString(""); // Title
packet.PutString(""); // Eng Title
packet.PutInt(creature.Race);
packet.PutByte(creature.SkinColor);
packet.PutByte(creature.EyeType);
packet.PutByte(creature.EyeColor);
packet.PutByte(creature.Mouth);
packet.PutInt((uint)creature.State);
if (type == CreaturePacketType.Public)
{
packet.PutInt((uint)creature.StateEx);
// [180300, NA166 (18.09.2013)
{
packet.PutInt(0);
}
}
packet.PutFloat(creature.Height);
packet.PutFloat(creature.Weight);
packet.PutFloat(creature.Upper);
packet.PutFloat(creature.Lower);
packet.PutInt(creature.Region);
packet.PutInt(loc.X);
packet.PutInt(loc.Y);
packet.PutByte(creature.Direction);
packet.PutInt(creature.BattleState);
packet.PutByte((byte)creature.Inventory.WeaponSet);
packet.PutInt(creature.Color1);
packet.PutInt(creature.Color2);
packet.PutInt(creature.Color3);
// Stats
// --------------------------------------------------------------
packet.PutFloat(creature.CombatPower);
packet.PutString(creature.StandStyle);
if (type == CreaturePacketType.Private)
{
packet.PutFloat(creature.Life);
packet.PutFloat(creature.LifeInjured);
packet.PutFloat(creature.LifeMaxBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.LifeMaxMod));
packet.PutFloat(creature.Mana);
packet.PutFloat(creature.ManaMaxBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.ManaMaxMod));
packet.PutFloat(creature.Stamina);
packet.PutFloat(creature.StaminaMaxBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.StaminaMaxMod));
packet.PutFloat(creature.StaminaHunger);
packet.PutFloat(0.5f);
packet.PutShort(creature.Level);
packet.PutInt(creature.LevelTotal);
packet.PutShort(0); // Max Level
packet.PutShort(0); // Rebirthes
packet.PutShort(0);
packet.PutLong(MabiData.ExpDb.CalculateRemaining(creature.Level, creature.Experience) * 1000);
packet.PutShort(creature.Age);
packet.PutFloat(creature.StrBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.StrMod));
packet.PutFloat(creature.DexBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.DexMod));
packet.PutFloat(creature.IntBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.IntMod));
packet.PutFloat(creature.WillBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.WillMod));
packet.PutFloat(creature.LuckBaseTotal);
packet.PutFloat(creature.StatMods.GetMod(Stat.LuckMod));
//.........这里部分代码省略.........
示例7: Revived
/// <summary>
/// Sends revive notice to creature's client.
/// </summary>
/// <param name="creature"></param>
public static void Revived(MabiCreature creature)
{
var pos = creature.GetPosition();
var packet = new MabiPacket(Op.Revived, creature.Id);
packet.PutInt(1);
packet.PutInt(creature.Region);
packet.PutInt(pos.X);
packet.PutInt(pos.Y);
creature.Client.Send(packet);
}
示例8: EnterRegionPermission
/// <summary>
/// Sends enter region permission, which kinda makes the client warp.
/// </summary>
/// <param name="client"></param>
/// <param name="creature"></param>
/// <param name="permission"></param>
public static void EnterRegionPermission(WorldClient client, MabiCreature creature, bool permission = true)
{
var pos = creature.GetPosition();
var p = new MabiPacket(Op.EnterRegionPermission, Id.World);
p.PutLong(creature.Id);
p.PutByte(permission);
if (permission)
{
p.PutInt(creature.Region);
p.PutInt(pos.X);
p.PutInt(pos.Y);
}
client.Send(p);
}
示例9: KnockBack
/// <summary>
/// Calculates and sets new position for creature, and returns a copy
/// of the current coordinates, for later use.
/// </summary>
/// <param name="target">Creature to knock back</param>
/// <param name="attacker">Creature that attacked</param>
/// <param name="distance">Knock back distance</param>
/// <returns>Position of creature, before the knock back</returns>
public static MabiVertex KnockBack(MabiCreature target, MabiEntity attacker, int distance = 375)
{
var oldPos = target.GetPosition();
var pos = WorldManager.CalculatePosOnLine(attacker, target, distance);
// Check for collision, set new pos 200 points before the
// intersection, to prevent glitching through.
MabiVertex intersection;
if (WorldManager.Instance.FindCollision(attacker.Region, oldPos, pos, out intersection))
pos = WorldManager.CalculatePosOnLine(oldPos, intersection, -200);
target.SetPosition(pos.X, pos.Y);
return oldPos;
}
示例10: Command_jump
/// <summary>
/// Warps creature to the specified coordinates in the current region.
/// If coordinates are ommited, a random location will be used.
/// </summary>
private CommandResult Command_jump(WorldClient client, MabiCreature creature, string[] args, string msg)
{
var pos = creature.GetPosition();
uint region = creature.Region;
uint x = pos.X, y = pos.Y;
if (args.Length > 1 && !uint.TryParse(args[1], out x))
return CommandResult.WrongParameter;
if (args.Length > 2 && !uint.TryParse(args[2], out y))
return CommandResult.WrongParameter;
if (args.Length == 1)
{
// Random coordinates.
var rndc = MabiData.RegionInfoDb.RandomCoord(region);
x = rndc.X;
y = rndc.Y;
}
client.Warp(region, x, y);
return CommandResult.Okay;
}
示例11: Explode
protected void Explode(MabiCreature attacker, MabiCreature target, MabiSkill skill, MabiProp casterProp, float dmgModifier = 1f)
{
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.IcespearFreeze).PutByte(1).PutInt(0), SendTargets.Range, target); // Cancel freeze
var tPos = target.GetPosition();
var bombProp = new MabiProp(280, target.Region, tPos.X, tPos.Y, 0); //4
WorldManager.Instance.AddProp(bombProp);
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, bombProp.Id).PutInts(Effect.IcespearBoom, target.Region, tPos.X, tPos.Y), SendTargets.Range, bombProp);
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.Thunderbolt).PutByte(0), SendTargets.Range, target);
var sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, SkillHelper.GetAreaTargetID(target.Region, tPos.X, tPos.Y));
sAction.PropId = casterProp.Id;
sAction.Options = AttackerOptions.KnockBackHit1 | AttackerOptions.UseEffect;
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Id);
tAction.Options = TargetOptions.Result;
tAction.StunTime = target.Stun = 2000;
var rnd = RandomProvider.Get();
var damage = attacker.GetMagicDamage(attacker.RightHand, rnd.Next((int)skill.RankInfo.Var1, (int)skill.RankInfo.Var2 + 1)) * dmgModifier;
if (CombatHelper.TryAddCritical(target, ref damage, attacker.CriticalChanceAgainst(target)))
tAction.Options |= TargetOptions.Critical;
target.TakeDamage(tAction.Damage = damage);
// Knock down if dead
tAction.OldPosition = CombatHelper.KnockBack(target, bombProp);
if (target.IsDead)
{
tAction.Options |= TargetOptions.FinishingKnockDown;
}
else
{
tAction.Options |= TargetOptions.KnockDown;
CombatHelper.SetAggro(attacker, target);
}
var cap = new CombatActionPack(attacker, skill.Id);
cap.Add(sAction, tAction);
WorldManager.Instance.HandleCombatActionPack(cap);
sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, SkillHelper.GetAreaTargetID(target.Region, tPos.X, tPos.Y));
sAction.PropId = bombProp.Id;
sAction.Options = AttackerOptions.UseEffect;
cap = new CombatActionPack(attacker, skill.Id);
cap.Add(sAction);
WorldManager.Instance.HandleCombatActionPack(cap);
WorldManager.Instance.RemoveProp(bombProp);
}
示例12: UseCombat
public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
{
var itarget = WorldManager.Instance.GetCreatureById(targetId);
if (itarget == null)
return SkillResults.InvalidTarget;
if (!WorldManager.InRange(attacker, itarget, 2000))
return SkillResults.OutOfRange;
var targets = this.GetIceSpearLOSChain(attacker, itarget, (uint)skill.RankInfo.Var5);
foreach (var target in targets)
{
target.StopMove();
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, target.Id).PutInt(Effect.IcespearFreeze).PutByte(1).PutInt(13000), SendTargets.Range, target);
}
var aPos = attacker.GetPosition();
var casterProp = new MabiProp(280, attacker.Region, aPos.X, aPos.Y, 0); // 3
WorldManager.Instance.AddProp(casterProp);
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, attacker.Id).PutInt(Effect.UseMagic).PutString("icespear").PutByte(1).PutLong(targetId).PutShort((ushort)skill.Id), SendTargets.Range, attacker);
var charges = attacker.ActiveSkillStacks;
Send.SkillUse(attacker.Client, attacker, skill.Id, targetId);
SkillHelper.ClearStack(attacker, skill);
// End the spear
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, attacker.Id).PutInt(Effect.StackUpdate).PutString("icespear").PutBytes(0, 0), SendTargets.Range, attacker);
var sAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Id, targetId);
sAction.Options = AttackerOptions.Result;
var cap = new CombatActionPack(attacker, skill.Id);
cap.Add(sAction);
foreach (var target in targets)
{
var tAction = new TargetAction(CombatActionType.None, target, attacker, skill.Id);
cap.Add(tAction);
}
WorldManager.Instance.HandleCombatActionPack(cap);
SkillHelper.GiveSkillExp(attacker, skill, 20);
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
{
this.IcespearProcessing(attacker, skill, targets, casterProp, 3500, charges);
}));
t.Start();
return SkillResults.Okay;
}
示例13: WalkTo
/// <summary>
/// Broadcasts WalkTo. If to is null, the creature's position is used.
/// </summary>
/// <param name="wm"></param>
/// <param name="creature"></param>
public static void WalkTo(MabiCreature creature, MabiVertex to = null)
{
var pos = creature.GetPosition();
var p = new MabiPacket(Op.WalkTo, creature.Id);
p.PutInts(pos.X, pos.Y); // From
p.PutInts(pos.X, pos.Y); // To
p.PutBytes(1, 0);
WorldManager.Instance.Broadcast(p, SendTargets.Range, creature);
}
示例14: AddCreature
// Entity Management
// ==================================================================
/// <summary>
/// Adds a creature to the world, and raises the EnterRegion event.
/// </summary>
/// <param name="creature"></param>
public void AddCreature(MabiCreature creature)
{
lock (_creatures)
{
if (!_creatures.Contains(creature))
{
_creatures.Add(creature);
if (creature is MabiPC)
this.ActivateMobs(creature, creature.GetPosition(), creature.GetPosition());
}
}
if (creature.Client is WorldClient)
{
lock (_clients)
{
if (!_clients.Contains(creature.Client as WorldClient))
_clients.Add(creature.Client as WorldClient);
}
}
Send.EntityAppearsOthers(creature);
EventManager.EntityEvents.OnEntityEntersRegion(creature);
}
示例15: UseCombat
public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
{
var target = WorldManager.Instance.GetCreatureById(targetId);
if (target == null)
return SkillResults.InvalidTarget;
if (!WorldManager.InRange(attacker, target, 2000))
return SkillResults.OutOfRange;
if (attacker.ActiveSkillStacks != 5)
return SkillResults.Failure;
attacker.StopMove();
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, attacker.Id).PutInt(Effect.UseMagic).PutString("fireball").PutByte(1).PutLong(targetId).PutShort((ushort)skill.Id), SendTargets.Range, attacker);
WorldManager.Instance.Broadcast(PacketCreator.TurnTo(attacker, target).PutByte(1), SendTargets.Range, attacker);
var pos = target.GetPosition();
var bomb = new MabiProp(280, target.Region, pos.X, pos.Y, 1f);
WorldManager.Instance.AddProp(bomb);
var frompos = attacker.GetPosition();
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, bomb.Id).PutInts(Effect.FireballFly, bomb.Region).PutFloats(frompos.X, frompos.Y, pos.X, pos.Y).PutInt(4000).PutByte(0).PutInt((uint)skill.Id), SendTargets.Range, attacker);
Send.SkillUse(attacker.Client, attacker, skill.Id, UseStun, 1);
SkillHelper.ClearStack(attacker, skill);
// End the fire bolts
WorldManager.Instance.Broadcast(new MabiPacket(Op.Effect, attacker.Id).PutInt(Effect.StackUpdate).PutString("firebolt").PutBytes(0, 0), SendTargets.Range, attacker);
SkillHelper.GiveSkillExp(attacker, skill, 20);
var t = new Thread(new System.Threading.ThreadStart(() =>
{
this.FireballProcessing(attacker, skill, bomb, targetId);
}));
t.Start();
return SkillResults.Okay;
}