Ejemplo n.º 1
0
            override internal void doSkill(Game game, double x, double y, int unitId)
            {
                Point  target   = new Point(x, y);
                double distance = hero.Distance(target);

                target.x = hero.x + (x - hero.x) / distance * range;
                target.y = hero.y + (y - hero.y) / distance * range;

                MovingEntity lineSpellUnit = new MovingEntity(hero.x, hero.y, (target.x - hero.x) / flyTime, (target.y - hero.y) / flyTime);

                double      lowestT         = 2;
                List <Hero> possibleTargets = new List <Hero>();

                for (int i = Const.game.allUnits.Count - 1; i >= 0; i--)
                {
                    Unit unit = Const.game.allUnits[i];
                    if (unit.team != hero.team && (unit is Hero))
                    {
                        double collisionT = unit.getCollisionTime(lineSpellUnit, radius);
                        possibleTargets.Add((Hero)unit);
                        if (collisionT >= 0 && collisionT <= lowestT)
                        {
                            lowestT = collisionT;
                        }
                    }
                }

                Const.game.events.Add(new WireEvent(possibleTargets, lowestT, lineSpellUnit, stun_time, hero, radius, duration, 0.5));
            }
Ejemplo n.º 2
0
 public WireEvent(List <Hero> potentialTargets, double t, MovingEntity movingSpell, int stun_time, Hero attacker, double radius, double duration, double dmgMultiplier) :
     base(null, t)
 {
     this.dmgMultiplier    = dmgMultiplier;
     this.attacker         = attacker;
     this.movingSpell      = movingSpell;
     this.stun_time        = stun_time;
     this.radius           = radius;
     this.duration         = duration;
     this.potentialTargets = potentialTargets;
 }
Ejemplo n.º 3
0
 public LineEffectEvent(Unit unit, double t, MovingEntity movingSpell, int damage, Hero attacker, double radius, double duration, int damageByTime)
     :
     base(unit, t)
 {
     this.attacker     = attacker;
     this.movingSpell  = movingSpell;
     this.damage       = damage;
     this.radius       = radius;
     this.duration     = duration;
     this.damageByTime = damageByTime;
 }
        public double getCollisionTime(MovingEntity entity, double radius)
        {
            // Check instant collision
            if (this.Distance(entity) <= radius)
            {
                return(0.0);
            }

            // Fixes rounding errors.
            radius -= Const.EPSILON;

            // Both units are motionless
            if (this.vx == 0.0 && this.vy == 0.0 && entity.vx == 0.0 && entity.vy == 0.0)
            {
                return(-1);
            }

            // Change referencial
            // Unit u is not at point (0, 0) with a speed vector of (0, 0)
            double x2  = this.x - entity.x;
            double y2  = this.y - entity.y;
            double r2  = radius;
            double vx2 = this.vx - entity.vx;
            double vy2 = this.vy - entity.vy;

            double a = vx2 * vx2 + vy2 * vy2;

            if (a <= 0.0)
            {
                return(-1);
            }

            double b     = 2.0 * (x2 * vx2 + y2 * vy2);
            double c     = x2 * x2 + y2 * y2 - r2 * r2;
            double delta = b * b - 4.0 * a * c;

            if (delta < 0.0)
            {
                return(-1);
            }

            double t = (-b - Math.Sqrt(delta)) / (2.0 * a);

            if (t <= 0.0)
            {
                return(-1);
            }

            return(t);
        }
Ejemplo n.º 5
0
            override internal void doSkill(Game game, double x, double y, int unitId)
            {
                Point  target   = new Point(x, y);
                double distance = hero.Distance(target);
                double vx       = (x - hero.x) / distance;
                double vy       = (y - hero.y) / distance;

                target.x = hero.x + vx * range;
                target.y = hero.y + vy * range;

                MovingEntity lineSpellUnit = new MovingEntity(hero.x, hero.y, vx * range / duration, vy * range / duration);

                foreach (Unit unit in Const.game.allUnits)
                {
                    if (unit.team != hero.team && (unit is Hero || unit is Creature))
                    {
                        double collisionT = unit.getCollisionTime(lineSpellUnit, radius - Const.EPSILON);
                        Const.game.events.Add(new LineEffectEvent(unit, collisionT < 0 ? duration : collisionT, lineSpellUnit, (int)(0.2 * (hero.mana + manaCost)), hero, radius, duration, 55));
                    }
                }
            }