Beispiel #1
0
        void CastSpell(LinearSpell spell, Vec2 target)
        {
            Match.CurrentState.AddEntity(spell);
            ActiveSpells.Add(spell);

            float       castTime = (float)Server.Instance.GetTime().TotalSeconds;
            LinearSpell copy     = (LinearSpell)spell.Clone();

            AddRemarkableEvent(ServerCommand.SpellCast,
                               (NetBuffer msg) => {
                ulong id    = copy.ID;
                ulong owner = copy.Owner != null ? copy.Owner.ID : IDGenerator.NO_ID;
                byte type   = (byte)copy.Type;
                float time  = castTime;
                float px    = copy.Position.X;
                float py    = copy.Position.Y;
                float vx    = copy.Velocity.X;
                float vy    = copy.Velocity.Y;
                float cd    = (float)copy.Info.Cooldown.TotalSeconds;
                float range = copy.Info.Range;
                float width = copy.CollisionWidth;

                msg.Write(id);
                msg.Write(owner);
                msg.Write(type);
                msg.Write(time);
                msg.Write(px);
                msg.Write(py);
                msg.Write(vx);
                msg.Write(vy);
                msg.Write(cd);
                msg.Write(range);
                msg.Write(width);
            });
        }
Beispiel #2
0
        private static void SpellsDetector_OnSkillShotDetected(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args, Database.SkillShotSpells.SSpell spell, Vector3 Start, Vector3 End, float Range, float Width, MissileClient missile)
        {
            var caster = sender as AIHeroClient;

            if (caster == null)
            {
                return;
            }
            var spellrange = Range;
            var endpos     = spell.IsFixedRange ? Start.Extend(End, spellrange).To3D() : End;

            if (spell.type == Database.SkillShotSpells.Type.CircleMissile && End.Distance(Start) < Range)
            {
                endpos = End;
            }

            var newactive = new ActiveSpells
            {
                Start = Start, End = endpos, Range = spellrange, Width = Width, spell = spell, EndTime = (endpos.Distance(Start) / spell.Speed) + (spell.CastDelay / 1000) + Game.Time, Caster = caster, Missile = missile, ArriveTime = (Start.Distance(Player.Instance) / spell.Speed) - (spell.CastDelay / 1000)
            };

            if (!DetectedSpells.Contains(newactive))
            {
                DetectedSpells.Add(newactive);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Attacks the specified player.
        /// </summary>
        /// <param name="other">The other player to attack with this player.</param>
        /// <param name="output">A delegate to a method to use to output messages.</param>
        public override void Attack(Player other, Action <string, object[]>?output)
        {
            var availableSpells = SpellInfo.Spells
                                  .Where((p) => p.Value.Cost <= Mana)
                                  .Where((p) => !ActiveSpells.Contains(p.Key))
                                  .ToList();

            if (availableSpells.Count < 1)
            {
                HitPoints = 0;
                return;
            }

            // Determine which spell the wizard should cast
            string spellToConjure = _spellSelector(this, availableSpells.Select((p) => p.Key).ToList());

            // Get the spell
            SpellInfo info = availableSpells
                             .Where((p) => string.Equals(spellToConjure, p.Key, StringComparison.Ordinal))
                             .Select((p) => p.Value)
                             .Single();

            // Conjure the new spell and then cast it
            Conjure(info).Cast(this, other, output);
        }
Beispiel #4
0
        void UpdateSpells(double dt)
        {
            var toRemove = new List <LinearSpell>();

            ActiveSpells.ForEach(s =>
            {
                Vec2 before = (Vec2)s.Position.Clone();
                Match.CurrentState.ApplyPhysicsUpdate(s.ID, (float)dt);
                Vec2 pass = (s.Position - before) / PhysicsEngine.PHYSICS_PASSES;

                s.Position = before;
                for (int i = 0; i < PhysicsEngine.PHYSICS_PASSES; ++i)
                {
                    // Check for entities collisions
                    var rect      = s.CreateCollisionRectangle();
                    var enemyTeam = TeamsHelper.Opposite(s.Team);

                    // Check to hit players
                    bool remove = CheckForSpellPlayerCollisions(s, rect, enemyTeam);

                    // Check to hit structures
                    if (!remove)
                    {
                        remove = CheckForSpellStructuresCollisions(s, rect,
                                                                   enemyTeam == Teams.Left ? Match.LeftStructures : Match.RightStructures);
                    }

                    // Check to remove spells
                    if (!remove &&                     // don't check if we know it already has to be removed
                        Match.CurrentState.SpellShouldDisappear(s))
                    {
                        remove = true;
                    }

                    // The spell has to be removed
                    if (remove)
                    {
                        toRemove.Add(s);
                        break;
                    }
                    s.Position += pass;
                }
            });

            toRemove.ForEach(s =>
            {
                ActiveSpells.Remove(s);
                RemarkableEvents.Add(Utilities.MakePair <ServerCommand, Action <NetBuffer> >(
                                         ServerCommand.SpellDisappear,
                                         (msg) =>
                {
                    ulong id = s.ID;
                    msg.Write(id);
                }));
            });
        }
Beispiel #5
0
		public SpellIcon(ActiveSpells parent, SpellRecord data, int slot)
			: base(parent, slot)
		{
			_spellData = data;
			_spellGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.SpellIcons, _spellData.Icon);
			_spellGraphicSourceRect = new Rectangle(0, 0, _spellGraphic.Width / 2, _spellGraphic.Height);

			_spellLevelColor = new Texture2D(Game.GraphicsDevice, 1, 1);
			_spellLevelColor.SetData(new[] {Color.FromNonPremultiplied(0xc9, 0xb8, 0x9b, 0xff)});
			OnLevelChanged();

			_clickTime = DateTime.Now;
		}
		public EmptySpellIcon(ActiveSpells parent, int slot)
			: base(null, null, parent)
		{
			Slot = slot;
			_parentSpellContainer = parent;

			_highlightColor = new Texture2D(Game.GraphicsDevice, 1, 1);
			_highlightColor.SetData(new[] { Color.FromNonPremultiplied(200, 200, 200, 60) });

			_setSize(ICON_AREA_WIDTH, ICON_AREA_HEIGHT);

			World.IgnoreDialogs(this);
		}
 public static Geometry.Polygon ToPolygon(this ActiveSpells spell)
 {
     if (spell.spell.type == Database.SkillShotSpells.Type.LineMissile)
     {
         return(new Geometry.Polygon.Rectangle(spell.Start, spell.End, spell.Width));
     }
     if (spell.spell.type == Database.SkillShotSpells.Type.CircleMissile)
     {
         return(new Geometry.Polygon.Circle(spell.End, spell.Width));
     }
     if (spell.spell.type == Database.SkillShotSpells.Type.Cone)
     {
         return(CreateCone(spell.Start, spell.End, spell.spell.Angle, spell.Range));
     }
     return(new Geometry.Polygon());
 }
Beispiel #8
0
        public static bool IsInDanger(this Obj_AI_Base target, ActiveSpells spell)
        {
            if (spell.spell.Speed > 90000)
            {
                return(spell.ToPolygon().IsInside(target.PrediectPosition((int)spell.spell.CastDelay)));
            }

            if (spell.Missile != null)
            {
                var arrivetime = spell.Missile.Distance(target) / spell.spell.Speed * 1000;
                return(spell.ToPolygon().IsInside(target.PrediectPosition((int)arrivetime)));
            }

            var arrivetime2 = spell.Start.Distance(target) / spell.spell.Speed * 1000 + spell.spell.CastDelay;

            return(spell.ToPolygon().IsInside(target.PrediectPosition((int)arrivetime2)));
        }
        public static bool IsInDanger(this Obj_AI_Base target, ActiveSpells spell)
        {
            var HitBox = new Geometry.Polygon.Circle(target.ServerPosition, target.BoundingRadius + 10);

            return(HitBox.Points.Any(p => spell.ToPolygon().IsInside(p)));
        }
Beispiel #10
0
 public static bool IsInDanger(this Obj_AI_Base target, ActiveSpells spell)
 {
     return(spell.ToPolygon().IsInside(target));
 }
Beispiel #11
0
        public static bool IsInDanger(this Obj_AI_Base target, ActiveSpells spell)
        {
            var traveltime = target.Distance(spell.Start) / spell.spell.Speed * 1000 + spell.spell.CastDelay;

            return(spell.ToPolygon().IsInside(target.PrediectPosition((int)traveltime)));
        }