public void LoadLevel(string name, long id) { LevelGenerator.levelName = name; LevelGenerator.levelId = id; levelText.text = name; try { if (levelMetaData == null) { throw new Exception(); } JSONScore score = JSONScoreActions.getJSONScore(id); if (score != null) { timeText.text = GetTimeScore(score.seconds); pointText.text = score.points.ToString(); } else { timeText.text = "--m--s"; pointText.text = "----"; } levelGenerator.InitializeLevelEditor(levelGenerator.ReadLevelJSON()); } catch (Exception e) { Debug.LogException(e, this); Debug.Log("Can't generate level"); } }
public void EndGame() { if (!hasWon) { hasWon = true; LevelEndingInterface.SetActive(true); TextMeshProUGUI[] textmeshes = LevelEndingInterface.GetComponentsInChildren <TextMeshProUGUI>(); textmeshes[0].SetText(nbScore.ToString()); textmeshes[1].SetText(GetTimeScore()); if (!editorMode) { JSONScore newScore = new JSONScore(); newScore.id = LevelGenerator.levelId; newScore.points = nbScore; newScore.seconds = Convert.ToInt64(Time.fixedTime - startingTime); List <JSONScore> list = new List <JSONScore>(); list.Add(newScore); if (JSONScoreActions.addScore(list)) { StartCoroutine(sendScores(newScore.points)); } ScoreUI.SetActive(false); } } }