Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        info = PlayerInfoScript.instance;

        if (info == null)
        {
            Debug.LogError("PlayerInfoScript not found");
        }

        //Update the achievement list and get the index of completion
        int levelIndex = UpdateAchievements(info.GetLevelAchievementIndex(), info.GetLevel(), _levelAchievements, 0);
        int killIndex  = UpdateAchievements(info.GetKillAchievementIndex(), info.GetTotalKills(), _killAchivements, 1);

        _achievementScroller.GetComponent <ScrollRect>().verticalNormalizedPosition = 1; //Automatically scroll to the top

        //If the game hasn't be loaded before, then set the achievement index for each achievement.
        if (!info.HasAchievementBeenLoaded())
        {
            info.SetAchievementLevel(levelIndex);
            info.SetAchievementKillLevel(killIndex);
        }

        //Update the UI for coins and the xp bar
        _levelUIManager.UpdateUIStats();
        OrderAchievements();
    }