public void SaveScore() { string name = InputName.text.Replace("\"", ""); name = name.Length > 15 ? name.Substring(0, 15) : name; HighScore newScore = new HighScore() { Player = name, Score = score }; StartCoroutine(WaitForRequest(HighscoreAPI.SaveScore(newScore))); btnSaveScore.gameObject.SetActive(false); InputName.gameObject.SetActive(false); }
private void LoadStats() { HighscoreAPI api = new HighscoreAPI(this); Api = api.PlayerAPI; string[] skillSet = Api.Split(',', '\n'); for (int i = 0, j = 0; i < Constants.SkillCount; i++) { Stats.Add(new Skill()); Stats[i].SkillName = Constants.SkillNames[i]; Stats[i].Rank = long.Parse(skillSet[j++]); Stats[i].Level = long.Parse(skillSet[j++]); Stats[i].XP = long.Parse(skillSet[j++]); } }
private IEnumerator WaitForRequest(WWW www) { yield return(www); // check for errors if (www.error == null) { txtScores.text = ""; List <HighScore> scores = HighscoreAPI.ConvertStringToHighscores(www.text); foreach (HighScore hs in scores) { txtScores.text += hs.Player + " : " + hs.Score + "\r\n"; } } else { Debug.Log(www.error); } }
private void Awake() { WWW scores = HighscoreAPI.GetScores(); StartCoroutine(WaitForRequest(scores)); }