42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
//using UnityEngine;
|
|
|
|
|
|
//// ÓÑÒÀÐÅÂØÈÉ ÔÓÍÊÖÈÎÍÀË ÑÅÉ×ÀÑ ÂÑÅ ×ÅÐÅÇ ComWrapper.
|
|
//public class PlayerWallet
|
|
//{
|
|
// public static event System.Action<int, int> OnCoinsChanged; // (playerId, newCoins)
|
|
|
|
// private int playerId;
|
|
// private string key;
|
|
|
|
// public PlayerWallet(int playerId)
|
|
// {
|
|
// this.playerId = playerId;
|
|
// key = $"Player{playerId}_Coins";
|
|
// }
|
|
|
|
// public int GetCoins() => PlayerPrefs.GetInt(key, 0);
|
|
|
|
// public void AddCoin()
|
|
// {
|
|
// int current = GetCoins();
|
|
// int newAmount = current + 1;
|
|
// PlayerPrefs.SetInt(key, newAmount);
|
|
// PlayerPrefs.Save();
|
|
// OnCoinsChanged?.Invoke(playerId, newAmount);
|
|
// }
|
|
|
|
// public bool SpendCoin()
|
|
// {
|
|
// int current = GetCoins();
|
|
// if (current >= 1)
|
|
// {
|
|
// PlayerPrefs.SetInt(key, current - 1);
|
|
// PlayerPrefs.Save();
|
|
// OnCoinsChanged?.Invoke(playerId, current - 1);
|
|
// return true;
|
|
// }
|
|
// return false;
|
|
// }
|
|
//}
|