Exemple #1
0
        void MoveToTargetPosition()
        {
            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.Position.z = FixedMath.MoveTowards(this.Position.z, TargetHeight, this.linearHeightSpeed);
            }

            LSProjectile.tempDirection = TargetPosition - this.Position.ToVector2d();
            if (LSProjectile.tempDirection.Dot(this.lastDirection.x, this.lastDirection.y) < 0L || tempDirection == Vector2d.zero)
            {
                this.Hit();
                //Debug.Log("asdf");
            }
            else
            {
                //Debug.Log("asdf2");
                LSProjectile.tempDirection.Normalize();
                Forward                     = tempDirection;
                this.lastDirection          = LSProjectile.tempDirection;
                LSProjectile.tempDirection *= this.speedPerFrame;
                this.Position.Add(LSProjectile.tempDirection.ToVector3d());
            }
        }
Exemple #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;
            }
        }