Beispiel #1
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (ModSabres.AINormalSlash(projectile, SlashLogic))
            {
            }
            else
            {
                // Charged attack
                ModSabres.AISetChargeSlashVariables(player, chargeSlashDirection);
                ModSabres.NormalSlash(projectile, player);

                // Play charged sound
                if (sndOnce)
                {
                    Main.PlaySound(SoundID.Item5.WithVolume(0.5f), projectile.Center); sndOnce = false;
                    preDashVelocity = player.velocity; // Save velocity before dash
                }
            }

            if (SlashLogic == 0)
            {
                float dashFrameDuration = 3;
                float dashSpeed         = player.maxRunSpeed * 4f;
                int   freezeFrame       = 2;
                ModSabres.AIDashSlash(player, projectile, dashFrameDuration, dashSpeed, freezeFrame, ref preDashVelocity);
            }

            projectile.damage = 0;
            projectile.ai[0] += 1f; // Framerate
        }
Beispiel #2
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (ModSabres.AINormalSlash(projectile, SlashLogic))
            {
            }
            else
            {
                // Charged attack
                ModSabres.AISetChargeSlashVariables(player, chargeSlashDirection);
                ModSabres.NormalSlash(projectile, player);

                // Play charged sound
                if (sndOnce)
                {
                    Main.PlaySound(2, player.Center, 28); sndOnce = false;
                    preDashVelocity = null; // Save velocity before dash
                }
            }

            if (SlashLogic == 0)
            {
                float dashFrameDuration = 6;
                float dashSpeed         = 32f;
                int   freezeFrame       = 2;
                bool  dashing           = ModSabres.AIDashSlash(player, projectile, dashFrameDuration, dashSpeed, freezeFrame, ref preDashVelocity);

                if (dashing)
                {
                    Dust.NewDust(player.Center - new Vector2(6, 6), 4, 4, 20);

                    // Coloured line trail
                    Vector2 dashStep = player.position - player.oldPosition;
                    for (int i = 0; i < 8; i++)
                    {
                        Dust d = Main.dust[Dust.NewDust(player.Center - (dashStep / 8) * i,
                                                        0, 0, 181, dashStep.X / 32, dashStep.Y / 32, 0, default(Color), 1.3f)];
                        d.noGravity = true;
                        d.velocity *= 0.1f;
                    }
                }

                // Calculate ending position dust
                if (firstFrame)
                {
                    firstFrame = false;

                    Vector2 endPosition = player.position;
                    Vector2 dashVector  = projectile.velocity * dashSpeed;
                    for (int i = 0; i < dashFrameDuration * 2; i++)
                    {
                        Vector2 move = Collision.TileCollision(
                            endPosition, dashVector / 2,
                            player.width, player.height,
                            false, false, (int)player.gravDir);
                        if (move == Vector2.Zero)
                        {
                            break;
                        }
                        endPosition += move;
                    }

                    // dash dust from the total distance over the duration
                    Vector2 totalDistanceStep =
                        (endPosition + new Vector2(player.width / 2, player.height / 2)
                         - player.Center) / dashFrameDuration;
                    for (int i = 0; i < dashFrameDuration; i++)
                    {
                        Vector2 pos = player.Center + (totalDistanceStep * i) - new Vector2(4, 4);
                        for (int j = 0; j < 5; j++)
                        {
                            pos += totalDistanceStep * (j / 5f);
                            Dust d = Main.dust[Dust.NewDust(pos, 0, 0,
                                                            175, projectile.velocity.X, projectile.velocity.Y,
                                                            0, Color.White, 1f)];
                            d.noGravity = true;
                            d.velocity *= 0.05f;
                        }
                    }
                }
            }

            projectile.damage = 0;
            FrameCheck       += 1f; // Framerate
        }