Exemplo n.º 1
0
        protected void AddTargetedProjectile(string name, AttackableUnit target, bool serverOnly = false)
        {
            var record         = SpellRecord.GetSpell(name);
            var position       = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var casterPosition = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var angle          = Geo.GetAngle(Owner.Position, target.Position);
            var direction      = Geo.GetDirection(angle);
            var velocity       = new Vector3(1, 1, 1) * 100;
            var startPoint     = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var endPoint       = new Vector3(target.Position.X, target.Position.Y, 100);


            var targetedProjectile = new TargetedProjectile(Owner.Game.NetIdProvider.PopNextNetId(),
                                                            Owner, target, startPoint.ToVector2(), SpellRecord.MissileSpeed, OnProjectileReach);

            Owner.Game.AddUnitToTeam(targetedProjectile, Owner.Team.Id);
            Owner.Game.Map.AddUnit(targetedProjectile);

            if (!serverOnly)
            {
                var castInfo = Spell.GetCastInformations(position, endPoint, name, targetedProjectile.NetId, new AttackableUnit[] { target });

                Owner.Game.Send(new SpawnProjectileMessage(targetedProjectile.NetId, position, casterPosition,
                                                           direction.ToVector3(), velocity, startPoint, endPoint, casterPosition,
                                                           0, record.MissileSpeed, 1f, 1f, 1f, false, castInfo));
            }
        }
Exemplo n.º 2
0
        protected void AddSkillShot(string name, Vector2 toPosition, Vector2 endPosition, float range, bool serverOnly = false)
        {
            var record         = SpellRecord.GetSpell(name);
            var position       = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var casterPosition = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var angle          = Geo.GetAngle(Owner.Position, endPosition);
            var direction      = Geo.GetDirection(angle);
            var velocity       = new Vector3(1, 1, 1) * 100;
            var startPoint     = new Vector3(Owner.Position.X, Owner.Position.Y, 100);
            var endPoint       = new Vector3(endPosition.X, endPosition.Y, 100);


            var skillShot = new SkillShot(Owner.Game.NetIdProvider.PopNextNetId(),
                                          Owner, position.ToVector2(), record.MissileSpeed, record.LineWidth,
                                          OnProjectileReach, direction, range, OnSkillShotRangeReached);


            Owner.Game.AddUnitToTeam(skillShot, Owner.Team.Id);
            Owner.Game.Map.AddUnit(skillShot);

            if (!serverOnly)
            {
                var castInfo = Spell.GetCastInformations(position, endPoint, name, skillShot.NetId);

                Owner.Game.Send(new SpawnProjectileMessage(skillShot.NetId, position, casterPosition,
                                                           direction.ToVector3(), velocity, startPoint, endPoint, casterPosition,
                                                           0, record.MissileSpeed, 1f, 1f, 1f, false, castInfo));
            }
        }