Exemplo n.º 1
0
    public Vector2 GetVector2(string key)
    {
        if (this.ContainsKey(key))
        {
            return(ParseTool.String2Vector2(this[key]));
        }

        if (data.m_defaultValue.ContainsKey(key))
        {
            return(ParseTool.String2Vector2(data.m_defaultValue[key]));
        }

        throw new Exception("Don't Exist Value or DefaultValue by ->" + key + "<- TableName is : ->" + data.m_tableName + "<- singleDataName : ->" + m_SingleDataName + "<-"); // throw
    }
Exemplo n.º 2
0
    public Vector2 GetVector2(string key)
    {
        if (this.ContainsKey(key))
        {
            return(ParseTool.String2Vector2(this[key]));
        }

        if (data.m_defaultValue.ContainsKey(key))
        {
            return(ParseTool.String2Vector2(data.m_defaultValue[key]));
        }

        throw new Exception("Don't Exist Value or DefaultValue by " + key); // throw
    }
Exemplo n.º 3
0
    public static object TableString2ObjectValue(string v, FieldType fieldValueType, string enumType)
    {
        object t = null;

        switch (fieldValueType)
        {
        case FieldType.String:
            t = v;
            break;

        case FieldType.Bool:
            t = bool.Parse(v);
            break;

        case FieldType.Int:
            t = int.Parse(v);
            break;

        case FieldType.Float:
            t = float.Parse(v);
            break;

        case FieldType.Vector2:
            t = ParseTool.String2Vector2(v);
            break;

        case FieldType.Vector3:
            t = ParseTool.String2Vector3(v);
            break;

        case FieldType.Color:
            t = ParseTool.String2Color(v);
            break;

        case FieldType.Enum:
            Type type = ConfigFieldValueType2Type(fieldValueType, enumType);
            t = Enum.Parse(type, v);
            break;

        case FieldType.StringArray:
            t = ParseTool.String2StringArray(v);
            break;

        case FieldType.IntArray:
            t = ParseTool.String2IntArray(v);
            break;

        case FieldType.FloatArray:
            t = ParseTool.String2FloatArray(v);
            break;

        case FieldType.BoolArray:
            t = ParseTool.String2BoolArray(v);
            break;

        case FieldType.Vector2Array:
            t = ParseTool.String2Vector2(v);
            break;

        case FieldType.Vector3Array:
            t = ParseTool.String2Vector3Array(v);
            break;

        default:
            break;
        }

        return(t);
    }
Exemplo n.º 4
0
 public Vector2 GetVector2()
 {
     return(ParseTool.String2Vector2(m_content));
 }
Exemplo n.º 5
0
    /// <summary>
    /// 原始表格字符串类型转换为具体的数据
    /// </summary>
    /// <param name="v"></param>
    /// <param name="fieldValueType"></param>
    /// <param name="enumType"></param>
    /// <returns></returns>
    public static object TableString2ObjectValue(string v, FieldType fieldValueType, string enumType, List <char> m_ArraySplitFormat)
    {
        object t = null;

        switch (fieldValueType)
        {
        case FieldType.String:
            t = v;
            break;

        case FieldType.Bool:
            t = bool.Parse(v);
            break;

        case FieldType.Int:
            t = int.Parse(v);
            break;

        case FieldType.Float:
            t = float.Parse(v);
            break;

        case FieldType.Vector2:
            t = ParseTool.String2Vector2(v);
            break;

        case FieldType.Vector3:
            t = ParseTool.String2Vector3(v);
            break;

        case FieldType.Color:
            t = ParseTool.String2Color(v);
            break;

        case FieldType.Enum:
            Type type = ConfigFieldValueType2Type(fieldValueType, enumType, m_ArraySplitFormat);
            try
            {
                t = Enum.Parse(type, v);
            }
            catch (Exception e)
            {
                t = Enum.GetValues(type).GetValue(0);
                // Debug.LogError("fieldValueType:" + fieldValueType + " enumType:" + enumType + " type:" + type + " v:" + v + "\n"+e);
                throw e;
            }

            break;

        case FieldType.StringArray:

        //t = ParseTool.String2StringArray(v);
        //break;
        case FieldType.IntArray:
        //t = ParseTool.String2IntArray(v);
        //break;
        case FieldType.FloatArray:
        //t = ParseTool.String2FloatArray(v);
        //break;
        case FieldType.BoolArray:
        //t = ParseTool.String2BoolArray(v);
        //break;
        case FieldType.Vector2Array:
        //t = ParseTool.String2Vector2(v);
        //break;
        case FieldType.Vector3Array:
            //t = ParseTool.String2Vector3Array(v);
            t = ParseTool.String2Array(fieldValueType, v, m_ArraySplitFormat.ToArray());
            break;

        default:

            break;
        }

        return(t);
    }