Esempio n. 1
0
    /// <summary>
    /// Notify that the level has been finished
    /// </summary>
    /// <param name="stars">Stars earned</param>
    public void LevelFinished(uint stars)
    {
        uint starsGained = 0;

        //Check if it's the fist time that the player pass this level
        if (_selectedLevelNumber == _playerData.current_level)
        {
            _playerData.levels_stars[(int)_selectedLevelNumber] = stars;

            //Add a new level to the player and to the array with 0 stars score, so the player can play it now.
            _playerData.levels_stars.Add(0);
            _playerData.current_level++;

            starsGained = stars;
        }
        else
        {
            //Update the level score
            if (stars >= _playerData.levels_stars[(int)_selectedLevelNumber])
            {
                starsGained = stars - _playerData.levels_stars[(int)_selectedLevelNumber];
                _playerData.levels_stars[(int)_selectedLevelNumber] = stars;
            }
        }



        _playerData.total_stars += starsGained;

        SaveData();
        _ads.ShowBasicAd();
    }