Esempio n. 1
0
        public void HandleFiring(Player player, Vector2 mouseVector)
        {
            MyPlayer modPlayer = player.GetModPlayer <MyPlayer>();

            // minimum charge level is required to fire in the first place, but once you fire, you can keep firing.
            if (ShouldFireBeam(modPlayer))
            {
                // kill the charge sound if we're firing
                ChargeSoundSlotId = SoundUtil.KillTrackedSound(ChargeSoundSlotId);

                if (!WasSustainingFire && MyProjectile == null)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient || Main.myPlayer == player.whoAmI)
                    {
                        // fire the laser!
                        MyProjectile = Projectile.NewProjectileDirect(projectile.position + BeamCreationOffset, projectile.velocity, mod.ProjectileType(BeamProjectileName), GetBeamDamage(), projectile.knockBack, projectile.owner);

                        // set firing time minimum for beams that auto-detach and are stationary, this prevents their self kill routine
                        MyProjectile.ai[1] = MinimumFireFrames;
                    }
                }

                // increment the fire time, this handles "IsSustainingFire" as well as stating the beam is no longer firable (it is already being fired)
                CurrentFireTime++;

                // if the player has charge left, drain the ball
                if (ChargeLevel >= FireDecayRate())
                {
                    ChargeLevel = Math.Max(0f, ChargeLevel - FireDecayRate());
                }
                else if (!modPlayer.IsKiDepleted())
                {
                    if (DBZMOD.IsTickRateElapsed(FIRE_KI_DRAIN_WINDOW))
                    {
                        modPlayer.AddKi(-FireKiDrainRate(), true, false);
                    }
                }
                else
                {
                    // beam is no longer sustainable
                    KillBeam();
                }
            }
            else
            {
                // player has stopped firing or something else has stopped them
                KillBeam();
            }

            WasSustainingFire = IsSustainingFire;
        }
Esempio n. 2
0
        public override void AI()
        {
            if (!player.channel || (ChargeLevel >= ChargeLimit))
            {
                if (ChargeLevel >= 1)
                {
                    float rot = (float)Math.Atan2((Main.mouseY + Main.screenPosition.Y) - projectile.Center.Y, (Main.mouseX + Main.screenPosition.X) - projectile.Center.X);
                    Projectile.NewProjectileDirect(new Vector2(projectile.Center.X, projectile.Center.Y), new Vector2((float)((Math.Cos(rot) * 15)), (float)((Math.Sin(rot) * 15))), mod.ProjectileType("BigBangKamehamehaBlast"), projectile.damage + (ChargeLevel * 65), projectile.knockBack, projectile.owner);

                    //ChargeLevel = 0;
                    SoundUtil.PlayCustomSound("Sounds/BasicBeamFire", projectile.Center);

                    projectile.Kill();

                    for (int i = 0; i < 100; i++)
                    {
                        float   angle    = Main.rand.NextFloat(360);
                        float   angleRad = MathHelper.ToRadians(angle);
                        Vector2 position = new Vector2((float)Math.Cos(angleRad), (float)Math.Sin(angleRad));
                        Dust    tDust    = Dust.NewDustDirect(projectile.position + (position * (20 + 3.0f * projectile.scale)), projectile.width, projectile.height, DustType, 0f, 0f, 213, default(Color), 3.0f);
                        tDust.velocity  = -0.5f * Vector2.Normalize((projectile.position + (projectile.Size / 2)) - tDust.position) * 2;
                        tDust.noGravity = true;
                    }
                }
                chargeSoundSlotId = SoundUtil.KillTrackedSound(chargeSoundSlotId);
            }

            if (!startingCharge)
            {
                startingCharge = true;
                if (!Main.dedServ)
                {
                    chargeSoundSlotId = SoundUtil.PlayCustomSound("Sounds/EnergyWaveCharge", projectile.Center);
                }
            }

            SoundUtil.UpdateTrackedSound(chargeSoundSlotId, projectile.Center);
        }
Esempio n. 3
0
        public void HandleChargingKi(Player player)
        {
            bool IsCharging = false;

            FinalChargeLimit = ChargeLimit + MyPlayer.ModPlayer(player).ChargeLimitAdd;

            // stop channeling if the player is out of ki
            if (MyPlayer.ModPlayer(player).IsKiDepleted())
            {
                player.channel = false;
            }

            // keep alive routine.
            if (projectile.timeLeft < 4)
            {
                projectile.timeLeft = 10;
            }

            MyPlayer modPlayer = MyPlayer.ModPlayer(player);

            // The energy in the projectile decays if the player stops channeling.
            if (!player.channel && !modPlayer.IsMouseRightHeld && !IsSustainingFire)
            {
                // kill the tracked charge sound if the player let go, immediately
                ChargeSoundSlotId = SoundUtil.KillTrackedSound(ChargeSoundSlotId);

                if (ChargeLevel > 0f)
                {
                    ChargeLevel = Math.Max(0, ChargeLevel - DecayRate());

                    // don't draw the ball when firing.
                    if (!IsSustainingFire)
                    {
                        ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, DecayDustFrequency, true, ChargeSize.ToVector2());
                    }
                }
                else
                {
                    // the charge level zeroed out, kill the projectile.
                    projectile.Kill();
                }
            }

            // charge the ball if the proper keys are held.
            // increment the charge timer if channeling and apply slowdown effect
            if (player.channel && projectile.active && modPlayer.IsMouseRightHeld && !IsSustainingFire)
            {
                // the player can hold the charge all they like once it's fully charged up. Currently this doesn't incur a movespeed debuff either.
                if (ChargeLevel < FinalChargeLimit && !modPlayer.IsKiDepleted())
                {
                    IsCharging = true;

                    // drain ki from the player when charging
                    if (DBZMOD.IsTickRateElapsed(CHARGE_KI_DRAIN_WINDOW))
                    {
                        MyPlayer.ModPlayer(player).AddKi(-ChargeKiDrainRate(), true, false);
                    }

                    // increase the charge
                    ChargeLevel = Math.Min(FinalChargeLimit, ChargeRate() + ChargeLevel);

                    // slow down the player while charging.
                    ProjectileUtil.ApplyChannelingSlowdown(player);

                    // shoot some dust into the ball to show it's charging, and to look cool.
                    if (!IsSustainingFire)
                    {
                        ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, ChargeDustFrequency, false, ChargeSize.ToVector2());
                    }
                }
            }

            // play the sound if the player just started charging and the audio is "off cooldown"
            if (!WasCharging && IsCharging && ChargeSoundCooldown == 0f)
            {
                if (!Main.dedServ)
                {
                    ChargeSoundSlotId = SoundUtil.PlayCustomSound(ChargeSoundKey, projectile.Center);
                }
                ChargeSoundCooldown = ChargeSoundDelay;
            }
            else
            {
                ChargeSoundCooldown = Math.Max(0f, ChargeSoundCooldown - 1);
            }

            // set the wasCharging flag for proper tracking
            WasCharging = IsCharging;
        }