Exemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    public void SaveClass(Action callBack = null)
    {
#if ULSP
        if (bl_DataBase.Instance != null)
        {
            string dbdata = $"{AssaultClass.ToString()},{EngineerClass.ToString()},{ReconClass.ToString()},{SupportClass.ToString()}";
            bl_DataBase.Instance.LocalUser.metaData.rawData.WeaponsLoadouts = dbdata;
            bl_DataBase.Instance.LocalUser.metaData.rawData.ClassKit        = ClassKit;
            bl_DataBase.Instance.SaveUserMetaData(() => { callBack?.Invoke(); });
        }
        else
        {
            callBack?.Invoke();
        }
#else
        callBack?.Invoke();
#endif
        string key  = string.Format(LOADOUT_KEY_FORMAT, PlayerClass.Assault);
        string data = AssaultClass.ToString();
        PlayerPrefs.SetString(key, data);

        key  = string.Format(LOADOUT_KEY_FORMAT, PlayerClass.Engineer);
        data = EngineerClass.ToString();
        PlayerPrefs.SetString(key, data);

        key  = string.Format(LOADOUT_KEY_FORMAT, PlayerClass.Recon);
        data = ReconClass.ToString();
        PlayerPrefs.SetString(key, data);

        key  = string.Format(LOADOUT_KEY_FORMAT, PlayerClass.Support);
        data = SupportClass.ToString();
        PlayerPrefs.SetString(key, data);

        PlayerPrefs.SetInt(ClassKey.ClassKit, ClassKit);
    }
Exemplo n.º 2
0
    /// <summary>
    ///
    /// </summary>
    void GetID()
    {
        int c = 0;

        if (PlayerPrefs.HasKey(ClassKey.ClassType))
        {
            c = PlayerPrefs.GetInt(ClassKey.ClassType);
        }
        switch (c)
        {
        case 0:
            m_Class = PlayerClass.Assault;
            break;

        case 1:
            m_Class = PlayerClass.Engineer;
            break;

        case 2:
            m_Class = PlayerClass.Support;
            break;

        case 3:
            m_Class = PlayerClass.Recon;
            break;
        }

#if ULSP
        if (bl_DataBase.Instance != null)
        {
            ClassKit = bl_DataBase.Instance.LocalUser.metaData.rawData.ClassKit;
            string dbData = bl_DataBase.Instance.LocalUser.metaData.rawData.WeaponsLoadouts;
            if (!string.IsNullOrEmpty(dbData))
            {
                AssaultClass = Instantiate(DefaultAssaultClass);
                AssaultClass.FromString(dbData, 0);

                EngineerClass = Instantiate(DefaultEngineerClass);
                EngineerClass.FromString(dbData, 1);

                ReconClass = Instantiate(DefaultReconClass);
                ReconClass.FromString(dbData, 2);

                SupportClass = Instantiate(DefaultSupportClass);
                SupportClass.FromString(dbData, 3);
                return;
            }
        }
        else
        {
            Debug.Log("Use local data since player is not logged yet.");
        }
#endif

        ClassKit = PlayerPrefs.GetInt(ClassKey.ClassKit, 0);

        string format = LOADOUT_KEY_FORMAT;
        string key    = string.Format(format, PlayerClass.Assault);

        string data = PlayerPrefs.GetString(key, DefaultAssaultClass.ToString());
        AssaultClass = Instantiate(DefaultAssaultClass);
        AssaultClass.FromString(data);

        key           = string.Format(format, PlayerClass.Engineer);
        data          = PlayerPrefs.GetString(key, DefaultEngineerClass.ToString());
        EngineerClass = Instantiate(DefaultEngineerClass);
        EngineerClass.FromString(data);

        key        = string.Format(format, PlayerClass.Recon);
        data       = PlayerPrefs.GetString(key, DefaultReconClass.ToString());
        ReconClass = Instantiate(DefaultReconClass);
        ReconClass.FromString(data);

        key          = string.Format(format, PlayerClass.Support);
        data         = PlayerPrefs.GetString(key, DefaultSupportClass.ToString());
        SupportClass = Instantiate(DefaultSupportClass);
        SupportClass.FromString(data);
    }