You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1005 B
C#
37 lines
1005 B
C#
2 months ago
|
using UnityEngine;
|
||
|
|
||
|
public static class GameConstants
|
||
|
{
|
||
|
private const string CashKey = "Cash";
|
||
|
private const string CarSelectedKey = "CarSelected";
|
||
|
private const string CarUnlockedPrefix = "CarUnlocked_";
|
||
|
private const string CarColorIndexKey = "CarColorIndex";
|
||
|
|
||
|
public static int CarColorIndex
|
||
|
{
|
||
|
get => PlayerPrefs.GetInt(CarColorIndexKey, 0);
|
||
|
set => PlayerPrefs.SetInt(CarColorIndexKey, value);
|
||
|
}
|
||
|
public static int Cash
|
||
|
{
|
||
|
get => PlayerPrefs.GetInt(CashKey, 0);
|
||
|
set => PlayerPrefs.SetInt(CashKey, value);
|
||
|
}
|
||
|
|
||
|
public static int CarSelected
|
||
|
{
|
||
|
get => PlayerPrefs.GetInt(CarSelectedKey, 0);
|
||
|
set => PlayerPrefs.SetInt(CarSelectedKey, value);
|
||
|
}
|
||
|
|
||
|
public static bool IsCarUnlocked(int index)
|
||
|
{
|
||
|
return PlayerPrefs.GetInt(CarUnlockedPrefix + index, index == 0 ? 1 : 0) == 1;
|
||
|
}
|
||
|
|
||
|
public static void UnlockCar(int index)
|
||
|
{
|
||
|
PlayerPrefs.SetInt(CarUnlockedPrefix + index, 1);
|
||
|
}
|
||
|
}
|