Exemplo n.º 1
0
    void Awake()
    {
        if (Instance != null)
        {
            GameObject.Destroy(Instance);
        }
        else
        {
            Instance = this;
        }

        DontDestroyOnLoad(this);

        timeManager   = new SGMTimeManager();
        userManager   = new SGMUserManager();
        unlockManager = new SGMUnlockManager();
        statsManager  = new SGMStatsManager();

        SGMUser user = userManager.GetUserById("test");

        if (user == null)
        {
            user = new SGMUser("test");
        }

        user.Load();
        statsManager.SetValueForStat(user.id, "test2", 25f, true, true);
    }
Exemplo n.º 2
0
    internal SGMUser GetUserById(string a_id)
    {
        SGMUser userFind = null;

        foreach (SGMUser user in _users)
        {
            if (user.id.CompareTo(a_id) == 0)
            {
                userFind = user;
            }
        }

        return(userFind);
    }
Exemplo n.º 3
0
    internal void AddValueForStat(string a_userId, string a_key, float a_value = 1f, bool a_notify = true, bool a_save = false)
    {
        // Get user by ID
        SGMUser user = SGMGameManager.Instance.userManager.GetUserById(a_userId);

        if (user == null)
        {
            return;
        }

        float existingValue = 0f;

        user.stats.TryGetValue(a_key, out existingValue);

        SetValueForStat(a_userId, a_key, existingValue + a_value, a_notify, a_save);
    }
Exemplo n.º 4
0
    internal bool RegisterUser(SGMUser userToAdd)
    {
        bool isAlreadyRgister = false;

        foreach (SGMUser user in _users)
        {
            if (user.id.CompareTo(userToAdd.id) == 0)
            {
                isAlreadyRgister = true;
            }
        }

        if (!isAlreadyRgister)
        {
            _users.Add(userToAdd);
        }

        return(isAlreadyRgister);
    }
Exemplo n.º 5
0
    internal void SetValueForStat(string a_userId, string a_key, float a_value, bool a_notify = true, bool a_save = false)
    {
        // Get user by ID
        SGMUser user = SGMGameManager.Instance.userManager.GetUserById(a_userId);

        if (user == null)
        {
            return;
        }

        // Set the stat
        user.stats[a_key] = a_value;

        if (a_save)
        {
            user.Save();
        }

        // Notify manager
        if (a_notify)
        {
            SGMGameManager.Instance.unlockManager.MajUnlockForData(a_key, a_userId);
        }
    }