Пример #1
0
        public override void AI()
        {
            float progress = Counter / Lifetime;

            if (Counter == 0f)
            {
                SoundSlot = SoundEngine.PlayTrackedSound(SoundID.DD2_GhastlyGlaiveImpactGhost, Projectile.Center).ToFloat();
            }

            ActiveSound activeSound = SoundEngine.GetActiveSound(SlotId.FromFloat(SoundSlot));

            if (activeSound == null)
            {
                SoundSlot = SlotId.Invalid.ToFloat();
            }
            else
            {
                activeSound.Position = Projectile.Center;
            }

            float fadeOutTime = Lifetime - 15f;

            if (Counter > fadeOutTime)
            {
                Projectile.alpha += 10;
                if (Projectile.alpha > 255)
                {
                    Projectile.alpha = 255;
                }
            }
            else
            {
                Projectile.alpha -= 25;
                if (Projectile.alpha < 50)
                {
                    Projectile.alpha = 50;
                }
            }

            if (Counter >= Lifetime - 1f)
            {
                Projectile.Kill();
                return;
            }

            float offset = 70f;

            Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt();
            if (Projectile.velocity.Length() > 0.1f)
            {
                Projectile.velocity *= 0.95f;
            }

            offset *= Projectile.direction;
            Vector2 value    = Projectile.Center - Projectile.rotation.ToRotationVector2() * offset;
            float   windUp   = Utils.Remap(progress, 0.3f, 0.5f, 0f, 1f) * Utils.Remap(progress, 0.45f, 0.5f, 1f, 0f);
            float   swing    = Utils.Remap(progress, 0.5f, 0.55f, 0f, 1f) * Utils.Remap(progress, 0.5f, 0.95f, 1f, 0.05f);
            float   bonusRot = windUp * MathHelper.Pi / 60f;

            bonusRot            += swing * -MathHelper.Pi * 5.5f / 60f;
            Projectile.rotation += bonusRot * -Projectile.direction;
            Projectile.rotation  = MathHelper.WrapAngle(Projectile.rotation);
            Projectile.Center    = value + Projectile.rotation.ToRotationVector2() * offset;

            Counter += 1f;
        }
        public override void AI()
        {
            GetVariationValues(out int variation, out float fakeCounter, out float counterMax);

            float fromValue = fakeCounter / counterMax;

            if (fakeCounter == 0f)
            {
                Projectile.localAI[1] = SoundEngine.PlayTrackedSound(SoundID.DD2_GhastlyGlaiveImpactGhost, Projectile.Center).ToFloat();
            }

            ActiveSound activeSound = SoundEngine.GetActiveSound(SlotId.FromFloat(Projectile.localAI[1]));

            if (activeSound == null)
            {
                Projectile.localAI[1] = SlotId.Invalid.ToFloat();
            }
            else
            {
                activeSound.Position = Projectile.Center;
            }

            float fadeOutTime = counterMax - 15f;

            if (fakeCounter > fadeOutTime)
            {
                Projectile.alpha += 25;
                if (Projectile.alpha > 255)
                {
                    Projectile.alpha = 255;
                }
            }
            else
            {
                Projectile.alpha -= 25;
                if (Projectile.alpha < 50)
                {
                    Projectile.alpha = 50;
                }
            }

            if (fakeCounter >= counterMax - 1f)
            {
                Projectile.Kill();
                return;
            }

            if (variation == 0)
            {
                Projectile.velocity *= 0.98f;
                Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt();
                Projectile.rotation  = Projectile.velocity.ToRotation();
                if (Projectile.spriteDirection == -1)
                {
                    Projectile.rotation += MathHelper.Pi;
                }
            }
            else if (variation == 1)
            {
                float offset = 70f;
                Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt();
                if (Projectile.velocity.Length() > 0.1f)
                {
                    Projectile.velocity *= 0.95f;
                }

                offset *= Projectile.direction;
                Vector2 value      = Projectile.Center - Projectile.rotation.ToRotationVector2() * offset;
                float   from03to05 = Utils.Remap(fromValue, 0.3f, 0.5f, 0f, 1f) * Utils.Remap(fromValue, 0.45f, 0.5f, 1f, 0f);            //Wind-up
                float   from05to1  = Utils.Remap(fromValue, 0.5f, 0.55f, 0f, 1f) * Utils.Remap(fromValue, 0.5f, 1f, 1f, 0f);              //Swing
                float   bonusRot   = from03to05 * MathHelper.Pi / 60f;
                bonusRot            += from05to1 * -MathHelper.Pi * 8f / 60f;
                Projectile.rotation += bonusRot * -Projectile.direction;
                Projectile.rotation  = MathHelper.WrapAngle(Projectile.rotation);
                Projectile.Center    = value + Projectile.rotation.ToRotationVector2() * offset;
            }
            else if (variation == 2)
            {
                float f              = Projectile.ai[1];
                float from0to04      = Utils.Remap(fromValue, 0f, 0.4f, 1f, 0f);
                float from03to1      = Utils.Remap(fromValue, 0.3f, 0.4f, 0f, 1f) * Utils.Remap(fromValue, 0.4f, 1f, 1f, 0f);
                float velocityFactor = from0to04 * 2f + from03to1 * 8f + 0.01f;
                Projectile.velocity  = f.ToRotationVector2() * velocityFactor;
                Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt();
                Projectile.rotation  = Projectile.velocity.ToRotation();
                if (Projectile.spriteDirection == -1)
                {
                    Projectile.rotation += MathHelper.Pi;
                }
            }
            else if (variation == 3)
            {
                float num8 = Projectile.ai[1];
                Projectile.velocity  = Projectile.velocity.RotatedBy(num8);
                Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt();
                Projectile.rotation  = Projectile.velocity.ToRotation();
                if (Projectile.spriteDirection == -1)
                {
                    Projectile.rotation += MathHelper.Pi;
                }
            }

            Projectile.ai[0] += 1f;
        }