예제 #1
0
        public void HandleChargingKi(Player player)
        {
            bool isCharging = false;

            DBTPlayer modPlayer = Main.LocalPlayer.GetModPlayer <DBTPlayer>();

            finalChargeLimit = chargeLimit + modPlayer.ChargeLimitAdd;

            // stop channeling if the player is out of ki

            /*if (modPlayer.IsKiDepleted())
             * {
             *  player.channel = false;
             * }*/

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

            // charge the ball if the proper keys are held.
            // increment the charge timer if channeling and apply slowdown effect
            if (modPlayer.MouseLeftHeld /*&& !IsFired*/)
            {
                // 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.HasKi(ChargeKiDrainRate()))
                {
                    isCharging = true;

                    // drain ki from the player when charging

                    /*if (DBTMod.IsTickRateElapsed(CHARGE_KI_DRAIN_WINDOW))
                     * {
                     *  modPlayer.ModifyKi(Definition.Characteristics.ChargeCharacteristics.GetChargeKiDrainForChargeLevel(modPlayer));
                     * }*/

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

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

                /*else
                 * {
                 *  if (ChargeLevel == 0f)
                 *  {
                 *      projectile.Kill();
                 *  }
                 * }*/
            }

            // play the sound if the player just started charging and the audio is "off cooldown"
            if (!_wasCharging && isCharging && ChargeSoundCooldown == 0f)
            {
                if (!Main.dedServ)
                {
                    chargeSoundSlotId = SoundHelper.PlayCustomSound(chargeSoundKey, projectile.Center, chargeSoundVolume);
                }
                ChargeSoundCooldown = chargeSoundDelay;
            }
            else
            {
                ChargeSoundCooldown = Math.Max(0f, ChargeSoundCooldown - 1);
            }

            // set the wasCharging flag for proper tracking
            _wasCharging = isCharging;
        }