public static int GetScore(string name, GameType type, GameMode.Mode mode, GameDifficult.Difficult diff) { JObject jobj; if (!UserData.ContainsKey("myBestScore")) { return(0); } jobj = (JObject)UserData["myBestScore"]; if (!jobj.ContainsKey(type.ToString())) { return(0); } jobj = (JObject)jobj[type.ToString()]; if (!jobj.ContainsKey(name)) { return(0); } jobj = (JObject)jobj[name]; if (!jobj.ContainsKey(mode.ToString())) { return(0); } jobj = (JObject)jobj[mode.ToString()]; if (!jobj.ContainsKey(diff.ToString())) { return(0); } return((int)jobj[diff.ToString()]); }
public static bool SetScore(int score, string name, GameType type, GameMode.Mode mode, GameDifficult.Difficult diff) { if (score == 0) { return(false); } JObject jobj; if (!UserData.ContainsKey("myBestScore")) { UserData["myBestScore"] = new JObject(); } jobj = (JObject)UserData["myBestScore"]; if (!jobj.ContainsKey(type.ToString())) { jobj[type.ToString()] = new JObject(); } jobj = (JObject)jobj[type.ToString()]; if (!jobj.ContainsKey(name)) { jobj[name] = new JObject(); } jobj = (JObject)jobj[name]; if (!jobj.ContainsKey(mode.ToString())) { jobj[mode.ToString()] = new JObject(); } jobj = (JObject)jobj[mode.ToString()]; if (!jobj.ContainsKey(diff.ToString())) { jobj[diff.ToString()] = score; return(true); } var bestScore = (int)jobj[diff.ToString()]; if (score > bestScore) { jobj[diff.ToString()] = score; return(true); } else { return(false); } }