예제 #1
0
        public static void ActivateKnockBack(UnitAbility ability, Unit unit, Unit vs, Battlefield battlefield, List <Unit> enemies)
        {
            //List<Unit> Targets = battlefield.Units.Where(x => Vector2.Distance(unit.RealPos, x.RealPos) < ability.Radius).ToList();
            List <Unit> Targets = enemies.Where(x => Vector2.Distance(unit.RealPos, x.RealPos) <= ability.Radius).ToList();

            foreach (Unit ent in Targets)
            {
                if (ent.Attributes.Contains(UnitAttributes.Massive))
                {
                    continue;
                }
                lock (ent)
                {
                    ent.Target = null;

                    Vector2 BlinkDirection = MoveService.RotatePoint(unit.RealPos, ent.RealPos, 180);
                    //float distance = Vector2.Distance(unit.RealPos, BlinkDirection);
                    //float t = 1 / distance;
                    float   t        = 1;
                    Vector2 BlinkPos = new Vector2();
                    BlinkPos.X  = (1 - t) * ent.RealPos.X + t * BlinkDirection.X;
                    BlinkPos.Y  = (1 - t) * ent.RealPos.Y + t * BlinkDirection.Y;
                    ent.RealPos = BlinkPos;
                    ent.RelPos  = MoveService.GetRelPos(ent.RealPos);
                    ent.Path.Remove(ent.Path.Last());
                    ent.Path.Add(new KeyValuePair <float, float>(ent.RelPos.Key, ent.RelPos.Value));
                }
            }
        }
예제 #2
0
        public static void ActivateBlink(UnitAbility ability, Unit unit, Unit vs, Battlefield battlefield, List <Unit> enemies)
        {
            if (unit.Shieldbar + unit.Healthbar < (unit.Shieldpoints + unit.Healthpoints) / 3)
            {
                ability.isActive = true;
                unit.Target      = null;
                vs.Target        = null;

                Vector2 BlinkDirection = MoveService.RotatePoint(vs.RealPos, unit.RealPos, 180);

                float d = Vector2.Distance(unit.RealPos, vs.RealPos);
                if (d < 0)
                {
                    d *= -1;
                }
                float t = 1;
                if (d > 0)
                {
                    t = (8 / 2) / d;
                    //if (t > 1)
                    //    t = 1;
                }

                Vector2 BlinkPos = new Vector2();
                BlinkPos.X = (1 - t) * unit.RealPos.X + t * BlinkDirection.X;
                BlinkPos.Y = (1 - t) * unit.RealPos.Y + t * BlinkDirection.Y;

                unit.RealPos = BlinkPos;
                unit.RelPos  = MoveService.GetRelPos(unit.RealPos);
            }
        }