Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomCurrencySingleCoin.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
8
10
12{
13 public float CurrencyDrawScale = 0.8f;
14
15 public string CurrencyTextKey = "Currency.DefenderMedals";
16
17 public Color CurrencyTextColor = new Color(240, 100, 120);
18
24
26 {
28 long num = price;
29 for (int i = 0; i < slotCoins.Count; i++)
30 {
31 Point item = slotCoins[i];
32 long num2 = num;
33 if (inv[item.X][item.Y].stack < num2)
34 {
35 num2 = inv[item.X][item.Y].stack;
36 }
37 num -= num2;
38 inv[item.X][item.Y].stack -= (int)num2;
39 if (inv[item.X][item.Y].stack == 0)
40 {
41 switch (item.X)
42 {
43 case 0:
45 break;
46 case 1:
48 break;
49 case 2:
51 break;
52 case 3:
54 break;
55 case 4:
57 break;
58 }
60 i--;
61 }
62 if (num == 0L)
63 {
64 break;
65 }
66 }
67 if (num != 0L)
68 {
70 return false;
71 }
72 return true;
73 }
74
75 public override void DrawSavingsMoney(SpriteBatch sb, string text, float shopx, float shopy, long totalCoins, bool horizontal = false)
76 {
77 int num = _valuePerUnit.Keys.ElementAt(0);
78 Main.instance.LoadItem(num);
79 Texture2D value = TextureAssets.Item[num].Value;
80 if (horizontal)
81 {
82 _ = 99;
83 Vector2 position = new Vector2(shopx + ChatManager.GetStringSize(FontAssets.MouseText.Value, text, Vector2.One).X + 45f, shopy + 50f);
84 sb.Draw(value, position, null, Color.White, 0f, value.Size() / 2f, CurrencyDrawScale, SpriteEffects.None, 0f);
85 Utils.DrawBorderStringFourWay(sb, FontAssets.ItemStack.Value, totalCoins.ToString(), position.X - 11f, position.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
86 }
87 else
88 {
89 int num2 = ((totalCoins > 99) ? (-6) : 0);
90 sb.Draw(value, new Vector2(shopx + 11f, shopy + 75f), null, Color.White, 0f, value.Size() / 2f, CurrencyDrawScale, SpriteEffects.None, 0f);
91 Utils.DrawBorderStringFourWay(sb, FontAssets.ItemStack.Value, totalCoins.ToString(), shopx + (float)num2, shopy + 75f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
92 }
93 }
94
95 public override void GetPriceText(string[] lines, ref int currentLine, long price)
96 {
97 Color color = CurrencyTextColor * ((float)(int)Main.mouseTextColor / 255f);
98 lines[currentLine++] = $"[c/{color.R:X2}{color.G:X2}{color.B:X2}:{Lang.tip[50].Value} {price} {Language.GetTextValue(CurrencyTextKey).ToLower()}]";
99 }
100}
void Draw(Texture2D texture, Vector2 position, Color color)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static Asset< DynamicSpriteFont > ItemStack
Definition FontAssets.cs:8
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
static Asset< Texture2D >[] Item
CustomCurrencySingleCoin(int coinItemID, long currencyCap)
override void GetPriceText(string[] lines, ref int currentLine, long price)
override bool TryPurchasing(long price, List< Item[]> inv, List< Point > slotCoins, List< Point > slotsEmpty, List< Point > slotEmptyBank, List< Point > slotEmptyBank2, List< Point > slotEmptyBank3, List< Point > slotEmptyBank4)
override void DrawSavingsMoney(SpriteBatch sb, string text, float shopx, float shopy, long totalCoins, bool horizontal=false)
void ItemCacheRestore(List< Tuple< Point, Item > > cache, List< Item[]> inventories)
void Include(int coin, int howMuchIsItWorth)
List< Tuple< Point, Item > > ItemCacheCreate(List< Item[]> inventories)
static Main instance
Definition Main.cs:283
static Vector2 GetStringSize(DynamicSpriteFont font, string text, Vector2 baseScale, float maxWidth=-1f)
static void DrawBorderStringFourWay(SpriteBatch sb, DynamicSpriteFont font, string text, float x, float y, Color textColor, Color borderColor, Vector2 origin, float scale=1f)
Definition Utils.cs:1857