Beispiel #1
0
    private void OnSuccessConversationEnded()
    {
        // Update the save data with the id of the level we are qualified to go to
        LevelEndingData ending = GameManager.Instance.LevelData.Ending;

        SaveData.QualifyForLevel(ending.GetNextLevelID());

        // Compute the rating for this level
        int rating = LevelRatingSystem.RateCurrentLevel();

        SaveData.SetLevelRating(LevelID.Current(), rating);

        // Save changes to the save data
        SaveData.Save();

        // Let the game manager handle level exiting
        GameManager.Instance.HandleExitLevel();

        // Open the success window
        OpenWindow(successWindow, () => LevelDataLoader.LoadNextLevel(), () => SceneManager.LoadScene("LevelMenu"));
    }
    public void Setup(LevelData enclosure)
    {
        // Get the id for this level
        LevelID current = LevelID.FromSceneName(enclosure.Level.SceneName);

        if (current < SaveData.LatestLevelQualified)
        {
            // Get the rating for this level
            int rating = SaveData.GetLevelRating(current);

            // Only display rating if this level has a rating
            // or if it is one whole level before the latest level qualified
            if (rating >= 0 || current.LevelNumber < SaveData.LatestLevelQualified.LevelNumber)
            {
                // Setup the rating text and rating objects
                ratingText.text = LevelRatingSystem.GetRatingText(rating);

                // Create a rating object for each rating level
                for (int i = 0; i <= rating; i++)
                {
                    Instantiate(ratingObjectPrefab, ratingObjectParent);
                }

                // Make this object enabled
                gameObject.SetActive(true);
            }
            // If this has no rating and it is the same level as the latest level qualified,
            // we do not want to see the rating
            else
            {
                gameObject.SetActive(false);
            }
        }
        // Do not display ratings for levels we are not qualified to complete
        else
        {
            gameObject.SetActive(false);
        }
    }
Beispiel #3
0
 void Start()
 {
     levelRatingSystem = GameObject.Find("LevelRatingSystem").GetComponent <LevelRatingSystem>();
     soundManager      = GameObject.Find("SoundManager").GetComponent <SoundManager>();
 }