private void OnParticleEvent(Entity sender, ParticleEffectAddedEventArgs args)
        {
            if (Bool(args.ParticleEffect))
            {
                return;
            }

            if (sender.Name.Contains("npc_dota_neutral_"))
            {
                UpdateManager.BeginInvoke(
                    () =>
                {
                    var RawGameTime = Game.RawGameTime;

                    Pos.RemoveAll(
                        x =>
                        x.GetPos.Distance(args.ParticleEffect.GetControlPoint(0)) < 500);

                    Pos.Add(new Position(args.ParticleEffect.GetControlPoint(0)));

                    UpdateManager.BeginInvoke(
                        () =>
                    {
                        Pos.RemoveAll(
                            x =>
                            x.GetGameTime == RawGameTime);
                    },
                        Config.TimerItem.Value * 1000);
                },
                    20);
            }
        }
Exemple #2
0
        private void OnParticleEffectReleased(Entity sender, ParticleEffectReleasedEventArgs args)
        {
            var particleEffect = args.ParticleEffect;

            if (particleEffect.Owner == null || !particleEffect.IsValid || particleEffect.Owner.IsVisible)
            {
                return;
            }

            if (!particleEffect.Name.Contains("generic_hit_blood") || !sender.Name.Contains("npc_dota_neutral_") && !sender.Name.Contains("npc_dota_roshan"))
            {
                return;
            }

            Pos.RemoveAll(x => x.GetPos.Distance(particleEffect.GetControlPoint(0)) < 500);
            Pos.Add(new Position(particleEffect.GetControlPoint(0)));

            var rawGameTime = Game.RawGameTime;

            UpdateManager.BeginInvoke(
                () =>
            {
                Pos.RemoveAll(x => x.GetGameTime == rawGameTime);
            },
                Config.TimerItem.Value * 1000);
        }
        private void OnParticleEvent(Entity sender, ParticleEffectAddedEventArgs args)
        {
            if (args.ParticleEffect.Owner == null || !args.ParticleEffect.IsValid || args.ParticleEffect.Owner.IsVisible)
            {
                return;
            }

            if (!sender.Name.Contains("npc_dota_neutral_") || args.Name.Contains("generic_creep_sleep"))
            {
                return;
            }

            UpdateManager.BeginInvoke(
                () =>
            {
                var rawGameTime = Game.RawGameTime;

                Pos.RemoveAll(x => x.GetPos.Distance(args.ParticleEffect.GetControlPoint(0)) < 500);

                Pos.Add(new Position(args.ParticleEffect.GetControlPoint(0)));

                UpdateManager.BeginInvoke(
                    () =>
                {
                    Pos.RemoveAll(x => x.GetGameTime == rawGameTime);
                },
                    Config.TimerItem.Value * 1000);
            },
                20);
        }
Exemple #4
0
        public override void Update(float timeElapsed)
        {
            // calculate the combined force from each steering behavior in the vehicle's list
            Vector2D steeringForce = SB.Calculate();

            // acceleration = force / mass
            Vector2D acceleration = steeringForce.divide(Mass);

            // update velocity
            Velocity.Add(acceleration.Multiply(timeElapsed));

            // make sure vehicle does not exceed maximum velocity
            Velocity.truncate(MaxSpeed);

            // update the position
            Pos = Pos.Add(Velocity.Multiply(timeElapsed));

            // update the heading if velocity is greater than 0.
            if (Velocity.LengthSquared() > 0.001)
            {
                Heading = Velocity.Normalize();

                Side = Heading.Perpendicular();
            }
        }
        private void UpdatePosition(float timeElapsed, Vector2D steeringForce)
        {
            Vector2D acceleration = steeringForce.Divide(Mass);

            Velocity += acceleration * timeElapsed;
            Velocity.Truncate(MaxSpeed);
            //Velocity *= 2;
            //Pos.Add(Velocity.Multiply(timeElapsed));
            Pos.Add(Velocity * timeElapsed);
            Velocity *= 0.9;
            Pos.WrapAround(MyWorld.Width, MyWorld.Height);
        }
Exemple #6
0
        public const int STRENGTH = 50;  //  as 50 damage spell
        public MIHealBall(Unit caster, IPair destination) : base(80, caster)
        {
            radius_ = RADIUS;
            damage_ = -10;
            speed_  = 350;

            hurt_self_             = true;
            explode_enemy_         = false;
            explode_enemy_missile_ = false;

            Unit target = null;
            bool used = false;
            long min_distance = 0, temp_distance;

            foreach (Unit unit in Game.Unit_List)
            {
                if (unit == caster)
                {
                    continue;
                }
                if (used == false)
                {
                    used         = true;
                    target       = unit;
                    min_distance = (unit.Pos - Pos).LengthSquare();
                }
                else
                {
                    temp_distance = (unit.Pos - Pos).LengthSquare();
                    if (temp_distance < min_distance)
                    {
                        target       = unit;
                        min_distance = temp_distance;
                    }
                }
            }
            if (target != null)
            {
                destination.Clone(target.Pos);
            }

            IPair delta = destination - caster.Pos;

            move_vector_ = delta.Clone();
            move_vector_.ChangeLength(speed_);
            delta.ChangeLength(GameDef.UNIT_RADIUS * GameDef.PIXEL_SCALE);
            Pos.Clone(caster.Pos);
            Pos.Add(delta);
        }
Exemple #7
0
        public const int STRENGTH = 60;  //  as 50 damage spell
        public MIGravity(Unit caster, IPair destination) : base(80, caster)
        {
            radius_ = RADIUS;
            damage_ = 0;
            speed_  = 450;

            hurt_self_             = false;
            explode_enemy_         = false;
            explode_enemy_missile_ = false;

            IPair delta = destination - caster.Pos;

            move_vector_ = delta.Clone();
            move_vector_.ChangeLength(speed_);
            delta.ChangeLength(GameDef.UNIT_RADIUS * GameDef.PIXEL_SCALE);
            Pos.Clone(caster.Pos);
            Pos.Add(delta);
        }
Exemple #8
0
        public MIFireBall(Unit caster, IPair destination) : base(66, caster)
        {
            radius_ = RADIUS;
            damage_ = 700;
            speed_  = 900;  //  x100

            hurt_self_             = false;
            explode_enemy_         = true;
            explode_enemy_missile_ = true;

            IPair delta = destination - caster.Pos;

            move_vector_ = delta.Clone();
            move_vector_.ChangeLength(speed_);
            delta.ChangeLength(GameDef.UNIT_RADIUS * GameDef.PIXEL_SCALE);
            Pos.Clone(caster.Pos);
            Pos.Add(delta);
        }
Exemple #9
0
        public override void Update(float timeElapsed)
        {
            Console.WriteLine(ToString());
            Vector2D totalVector = new Vector2D();

            foreach (SteeringBehaviour steeringBehaviour in steeringBehaviours)
            {
                Vector2D steeringBehaviourVector = steeringBehaviour.Calculate();

                totalVector.Add(steeringBehaviourVector);
            }
            // Acceleratie toevoegen op basis van Mass
            if (totalVector.Length() != 0)
            {
                totalVector = totalVector.Normalize();
                Vector2D acceleration = totalVector.Divide(Mass).Multiply(MaxSpeed);

                Velocity.Add(acceleration.Multiply(timeElapsed));
                Velocity.Truncate(MaxSpeed);
                Pos.Add(Velocity);
            }
        }
        public override void Update(float timeElapsed)
        {
            // Calculate the combined force from each steering behaviour.
            Vector2D steeringForce = SB.Calculate();

            // Acceleration = Force / Mass (Newton's laws of physics).
            Vector2D acceleration = steeringForce.Clone().divide(Mass);

            // Update velocity.
            Velocity.Add(acceleration.Clone().Multiply(timeElapsed));

            // Make sure the moving entity does not exceed maximum speed.
            Velocity.Truncate(MaxSpeed);

            // Update position.
            Pos.Add(Velocity.Clone().Multiply(timeElapsed));

            // Update heading if the velocity is bigger than 0
            if (Velocity.LengthSquared() > 0)
            {
                Heading = Velocity.Clone().Normalize();
            }
        }
Exemple #11
0
    // Returns the position of the world point relative to the chunk position (can be negative).
    public static Pos GetRelativePos(Pos chunk, Pos world)
    {
        Pos chunkWorld = GetChunkInWorld(chunk);

        return(world.Add(chunkWorld.Negate()));
    }
 public override void Update()
 {
     Pos.Clone(unit_.Pos);
     Pos.Add(offset_);
     base.Update();
 }
Exemple #13
0
    public string Solve()
    {
        int r, c;

        string[] ss = Console.ReadLine().Split(' ');
        r = int.Parse(ss[0]);
        c = int.Parse(ss[1]);

        bool[,] map = new bool[r + 2, c + 2];
        Pos start = new Pos();
        Pos stop  = new Pos();

        for (int i = 0; i < r; ++i)
        {
            string s = Console.ReadLine();
            for (int j = 0; j < c; ++j)
            {
                map[i + 1, j + 1] = s[j] != '#';

                if (s[j] == 'o' || s[j] == 'w')
                {
                    start.Add(i + 1, j + 1);
                }
                if (s[j] == 'x' || s[j] == 'w')
                {
                    stop.Add(i + 1, j + 1);
                }
            }
        }

        start.Finish();
        stop.Finish();

        Dictionary <Pos, bool> bol = new Dictionary <Pos, bool> ();
        List <Pos>             now = new List <Pos> ();

        now.Add(start);
        bol[start] = true;

        int cnt = 0;

        while (!bol.ContainsKey(stop) && now.Count > 0)
        {
            ++cnt;
            List <Pos> next = new List <Pos> ();

            foreach (Pos pos in now)
            {
                foreach (Pos pos2 in pos.Gen(map))
                {
                    if (!bol.ContainsKey(pos2))
                    {
                        bol[pos2] = true;
                        next.Add(pos2);
                    }
                }
            }

            now = next;
        }

        if (now.Count == 0)
        {
            return("-1");
        }

        return(cnt.ToString());
    }