public AreaOfEffectProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, Vector2 destination, int lifetime)
     : base(world, source, target, eventType, triggerEvents)
 {
     _position = destination;
     _destination = destination;
     _lifetime = lifetime;
 }
        public ConeProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, Vector2 destination, double angleSpread)
            : base(world, source, target, eventType, triggerEvents, liveDistance, startingPosition, destination)
        {
            this._destination = destination;

            double spread = RandomGenerator.Random.NextDouble() * (angleSpread);
            Velocity = new Vector2((float)Math.Cos(_angle ) * 2 + (float)spread, (float)Math.Sin(_angle) * 2 + (float)spread);
        }
示例#3
0
 public Projectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents)
     : base(world)
 {
     _source = source;
     _eventType = eventType;
     _triggerEvents = triggerEvents;
     _damagedOnce = false;
     _target = target;
     _damageAmount = 5;
 }
        public LinearProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, double angle)
            : base(world, source, target, eventType, triggerEvents)
        {
            _liveDistance = liveDistance;
            _startingPosition = startingPosition;
            _angle = angle;

            Position = startingPosition;
            Velocity = new Vector2((float)Math.Cos(_angle) * 4, (float)Math.Sin(_angle) * 4);
        }
        public LinearProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, Vector2 destination)
            : base(world, source, target, eventType, triggerEvents)
        {
            _liveDistance = liveDistance;
            _startingPosition = startingPosition;
            _destination = destination;
            _angle = GameMath.CalculateAngle(startingPosition, destination);

            Position = startingPosition;
            Velocity = new Vector2((float)Math.Cos(_angle) * 2, (float)Math.Sin(_angle) * 2);
        }
示例#6
0
        public override void Check()
        {
            if (ProjectileTarget != null && Obstacle == null)
            {
                StartCast     = Game.RawGameTime;
                StartPosition = ProjectilePostion;
                EndPosition   = ProjectileTarget.Position;
                EndCast       = StartCast + ProjectileTarget.Distance2D(EndPosition) / GetProjectileSpeed();
                Obstacle      = Pathfinder.AddObstacle(EndPosition, GetRadius(), Obstacle);
            }
            else if (StartCast > 0 && Game.RawGameTime > EndCast)
            {
                End();
            }
            else if (Obstacle != null)
            {
                if (ProjectileTarget == null)
                {
                    return;
                }

                var projectilePosition = GetProjectilePosition();
                if (projectilePosition == lastProjectilePosition)
                {
                    End();
                    return;
                }

                lastProjectilePosition = projectilePosition;

                EndCast = Game.RawGameTime
                          + (ProjectileTarget.Distance2D(projectilePosition) - 20) / GetProjectileSpeed();
                EndPosition = StartPosition.Extend(
                    ProjectileTarget.Position,
                    ProjectileTarget.Distance2D(StartPosition) + GetRadius());
                Pathfinder.UpdateObstacle(
                    Obstacle.Value,
                    ProjectileTarget.NetworkPosition.Extend(StartPosition, GetRadius()),
                    ProjectileTarget.NetworkPosition.Extend(EndPosition, GetRadius()));
            }
        }
        public ThrowProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, Vector2 startingPostion, float throwDistance, float beginningAngle, float projectileDistance, double projectileSpread, float revolutions, float projectilesPerIteration, bool triggerSecondaryProjectileEvents, Vector2 aoeDestination, int aoeLife)
            : base(world, source, target, eventType, triggerEvents)
        {
            _position = startingPostion;

            _startingPosition = startingPostion;
            _throwDistance = throwDistance;
            _beginningAngle = MathHelper.ToRadians(beginningAngle);
            _angle = _beginningAngle;
            _projectileDistance = projectileDistance;
            _projectileSpread = projectileSpread;
            _triggerSecondaryProjectileEvents = triggerSecondaryProjectileEvents;
            _angleCycle = revolutions * 2 * Math.PI;
            _deltaAngle = projectilesPerIteration / _angleCycle;
            _aoeDestination = aoeDestination;
            _aoeLife = aoeLife;

            _thrown = false;
            Velocity = new Vector2((float)Math.Cos(beginningAngle) * 2, (float)Math.Sin(beginningAngle) * 2);
            _triggerEvents = false;
        }
示例#8
0
    private void OnTriggerEnter(Collider other)
    {
        var target = other.gameObject.GetComponent <ProjectileTarget>();

        if (target == null)
        {
            return;
        }

        if (lockedTarget == null)
        {
            lockedTarget    = target;
            hasLockedTarget = true;
        }
        else
        {
            lockedTarget = Vector3.Distance(transform.position, lockedTarget.transform.position) < Vector3.Distance(transform.position, target.transform.position)
                ? lockedTarget
                : target;
            hasLockedTarget = true;
        }
    }
示例#9
0
文件: Gush.cs 项目: senzdota/Ensage
        public override void Check()
        {
            if (AbilityOwner.AghanimState())
            {
                if (StartCast <= 0 && IsInPhase && AbilityOwner.IsVisible)
                {
                    StartCast = Game.RawGameTime;
                    EndCast   = StartCast + CastPoint + AdditionalDelay + GetCastRange() / GetProjectileSpeed();
                }
                else if (StartCast > 0 && Obstacle == null && CanBeStopped() && !AbilityOwner.IsTurning())
                {
                    StartPosition = AbilityOwner.NetworkPosition;
                    EndPosition   = AbilityOwner.InFront(GetCastRange() + GetRadius() / 2);
                    Obstacle      = Pathfinder.AddObstacle(
                        StartPosition,
                        EndPosition,
                        GetRadius(),
                        GetEndRadius(),
                        Obstacle);
                }
                else if (StartCast > 0 && Game.RawGameTime > EndCast)
                {
                    End();
                }
                else if (Obstacle != null && !CanBeStopped())
                {
                    Pathfinder.UpdateObstacle(Obstacle.Value, GetProjectilePosition(), GetRadius(), GetEndRadius());
                }
            }
            else
            {
                if (StartCast <= 0 && IsInPhase && AbilityOwner.IsVisible)
                {
                    StartCast     = Game.RawGameTime;
                    EndCast       = StartCast + CastPoint + GetCastRange() / GetProjectileSpeed();
                    StartPosition = AbilityOwner.NetworkPosition;
                    EndPosition   = AbilityOwner.InFront(GetCastRange());
                    Obstacle      = Pathfinder.AddObstacle(StartPosition, EndPosition, GetRadius(), Obstacle);
                }
                else if (ProjectileTarget != null && Obstacle == null && !FowCast)
                {
                    FowCast       = true;
                    StartCast     = Game.RawGameTime;
                    EndCast       = StartCast + GetCastRange() / GetProjectileSpeed();
                    StartPosition = AbilityOwner.NetworkPosition;
                    EndPosition   = StartPosition.Extend(ProjectileTarget.Position, GetCastRange());
                    Obstacle      = Pathfinder.AddObstacle(StartPosition, EndPosition, GetRadius(), Obstacle);
                }
                else if (StartCast > 0 && Game.RawGameTime > EndCast)
                {
                    End();
                }
                else if (Obstacle != null)
                {
                    if (!ProjectileLaunched())
                    {
                        EndPosition = AbilityOwner.InFront(GetCastRange());
                        Pathfinder.UpdateObstacle(Obstacle.Value, StartPosition, EndPosition);
                        AbilityDrawer.UpdateRectanglePosition(StartPosition, EndPosition, GetRadius());
                    }
                    else if (ProjectileTarget != null)
                    {
                        var projectilePosition = GetProjectilePosition(FowCast);

                        if (projectilePosition == LastProjectilePosition)
                        {
                            End();
                            return;
                        }

                        LastProjectilePosition = projectilePosition;

                        AbilityDrawer.Dispose(AbilityDrawer.Type.Rectangle);
                        //    EndCast = Game.RawGameTime + GetProjectilePosition(fowCast).Distance2D(projectileTarget) / GetProjectileSpeed();
                        EndPosition = StartPosition.Extend(
                            ProjectileTarget.Position,
                            ProjectileTarget.Distance2D(StartPosition) + GetRadius());
                        Pathfinder.UpdateObstacle(
                            Obstacle.Value,
                            ProjectileTarget.NetworkPosition.Extend(StartPosition, GetRadius()),
                            ProjectileTarget.NetworkPosition.Extend(EndPosition, GetRadius()));
                    }
                }
            }
        }