예제 #1
0
        private void Hit(bool destroy = true)
        {
            this.OnHit ();
            if (this.onHit.IsNotNull ()) {
                this.onHit ();
            }
            if (this.TargetCurrent) {
                if (this.UseEffects) {
                    if (this.AttachEndEffectToTarget) {
                        LSEffect lSEffect = EffectManager.CreateEffect (this.HitFX);
                        lSEffect.CachedTransform.parent = this.Target.VisualCenter;
                        lSEffect.CachedTransform.localPosition = Vector3.up;
                        lSEffect.CachedTransform.rotation = this.cachedTransform.rotation;
                        lSEffect.Initialize ();
                    } else {
                        //Certain targeting types collide with a target
                        if (this.TargetingBehavior == TargetingType.Homing) {
                            EffectManager.CreateCollisionEffect (this.HitFX, this, Target.Body);
                        } else {
                            EffectManager.CreateEffect (this.HitFX, this.cachedTransform.position, this.cachedTransform.rotation);

                        }
                    }
                }
            }
            if (destroy)
                ProjectileManager.EndProjectile (this);
        }
예제 #2
0
        public void Simulate()
        {
            this.AliveTime++;

            if (this.AliveTime > this.MaxDuration)
            {
                ProjectileManager.EndProjectile(this);
                return;
            }
            switch (this.TargetingBehavior)
            {
            case TargetingType.Timed:
                this.CountDown--;
                if (this.CountDown == 0)
                {
                    this.Hit();
                }
                break;

            case TargetingType.Homing:
                if (this._visualArc)
                {
                    long progress = FixedMath.Create(this.AliveTime) / 32;
                    long height   = this.arcStartHeight + this.arcStartVerticalSpeed.Mul(progress) - Gravity.Mul(progress.Mul(progress));
                    this.Position.z = height;
                }
                else
                {
                    this.TargetHeight = this.Target.Body.HeightPos + Target.Body.Height / 2;
                    this.Position.z   = FixedMath.MoveTowards(this.Position.z, TargetHeight, this.linearHeightSpeed);
                }
                if (this.CheckCollision())
                {
                    this.TargetPosition = this.Target.Body._position;
                    this.Hit();
                }
                else
                {
                    LSProjectile.tempDirection = this.Target.Body._position - this.Position.ToVector2d();
                    if (LSProjectile.tempDirection.Dot(this.lastDirection.x, this.lastDirection.y) < 0L)
                    {
                        this.TargetPosition = this.Target.Body._position;
                        this.Hit();
                    }
                    else
                    {
                        LSProjectile.tempDirection.Normalize();
                        Forward                     = tempDirection;
                        this.lastDirection          = LSProjectile.tempDirection;
                        LSProjectile.tempDirection *= this.speedPerFrame;
                        this.Position.Add(LSProjectile.tempDirection.ToVector3d());
                    }
                }
                break;

            case TargetingType.Free:
                RaycastMove(this.Velocity);
                break;
            }
        }
예제 #3
0
 private void Hit()
 {
     if (this.TargetingBehavior == TargetingType.Homing && this.HitBehavior == HitType.Single && this.Target.SpawnVersion != this.TargetVersion)
     {
         ProjectileManager.EndProjectile(this);
         return;
     }
     this.OnHit();
     if (this.onHit.IsNotNull())
     {
         this.onHit.Invoke();
     }
     if (this.UseEffects)
     {
         if (this.AttachEndEffectToTarget)
         {
             LSEffect lSEffect = EffectManager.CreateEffect(this.EndEffect);
             lSEffect.CachedTransform.parent        = this.Target.VisualCenter;
             lSEffect.CachedTransform.localPosition = Vector3.up;
             lSEffect.Initialize();
         }
         else
         {
             {
                 EffectManager.LazyCreateEffect(this.EndEffect, this.cachedTransform.position, this.cachedTransform.rotation);
             }
         }
     }
     ProjectileManager.EndProjectile(this);
 }
예제 #4
0
        public void Simulate()
        {
            this.AliveTime++;

            if (this.AliveTime > this.MaxDuration)
            {
                ProjectileManager.EndProjectile(this);
                return;
            }
            switch (this.TargetingBehavior)
            {
            case TargetingType.Timed:
                this.CountDown--;

                if (!IsLasting)
                {
                    if (this.CountDown <= 0)
                    {
                        IsLasting = true;
                        tickTimer = 0;
                    }
                }
                if (IsLasting)
                {
                    tickTimer--;
                    if (tickTimer <= 0)
                    {
                        tickTimer = TickRate;
                        this.Hit((this.AliveTime + TickRate - this.Delay) >= this.LastingDuration);
                    }
                }
                break;

            case TargetingType.Homing:
                if (this.CheckCollision())
                {
                    this.TargetPosition = this.Target.Body._position;
                    this.Hit();
                }
                else
                {
                    TargetPosition    = Target.Body.Position;
                    this.TargetHeight = this.Target.Body.HeightPos + Target.Body.Height / 2;

                    MoveToTargetPosition();
                }
                break;

            case TargetingType.Free:
                RaycastMove(this.Velocity);
                break;

            case TargetingType.Positional:
                MoveToTargetPosition();

                break;
            }
        }
예제 #5
0
        public void Simulate()
        {
            this.AliveTime++;

            if (this.AliveTime > this.MaxDuration) {
                ProjectileManager.EndProjectile (this);
                return;
            }
            switch (this.TargetingBehavior) {
            case TargetingType.Timed:
                this.CountDown--;

                if (!IsLasting) {
                    if (this.CountDown <= 0) {
                        IsLasting = true;
                        tickTimer = 0;
                    }
                }
                if (IsLasting) {
                    tickTimer--;
                    if (tickTimer <= 0) {
                        tickTimer = TickRate;
                        this.Hit ((this.AliveTime + TickRate - this.Delay) >= this.LastingDuration);
                    }
                }
                break;
            case TargetingType.Homing:
                if (this.TargetingBehavior == TargetingType.Homing && this.HitBehavior == HitType.Single && this.Target.SpawnVersion != this.TargetVersion) {
                    //Switch to positional to move to target's last position and not seek deceased target
                    this.TargetingBehavior = TargetingType.Positional;
                    Target = null;
                    TargetCurrent = false;
                    goto case TargetingType.Positional;
                }
                if (this.CheckCollision ()) {
                    this.TargetPosition = this.Target.Body._position;
                    this.Hit ();
                } else {
                    TargetPosition = Target.Body.Position;
                    this.TargetHeight = this.Target.Body.HeightPos + Target.Body.Height / 2;

                    MoveToTargetPosition ();
                }
                break;
            case TargetingType.Directional:
                RaycastMove (this.Velocity);
                break;
            case TargetingType.Positional:
                MoveToTargetPosition ();

                break;
            }
        }
예제 #6
0
        public void Simulate()
        {
            this.AliveTime++;
            if (this.AliveTime > this.MaxDuration || (this.Channeled && (this.Source.SpawnVersion != this.SourceVersion || !this.Source.Scanner.IsCasting)))
            {
                ProjectileManager.EndProjectile(this);
                return;
            }
            switch (this.TargetingBehavior)
            {
            case TargetingType.Timed:
                this.CountDown--;
                if (this.CountDown == 0)
                {
                    this.Hit();
                }
                break;

            case TargetingType.Seeking:
                if (this.CheckCollision())
                {
                    this.TargetPosition = this.Target.Body.Position;
                    this.Hit();
                }
                else
                {
                    LSProjectile.tempDirection = this.Target.Body.Position - this.Position;
                    if (LSProjectile.tempDirection.Dot(this.lastDirection.x, this.lastDirection.y) < 0L)
                    {
                        this.TargetPosition = this.Target.Body.Position;
                        this.Hit();
                    }
                    else
                    {
                        LSProjectile.tempDirection.Normalize();
                        this.lastDirection          = LSProjectile.tempDirection;
                        LSProjectile.tempDirection *= this.speedPerFrame;
                        this.Position += LSProjectile.tempDirection;
                    }
                }
                break;

            case TargetingType.Positional:
                this.Position += this.targetDirection;
                LSProjectile.tempDirection = this.TargetPosition - this.Position;
                if (this.targetDirection.Dot(LSProjectile.tempDirection.x, LSProjectile.tempDirection.y) < 0L)
                {
                    this.Hit();
                }
                break;
            }
        }
        protected override void OnRawExecute(Command com)
        {
            if (com.InputCode == StartShootCode || com.InputCode == EndShootCode)
            {
                if (com.InputCode == StartShootCode)
                {
                    int comFrame = (int)com.GetData <DefaultData>().Value;
                    PassedFrames = LockstepManager.FrameCount - comFrame;
                    uint currentShot = (uint)com.GetData <DefaultData>(1).Value;
                    if (this.LatencyProjectiles.ContainsKey(currentShot))
                    {
                        ProjectileManager.EndProjectile(this.LatencyProjectiles[currentShot]);
                    }

                    this.IsFiring = true;
                    this.CheckFire();
                }
                else if (com.InputCode == EndShootCode)
                {
                    this.IsFiring = false;
                }
            }
        }