-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerPrefsManager.cs
84 lines (70 loc) · 1.69 KB
/
PlayerPrefsManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerPrefsManager : MonoBehaviour
{
const string SCORE = "score";
const string VOLUME = "volume";
const string CHARACTER = "character";
const string DIFFICULTY = "difficulty";
public static void SetScore(float score)
{
if (score > 0)
{
PlayerPrefs.SetFloat(SCORE, score);
}
else
{
Debug.LogError("score menor que 0");
}
}
public static float GetScore()
{
return PlayerPrefs.GetFloat(SCORE);
}
public static void SetVolume(float volumen)
{
if (volumen >= 0 && volumen <= 3)
{
PlayerPrefs.SetFloat(VOLUME, volumen);
}
else
{
Debug.LogError("volume out of bounds");
}
}
public static float GetVolume()
{
return PlayerPrefs.GetFloat(VOLUME);
}
public static void SetCharacter(int pj)
{
if (pj >= 0 && pj <= 2)
{
PlayerPrefs.SetInt(CHARACTER, pj);
}
else
{
Debug.LogError("Pj out of bounds");
}
}
public static int GetCharacter()
{
return PlayerPrefs.GetInt(CHARACTER);
}
public static void SetDifficulty(int dif)
{
if (dif >= 0 && dif < 2)
{
PlayerPrefs.SetInt(DIFFICULTY, dif);
}
else
{
Debug.LogError("Dif out of bounds");
}
}
public static int GetDifficulty()
{
return PlayerPrefs.GetInt(DIFFICULTY);
}
}