Example #1
0
        ////////////////

        public bool ApplyExercise(Player player)
        {
            var mymod = StaminaMod.Instance;

            if (this.MaxStamina >= mymod.Config.MaxStaminaAmount)
            {
                return(false);
            }

            var myplayer = player.GetModPlayer <StaminaPlayer>();

            this.AddMaxStamina(player, mymod.Config.ExerciseGrowthAmount);

            if (myplayer.IsUsingSupplements)
            {
                this.AddMaxStamina(player, mymod.Config.ExerciseSupplementAddedGrowthAmount);
            }

            if (this.MaxStamina > mymod.Config.MaxStaminaAmount)
            {
                this.AddMaxStamina(player, mymod.Config.MaxStaminaAmount - this.MaxStamina);
            }

            string msg = "+" + mymod.Config.ExerciseGrowthAmount + " Stamina";

            PlayerMessages.AddPlayerLabel(player, msg, Color.Chartreuse, 60 * 3, true);

            Main.PlaySound(SoundID.Item47.WithVolume(0.5f));

            return(true);
        }
Example #2
0
        public override bool UseItem(Player player)
        {
            var            mymod = (LicensesMod)this.mod;
            int            savings;
            int            oldStack    = this.item.stack;
            ItemDefinition randItemDef = this.AttemptToLicenseRandomItem(player, out savings);

            if (randItemDef == null)
            {
                Main.NewText("No items of the given tier left to license.", Color.Red);
                return(false);
            }

            int   targetRarity = WildcardLicenseItem.ComputeTargetRarityOfLicenseStackSize(oldStack);
            Color color        = ItemRarityAttributeHelpers.RarityColor[targetRarity];

            string randItemName = ItemAttributeHelpers.GetQualifiedName(randItemDef.Type);
            string msg          = randItemName + " licensed";

            if (savings > 0)
            {
                msg += " - " + savings + " discounted";
            }

            PlayerMessages.AddPlayerLabel(player, msg, color, 2 * 60, true);
            Main.NewText(msg, color);

            if (LicensesMod.Config.DebugModeInfo)
            {
                LogHelpers.Alert(randItemName + " unlocked");
            }

            return(true);
        }
Example #3
0
        public float AddRewardForPlayer(Player player, bool isGrind, bool isExpired, float reward)
        {
            if (isExpired)
            {
                return(0f);
            }

            var   mymod       = RewardsMod.Instance;
            float finalReward = reward;
            float oldPP       = this.ProgressPoints;

            if (isGrind)
            {
                finalReward *= mymod.PointsConfig.GrindKillMultiplier;
            }

            if (Main.netMode != 2 && mymod.SettingsConfig.ShowPointsPopups)
            {
                Color color = isGrind ? Color.DarkGray : Color.GreenYellow;

                if (Math.Abs(finalReward) >= 0.01f)
                {
                    string msg = "+" + Math.Round(finalReward, 2) + " PP";
                    PlayerMessages.AddPlayerLabel(player, msg, color, 60 * 3, true, false);
                }
                else if (Math.Abs(finalReward) > 0)
                {
                    PlayerMessages.AddPlayerLabel(player, "+PP", color, 60, true, false);
                }
            }

            this.ProgressPoints += finalReward;

            foreach (var hook in mymod.OnPointsGainedHooks)
            {
                hook(player, finalReward);
            }

            if (mymod.SettingsConfig.DebugModeKillInfo)
            {
                LogHelpers.Log("  AddRewardForPlayer - Player: " + player.name + " (" + player.whoAmI + ")"
                               + ", reward: " + finalReward + ((finalReward != reward) ? (" (was " + reward + ")") : "")
                               + ", isGrind:" + isGrind + ", isExpired:" + isExpired
                               + ", PP: " + this.ProgressPoints + " (was " + oldPP + ")"
                               );
            }
            if (mymod.SettingsConfig.DebugModePPInfo && finalReward != 0)
            {
                LogHelpers.Alert("PP added: " + finalReward + " (now " + this.ProgressPoints
                                 + " for " + (player?.name ?? "world") + ")");
            }

            return(finalReward);
        }