Forum rules - please read before posting.

Achievements

Hello,
We have achievements. They have following parameters:

- each achievment has some data, like ID, images etc. that don't need to be saved
- achievment has text fields Name and Description that need to be translated.
- Achievment has a state that needs to be saved.

What we need from AC:
- to gather Name and Description of achievment for translation.
- Save state "achieved/UnAchieved"

Achievements will be used inside the game but also used in stores like Steam,App Store etc.
Any ideas how to better implement this?
Thanks.

Comments

  • gather Name and Description of achievment for translation.

    You can either store each as a Global String variable, which will be included in the "Gather text" process automatically, or rely on a custom ITranslatable implementation.

    See the provided "CustomTranslatableExample" script - if a class that implements ITranslatable is present in a scene, AC will include it in the "Gather text" process. While you could include all achievement data in one script, it'd be easier to rely on one achievement-per-component.

    Something like this:

    using UnityEngine;
    using System.Collections;
    
    namespace AC
    {
    
        public class Achievement : MonoBehaviour, ITranslatable
        {
    
            public string label;
            public int labelLineID = -1;
    
            public string description;
            public int descriptionLineID = -1;
    
            public string GetTranslatableString (int index)
            {
                if (index == 0)
                {
                    return label;
                }
                return description;
            }
    
            public int GetTranslationID (int index)
            {
                if (index == 0)
                {
                    return labelLineID;
                }
                return descriptionLineID;
            }
    
            #if UNITY_EDITOR
    
            public void UpdateTranslatableString (int index, string updatedText)
            {
                if (index == 0)
                {
                    label = updatedText;
                }
                else
                {
                    description = updatedText;
                }
            }
    
            public int GetNumTranslatables ()
            {
                return 2;
            }
    
            public bool CanTranslate (int index)
            {
                if (index == 0)
                {
                    return !string.IsNullOrEmpty (label);
                }
                return !string.IsNullOrEmpty (description);
            }
    
            public bool HasExistingTranslation (int index)
            {
                if (index == 0)
                {
                    return labelLineID >= 0;
                }
                return descriptionLineID >= 0;
            }
    
            public void SetTranslationID (int index, int lineID)
            {
                if (index == 0)
                {
                    labelLineID = lineID;
                }
                else
                {
                    descriptionLineID = lineID;
                }
            }
    
            public string GetOwner (int index)
            {
                return string.Empty;
            }
    
            public bool OwnerIsPlayer (int index)
            {
                return false;
            }
    
            public AC_TextType GetTranslationType (int index)
            {
                return AC_TextType.Custom;
            }
    
            #endif
        }
    
    }
    

    Save state "achieved/UnAchieved"

    This would need to be stored in Global Variables - either a separate Bool for each, or all compressed into a single String and combined/separated with a custom script, i.e. True/False/True would become "1/0/1", and following this tutorial.

    I'd recommend just going with a separate Bool for each. If you name them each "Achievement/One", "Achievement/Two" etc, then they'll be organised into an "Achievement" hierarchy when displayed in Variable selection fields.

    Also, if you want to record these achievements independently of save game files, set their Link to fields to Options Data, so that their states are stored in the PlayerPrefs.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.