Currency Agent - MatinTheGC/DotPlay GitHub Wiki
Currency Agent encrypts & stores your games' currencies to prevent modifying your game.
Methods
void CurrencyAgent.Encrypt
Gets an id, CurrencyChangeType & amount. Then encrypts (converts to letters) & stores it using PlayerPrefs.SetString().
int CurrencyAgent.Decrypt
Gets an id, Decrypts string & converts it to int & returns it.
enum CurrencyModityType
Contains ways to modify the currency:
- Add
- Subtract
- Set
Example
private void Start ()
{
SetCoins (1000);
int coins = GetCoins ();
Debug.Log (coins);
// 1000
}
private void SetCoins(int amount)
{
CurrencyAgent.Encrypt (0, CurrencyModifyType.Set, amount);
}
private int GetCoins ()
{
return CurrencyAgent.Decrypt (0);
}