-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataEntry.cs
181 lines (181 loc) · 5.33 KB
/
DataEntry.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DataEntry : MonoBehaviour {
public bool oneTime = true;
public int highScore;
public int orbCount;
public int balance;
public float volume;
public bool sfxMuted;
public bool bgmMuted;
public bool hapticOn;
//PRODUCTION
public int totalCoins;
public string FBTokenString;
public Dictionary<string, int> userStatistics = new Dictionary<string, int> ();
public List<string> carsOwned;
public List<string> trailsOwned;
public bool firstTime;
public List<int> challengesCompleted;
public List<int> challengesToFinish;
public string carUsing;
public string trailUsing;
bool gameOn;
public bool FBLinked = false;
public string FBName = "";
public string AvatarUrl = "";
public bool firstTimeOnDevice;
public int AvatarInd = 0;
public bool UsernameSet = false;
public bool loggedIn = false;
public string displayName = "";
public int dailyHighScore = 0;
public int actualDailyHighScore = 0;
public static DataEntry instance;
PlayerData data;
bool setFailed = false;
void Awake () {
instance = this;
DontDestroyOnLoad (this);
//Reloads Saved Data
carsOwned.Add ("C0002");
trailsOwned.Add ("T0001");
carUsing = "C0002";
trailUsing = "T0001";
firstTime = true;
balance = 0;
totalCoins = 0;
orbCount = 0;
dailyHighScore = 0;
actualDailyHighScore = 0;
firstTimeOnDevice = true;
volume = 1f;
//SANDBOX
try {
SetFromFile ();
} catch {
setFailed = true;
}
}
void Start () {
//SetFromFile ();
if (setFailed) {
if (Debug.isDebugBuild) {
//print ("Set failed");
}
Save ();
setFailed = false;
}
}
public void SetFromFile () {
data = SaveData.LoadData ();
firstTimeOnDevice = data.firstTimeOnDevice;
AvatarInd = data.AvatarInd;
AvatarUrl = data.AvatarUrl;
carUsing = data.carUsing;
trailUsing = data.trailUsing;
carsOwned = data.ownedCars;
trailsOwned = data.ownedTrails;
sfxMuted = data.sfxMuted;
bgmMuted = data.bgmMuted;
hapticOn = data.hapticOn;
volume = data.volume;
dailyHighScore = data.dailyHighScore;
actualDailyHighScore = data.actualDailyHighScore;
FBTokenString = data.FBTokenString;
firstTime = data.firstTime;
challengesCompleted = data.challengesCompleted;
challengesToFinish = data.challengesToFinish;
highScore = data.stats[0];
orbCount = data.stats[1];
totalCoins = data.stats[2];
balance = data.stats[3];
userStatistics = data.userStatistics;
displayName = data.displayName;
UsernameSet = data.UsernameSet;
}
public void UpdateUserStatistics (Dictionary<string, int> dict) {
userStatistics = dict;
}
public void UpdateVolume (float val) {
volume = val;
}
public void UpdateHaptic (bool haptic) {
hapticOn = haptic;
//print ("haptic is now " + haptic);
}
public void UpdateSFXMute (bool thismuted) {
sfxMuted = thismuted;
}
public void UpdateBGMMute (bool thismuted) {
bgmMuted = thismuted;
}
public void UpdateHighScore (int score) {
highScore = score;
}
public void UpdateDailyHighScore (int score) {
dailyHighScore = score;
}
public void UpdateActualDailyHighScore (int score) {
actualDailyHighScore = score;
}
public void UpdateFBToken (string token) {
FBTokenString = token;
}
public void UpdateCoins (int coins) {
totalCoins = coins;
}
public void UpdateOrbs (int orbs) {
orbCount = orbs;
}
public void UpdateBalance (int bal) {
balance = bal;
}
public void UpdateCarsOwned (List<string> list) {
carsOwned = list;
}
public void UpdateTrailsOwned (List<string> list) {
trailsOwned = list;
}
public void UpdateChallengesToFinish (List<int> chal) {
challengesToFinish = chal;
}
public void UpdateChallengesCompleted (List<int> chal) {
challengesCompleted = chal;
}
public void UpdateCarUsing (string ind) {
carUsing = ind;
}
public void UpdateTrailUsing (string ind) {
trailUsing = ind;
}
public void UpdateFacebookLinked (bool linked, string name = "") {
FBLinked = linked;
FBName = name;
}
public void UpdateUsernameSet (bool boolean) {
UsernameSet = boolean;
}
public void UpdateDisplayName (string name) {
displayName = name;
}
public void BuyCar (string id) {
totalCoins = StoreController.instance.newCoinCount;
carsOwned.Add (id);
StoreCoinCountController.UpdateValue ();
}
public void BuyTrail (string id) {
orbCount = StoreController.instance.newOrbCount;
trailsOwned.Add (id);
StoreOrbCount.UpdateValue ();
}
public void UpdateAvatarUrlInd (string url, int ind) {
AvatarUrl = url;
AvatarInd = ind;
}
public void Save () {
SaveData.Save (this);
}
}