コード例 #1
0
        public static List <List <T> > GetCustomTwoDList <T>(string key, string field, List <List <T> > defaultVal) where T : IGDEData
        {
            List <List <T> > retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    retVal = new List <List <T> >();

                    List <List <string> > customDataKeys = GDEDataManager.GetStringTwoDList(key, field, null);

                    if (customDataKeys != null)
                    {
                        foreach (var subListKeys in customDataKeys)
                        {
                            List <T> subList = new List <T>();
                            foreach (var customDataKey in subListKeys)
                            {
                                subList.Add((T)Activator.CreateInstance(typeof(T), new object[] { customDataKey }));
                            }
                            retVal.Add(subList);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #2
0
        public static void RegisterItem(string schema, string key)
        {
            Dictionary <string, object> dict;

            if (!ModifiedData.TryGetValue(key, out dict))
            {
                dict = new Dictionary <string, object>();
                dict.TryAddOrUpdateValue(GDMConstants.SchemaKey, schema);
                ModifiedData.TryAddOrUpdateValue(key, dict);

                HashSet <string> keys;
                DataKeysBySchema.TryGetValue(schema, out keys);

                if (keys != null)
                {
                    keys.Add(key);
                }
                else
                {
                    keys = new HashSet <string>();
                    keys.Add(key);
                    DataKeysBySchema.Add(schema, keys);
                }
            }
        }
コード例 #3
0
        public static List <List <Vector2> > GetVector2TwoDList(string key, string field, List <List <Vector2> > defaultVal = null)
        {
            List <List <Vector2> > retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp) && temp.GetType().IsAssignableFrom(typeof(List <List <GDEV2> >)))
                    {
                        retVal = (temp as List <List <GDEV2> >).ConvertAll(x => {
                            if (x != null)
                            {
                                return(x.ConvertAll(y => (Vector2)y));
                            }
                            return(null);
                        }
                                                                           );
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #4
0
        static void SaveValue(string key, string field, object val)
        {
            Dictionary <string, object> dict;

            if (!ModifiedData.TryGetValue(key, out dict))
            {
                dict = new Dictionary <string, object>();
            }

            dict.TryAddOrUpdateValue(field, val);
            ModifiedData.TryAddOrUpdateValue(key, dict);
        }
コード例 #5
0
        public static void ResetToDefault(string itemName, string fieldName = "")
        {
            Dictionary <string, object> dict;

            if (string.IsNullOrEmpty(fieldName))
            {
                ModifiedData.Remove(itemName);
            }
            else if (ModifiedData.TryGetValue(itemName, out dict))
            {
                dict.Remove(fieldName);
            }
        }
コード例 #6
0
        public static List <List <Vector4> > GetVector4TwoDList(string key, string field, List <List <Vector4> > defaultVal = null)
        {
            List <List <Vector4> > retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = (temp as List <List <GDEV4> >).ConvertAll(x => x.ConvertAll(y => (Vector4)y));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #7
0
        public static Vector4 GetVector4(string key, string field, Vector4 defaultVal)
        {
            Vector4 retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = (GDEV4)temp;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #8
0
        public static List <Color> GetColorList(string key, string field, List <Color> defaultVal = null)
        {
            List <Color> retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = (temp as List <GDEColor>).ConvertAll(x => (Color)x);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #9
0
        public static List <List <bool> > GetBoolTwoDList(string key, string field, List <List <bool> > defaultVal = null)
        {
            List <List <bool> > retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = temp as List <List <bool> >;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #10
0
        public static bool GetBool(string key, string field, bool defaultVal)
        {
            bool retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = Convert.ToBoolean(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #11
0
        public static float GetFloat(string key, string field, float defaultVal)
        {
            float retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = Convert.ToSingle(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #12
0
        public static string GetString(string key, string field, string defaultVal)
        {
            string retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp))
                    {
                        retVal = temp.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }
コード例 #13
0
        public static Vector3 GetVector3(string key, string field, Vector3 defaultVal)
        {
            Vector3 retVal = defaultVal;

            try
            {
                Dictionary <string, object> dict;
                if (ModifiedData.TryGetValue(key, out dict) && dict.ContainsKey(field))
                {
                    object temp;
                    if (dict.TryGetValue(field, out temp) && temp.GetType().IsAssignableFrom(typeof(GDEV3)))
                    {
                        retVal = (GDEV3)temp;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            return(retVal);
        }