Exemplo 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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add progress to selected achievement
        /// </summary>
        /// <param name="achievement"></param>
        /// <param name="count"></param>
        public void AddProgressAchievement(ProgressAchievement achievement, byte count)
        {
            if (!achievement.GetState())
            {
                achievement.AddProgress(count);
                achievement.Check();
                Notify(prefabAchievement, achievement.GetID(), true);

                if (achievement.Check())
                {
                    Notify(prefabAchievement, achievement.GetID(), false);
                    Output(achievement_header, achievement_icon, achievement);
                }
            }
        }
Exemplo 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;
                }
            }
        }