Advertisement
nemszabo

New_Gold

Jul 8th, 2025
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | Gaming | 0 0
  1. /// <summary>
  2. /// A megadott <paramref name="amount"/> aranyat hozzáadja a halomhoz,
  3. /// de soha nem lépi túl a maximális kapacitást.
  4. /// Ha a halom már tele van, figyelmeztetést ír a konzolra és nem módosít.
  5. /// </summary>
  6. /// <param name="amount">A hozzáadni kívánt aranymennyiség.</param>
  7. public void IncreasePileGoldCount(long amount) {
  8.     long spaceLeft = pileMaxGoldCapacity - pileCurrentGold;
  9.     if (spaceLeft <= 0) {
  10.         Debug.LogWarning("Pile is full. Could not add any more gold.");
  11.         return;
  12.     }
  13.     long toAdd = Math.Min(amount, spaceLeft);
  14.     pileCurrentGold += toAdd;
  15.  
  16.     if (pileGoldAmountPercentage >= 1f) {
  17.         grampsComments_c.BuyBiggerPileComment();
  18.     } else if (pileGoldAmountPercentage >= warningGoldAmountPercentage) {
  19.         grampsComments_c.SpendGoldComment();
  20.     } else {
  21.         grampsComments_c.NiceGatheringComment();
  22.     }
  23. }
  24.  
  25. /// <summary>
  26. /// A megadott <paramref name="amount"/> aranyat áthelyezi a játékos zsákjából a halomba,
  27. /// a halom fennmaradó kapacitása szerint korlátozva.
  28. /// Csökkenti a játékos zsákjában lévő aranymennyiséget az átvitt összeggel.
  29. /// </summary>
  30. /// <param name="amount">A mozgatni kívánt aranymennyiség.</param>
  31. /// <param name="playerBag_c">A játékos táskáját kezelő komponens.</param>
  32. public void MoveGoldFromBagToPile(long amount, P_Bag_Control playerBag_c) {
  33.     long spaceLeft = pileMaxGoldCapacity - pileCurrentGold;
  34.     if (spaceLeft <= 0) {
  35.         Debug.LogWarning("Pile is full. No gold moved.");
  36.         return;
  37.     }
  38.     long toTransfer = Math.Min(amount, spaceLeft);
  39.     IncreasePileGoldCount(toTransfer);
  40.     playerBag_c.DecreaseGold(toTransfer);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement