Beispiel #1
0
    private static void SavePercent(int levelID, float percent)
    {
        string key = PropertiesStorage.GetPercentKey() + levelID.ToString();

        PlayerPrefs.SetFloat(key, percent);
        PlayerPrefs.Save();
    }
    private float GetPercent(int levelID)
    {
        string key = PropertiesStorage.GetPercentKey() + levelID.ToString();

        if (PlayerPrefs.HasKey(key))
        {
            return(PlayerPrefs.GetFloat(key));
        }
        else
        {
            return(0f);
        }
    }
Beispiel #3
0
    public static float[] LoadPercents()
    {
        int levelCount = LevelContainer.currentLevelContainer.GetLevelCount();

        float[] percents = new float[levelCount - 1];
        string  key;

        for (int i = 0; i < levelCount; i++)
        {
            key = PropertiesStorage.GetPercentKey() + i.ToString();
            if (PlayerPrefs.HasKey(key))
            {
                percents[i] = PlayerPrefs.GetInt(key);
            }
            else
            {
                PlayerPrefs.SetFloat(key, 0f);
                PlayerPrefs.Save();
            }
        }
        return(percents);
    }