Ejemplo n.º 1
0
        /// <summary>
        /// Unlock selected achievement
        /// </summary>
        /// <param name="achievement"></param>
        private void UnlockAchievement(Achievement achievement, Text outputHeader, Image outputIcon)
        {
            if (!achievement.GetState())
            {
                if (achievement is ProgressAchievement)
                {
                    ProgressAchievement progressAchievement = (ProgressAchievement)achievement;
                    progressAchievement.AddProgress(100);
                }

                achievement.SetState(true);
                Notify(prefabAchievement, achievement.GetID(), false);
                Output(outputHeader, outputIcon, achievement);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create selected achievement
        /// </summary>
        /// <param name="achievement"></param>
        /// <param name="headerName"></param>
        /// <param name="iconName"></param>
        public void GetAchievementInPrefab(Achievement achievement)
        {
            if (!achievement.GetState())
            {
                GameObject instance = Instantiate(prefabAchievement, achievementsGrid);
                Text       header   = instance.transform.Find(prefabNameHeader).GetComponent <Text>();
                Image      icon     = instance.transform.Find(prefabNameIcon).GetComponent <Image>();

                instance.GetComponent <AchievementElement>().SetAnimationState(true);
                instance.GetComponent <AchievementElement>().SetAchievementID(achievement.GetID());

                UnlockAchievement(achievement, header, icon);

                Destroy(instance, timeOfDestroying);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Output all information achievement
        /// </summary>
        /// <param name="achievement"></param>
        private void OutputInfo(Achievement achievement, Text header, Text state, Image icon)
        {
            header.text = achievement.GetHeader();
            if (achievement.GetState())
            {
                icon.sprite = achievement.GetUnlockedIcon();
                ColorUtility.TryParseHtmlString(unlockColor, out colorState);
                state.color = colorState;

                if (achievement is ProgressAchievement)
                {
                    ProgressAchievement progressAchievement = (ProgressAchievement)achievement;
                    state.text = UNLOCK_STATE + " " + progressAchievement.GetProgress().ToString() + "/" + progressAchievement.MAX_PROGRESS_VALUE.ToString();
                }
                else
                {
                    state.text = UNLOCK_STATE;
                }
            }
            else
            {
                icon.sprite = achievement.GetLockedIcon();
                ColorUtility.TryParseHtmlString(lockColor, out colorState);
                state.color = colorState;

                if (achievement is ProgressAchievement)
                {
                    ProgressAchievement progressAchievement = (ProgressAchievement)achievement;
                    state.text = LOCK_STATE + " " + progressAchievement.GetProgress().ToString() + "/" + progressAchievement.MAX_PROGRESS_VALUE.ToString();
                }
                else
                {
                    state.text = LOCK_STATE;
                }
            }
        }