private void Click_NpcChatButton_WitchDoctorHeal_Necrotis(float healAmount) { if (healAmount > 0) { NecrotisPlayer.HealAtCost(Main.LocalPlayer, healAmount); } }
//// public static bool HealAtCost(Player player, float healAmount) { var myplayer = player.GetModPlayer <NecrotisPlayer>(); int cost = NecrotisPlayer.CalculateHealCostFromWitchDoctor(player, healAmount); if (cost == 0) { return(false); } if (!player.BuyItem(cost)) { return(false); } myplayer.AnimaPercent += healAmount; DustLibraries.CreateMany(dustType: DustLibraries.GoldGlitterTypeID, position: player.Center, quantity: 8); Main.PlaySound(SoundID.Item4); return(true); }
//////////////// private void Draw_NpcChatButton_WitchDoctor_HealNecrotis() { string label = "Heal Necrotis"; float healAmount = NecrotisPlayer.CalculateHealAmountFromWitchDoctor(Main.LocalPlayer); int cost = NecrotisPlayer.CalculateHealCostFromWitchDoctor(Main.LocalPlayer, healAmount); Color color; if (cost == 0) { color = Color.Gray; } else { string readCost = string.Join(" ", ItemMoneyLibraries.RenderMoneyDenominations(cost, true, false, false)); label += " (" + readCost + ")"; color = new Color( Main.mouseTextColor, (byte)((double)Main.mouseTextColor / 1.1d), Main.mouseTextColor / 2, Main.mouseTextColor ); } List <List <TextSnippet> > snippets = Utils.WordwrapStringSmart( text: Main.npcChatText, c: Color.White, font: Main.fontMouseText, maxWidth: 460, maxLines: 10 ); int lineCount = snippets.Count; Vector2 scale = new Vector2(0.9f); DynamicSpriteFont font = Main.fontMouseText; Vector2 stringSize = ChatManager.GetStringSize(font, label, scale, -1f); Vector2 pos = new Vector2( stringSize.X + 30f + 96f /*todo?*/, 100 + (lineCount + 1) * 30 ); pos.X += (Main.screenWidth / 2) - (Main.chatBackTexture.Width / 2); if (cost > 0) { this.Hover_NpcChatButton_WitchDoctor_HealNecrotis(pos, stringSize, ref scale); } ChatManager.DrawColorCodedStringWithShadow( spriteBatch: Main.spriteBatch, font: font, text: label, position: pos + stringSize * 0.5f, baseColor: color, rotation: 0f, origin: stringSize * 0.5f, baseScale: scale, maxWidth: -1f, spread: 2f ); // TODO: Figure out how to use this properly? //UILinkPointNavigator.SetPosition( 2502, pos + stringSize * 0.5f ); //UILinkPointNavigator.Shortcuts.NPCCHAT_ButtonsRight = true; if (cost > 0) { if (Main.npcChatFocus3 && Main.mouseLeft && Main.mouseLeftRelease) { this.Click_NpcChatButton_WitchDoctorHeal_Necrotis(healAmount); } } }