Exemple #1
0
        /// <summary>
        /// Fill the achievement panel with achievements.
        /// </summary>
        /// <param name="achievementsList">List of the achievements to display.</param>
        public void FillAchievementPanel(Dictionary <string, AchievementDefinition> achievementsList)
        {
            // Clear the achievement panel
            ClearAchievementPanel(false);

            // If there are achievements to display, fill the achievement panel with achievement prefabs
            if ((achievementsList != null) && (achievementsList.Count > 0))
            {
                foreach (KeyValuePair <string, AchievementDefinition> achievement in achievementsList)
                {
                    // Create an achievement item GameObject and hook it at the achievement items layout
                    GameObject prefabInstance = Instantiate <GameObject>(achievementItemPrefab);
                    prefabInstance.transform.SetParent(achievementItemsLayout.transform, false);

                    // Fill the newly created GameObject with achievement data
                    AchievementItemHandler achievementItemHandler = prefabInstance.GetComponent <AchievementItemHandler>();
                    achievementItemHandler.FillData(achievement.Value);

                    // Add the newly created GameObject to the list
                    achievementItems.Add(prefabInstance);
                }
            }
            // Else, show the "no achievement" text
            else
            {
                noAchievementText.SetActive(true);
            }
        }
Exemple #2
0
        /// <summary>
        /// Build an "achievement unlocked" event type then add it to the pending list to display. (events are displayed one by one)
        /// </summary>
        /// <param name="eventMessage">Message of the event. (describes an unlocked achievement)</param>
        /// <param name="achievement">The unlocked achievement under the AchievementDefinition format.</param>
        public void BuildAndAddEventItem_AchievementUnlocked(string eventMessage, AchievementDefinition achievement)
        {
            // Create an event achievement item GameObject
            GameObject achievementItemPrefabInstance = Instantiate <GameObject>(achievementItemPrefab);

            // Fill the newly created GameObject with event friend data
            AchievementItemHandler achievementItemHandler = achievementItemPrefabInstance.GetComponent <AchievementItemHandler>();

            achievementItemHandler.FillData(achievement);

            // Add an event item with the newly created GameObject linked to it
            AddEventItem(eventMessage, achievementItemPrefabInstance);
        }