Exemplo n.º 1
0
 public static MabiPacket SpawnEffect(MabiEntity entity, SpawnEffect type)
 {
     return SpawnEffect(entity, type, entity.GetPosition());
 }
Exemplo n.º 2
0
        /// <summary>
        /// Lets the creature face the target.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static MabiPacket TurnTo(MabiEntity creature, MabiEntity target)
        {
            var cpos = creature.GetPosition();
            var tpos = target.GetPosition();

            var p = new MabiPacket(Op.TurnTo, creature.Id);
            p.PutFloat((float)tpos.X - (float)cpos.X);
            p.PutFloat((float)tpos.Y - (float)cpos.Y);

            return p;
        }
Exemplo n.º 3
0
        protected IEnumerable Circle(MabiEntity center, bool clockwise, int radius, bool wait)
        {
            var centerPos = center.GetPosition();
            var myPos = this.Creature.GetPosition();

            var deltaX = (double)myPos.X - (double)centerPos.X;
            var deltaY = (double)myPos.Y - (double)centerPos.Y;

            var angle = Math.Atan2(deltaY, deltaX);

            angle += (clockwise ? -1 : 1) * rnd.NextDouble() * (Math.PI / 6);

            var x = (int)(Math.Cos(angle) * radius);
            var y = (int)(Math.Sin(angle) * radius);

            var dest = new MabiVertex(centerPos.X + x, centerPos.Y + y);

            foreach (var a in WalkTo(dest, wait))
                yield return a;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Calculates a position on the line between source and target.
 /// e.g. distance 0 would be the position of target, 100 would be
 /// 100 points farther away from source.
 /// </summary>
 public static MabiVertex CalculatePosOnLine(MabiEntity source, MabiEntity target, int distance)
 {
     return CalculatePosOnLine(source.GetPosition(), target.GetPosition(), distance);
 }
Exemplo n.º 5
0
 public List<MabiEntity> GetEntitiesInRange(MabiEntity entity, uint range = 0)
 {
     var pos = entity.GetPosition();
     return this.GetEntitiesInRange(entity.Region, pos.X, pos.Y, range);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Checks distance between the entity and the coordinates, does not check region.
 /// </summary>
 public static bool InRange(MabiEntity entity, uint x, uint y, uint range = 0)
 {
     var pos = entity.GetPosition();
     return InRange(pos.X, pos.Y, x, y, range);
 }
Exemplo n.º 7
0
 // Range and position calculations
 // ==================================================================
 /// <summary>
 /// Checks distance between the two entities, does not check region.
 /// </summary>
 public static bool InRange(MabiEntity c1, MabiEntity c2, uint range = 0)
 {
     return InRange(c1.GetPosition(), c2.GetPosition(), range);
 }