public HighScoresViewModel(IMessenger messenger)
 {
     this.messenger = messenger;
     messenger.Register<HighScoresUpdateMessage>(this, (msg) => UpdateHighScores());
     scoreStorage = new ScoreStorage();
     m_highScores = new ObservableCollection<Score>(scoreStorage.GetScores());
 }
Example #2
0
    private void Awake()
    {
        Instance = this;

        spawnersStopped = false;
        Score           = 0;
        State           = State.MainMenu;
        scoreStorage    = new ScoreStorage();

        soundtrack.Play();
    }
Example #3
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #4
0
    //Score change if win or lose
    public void OnHighScore()
    {
        ScoreStorage ScoreCheck = JsonUtility.FromJson <ScoreStorage>(jsonString);

        ScoreCheck.scoreList.Add(overall);
        ScoreCheck.scoreList = ScoreCheck.scoreList.OrderByDescending(x => x).ToList();

        for (int i = 0; i < highestScoreText.Count; i++)
        {
            highestScoreText[i].text = ScoreCheck.scoreList[i].ToString();
        }

        Debug.Log("Saved JSON string: " + JsonUtility.ToJson(ScoreCheck));

        File.WriteAllText(path, JsonUtility.ToJson(ScoreCheck));
    }