当前位置: 首页>>代码示例>>C#>>正文


C# Dictionary.TryGetString方法代码示例

本文整理汇总了C#中Dictionary.TryGetString方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.TryGetString方法的具体用法?C# Dictionary.TryGetString怎么用?C# Dictionary.TryGetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary.TryGetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Buff

 //
 // Constructor that takes the data returned by the
 // GDEDataManager.Get() method and will now pull out the
 // individual fields using the TryGet() methods.
 //
 public Buff(Dictionary<string, object> data)
 {
     if (data != null)
     {
         data.TryGetString("name", out Name);
         data.TryGetInt("hp_delta", out HPDelta);
         data.TryGetInt("mana_delta", out ManaDelta);
         data.TryGetInt("damage_delta", out DamageDelta);
     }
 }
开发者ID:hsienwei,项目名称:ez-item-editor,代码行数:15,代码来源:Buff.cs

示例2: Character

    //
    // Constructor that takes the data returned by the
    // GDEDataManager.Get() method and will now pull out the
    // individual fields using the TryGet() methods.
    //
    public Character(Dictionary<string, object> data)
    {
        if (data != null)
        {
            // Pull out the individual fields and load our Character stats.
            data.TryGetString("name", out Name);
            data.TryGetInt("hp", out baseHP);
            data.TryGetInt("mana", out baseMana);
            data.TryGetInt("damage", out baseDamage);

            //
            // Get the Buff list
            //
            // First get a string list of the buffs using TryGetStringList
            List<string> buffKeyList;
            if (data.TryGetStringList("buffs", out buffKeyList))
            {
                //
                // Spin through each of the Buff names and pull out
                // the data with the GDEDataManager.Get() method.
                //
                Buffs = new List<Buff>();
                foreach(string buffKey in buffKeyList)
                {
                    //
                    // Pull out Buff data with Get() method and pass
                    // it down to the Buff classes constructor where
                    // it will pull out the individual fields and set
                    // it's properties.
                    //
                    Buff curBuff;
                    Dictionary<string, object> curBuffData;
                    GDEDataManager.Instance.Get(buffKey, out curBuffData);

                    //
                    // For each Buff in the string list create a new
                    // object passing it the data from the Get()
                    // method and add it to the Buff's list.
                    //
                    curBuff = new Buff(curBuffData);
                    Buffs.Add(curBuff);

                    //
                    // Now that the Buff's properties have been set
                    // from the data in the Buff's constructor add the
                    // bonuses to the HP, Mana, and Damage.
                    //
                    bonusHP += curBuff.HPDelta;
                    bonusMana += curBuff.ManaDelta;
                    bonusDamage += curBuff.DamageDelta;
                }
            }
        }
    }
开发者ID:hsienwei,项目名称:ez-item-editor,代码行数:59,代码来源:Character.cs

示例3: LoadFromDict

        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetString(descriptionKey, out _description);
                LoadFromSavedData(dataKey);
            }
        }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:12,代码来源:GDEReadSceneCustomData.cs

示例4: DrawSingleField

    void DrawSingleField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        string fieldPreviewKey = schemaKey+"_"+itemKey+"_"+fieldKey;
        string fieldType;
        itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
        }

        content.text = fieldType;
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, labelStyle, out size);
        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);

        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);
        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);

        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
            {
                DrawBool(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Int:
            {
                DrawInt(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Float:
            {
                DrawFloat(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.String:
            {
                DrawString(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Vector2:
            {
                DrawVector2(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector3:
            {
                DrawVector3(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector4:
            {
                DrawVector4(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Color:
            {
                DrawColor(fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.GameObject:
            {
                DrawObject<GameObject>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Texture2D:
            {
                DrawObject<Texture2D>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.Material:
            {
                DrawObject<Material>(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
            }
            case BasicFieldType.AudioClip:
            {
                DrawAudio(fieldPreviewKey, fieldKey, itemData, GDEConstants.ValueLbl);
                drawHelper.NewLine();
                break;
//.........这里部分代码省略.........
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:101,代码来源:GDEItemManagerWindow.cs

示例5: DrawListField

    void DrawListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDEConstants.MetaDataFormat, itemKey, fieldKey);
            bool newFoldoutState;
            bool currentFoldoutState = listFieldFoldoutState.Contains(foldoutKey);
            object defaultResizeValue = null;

            string fieldType;
            itemData.TryGetString(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                if (!fieldTypeEnum.Equals(BasicFieldType.Vector2) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Vector3) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Vector4) &&
                    !fieldTypeEnum.Equals(BasicFieldType.Color))
                    fieldType = fieldType.ToLower();

                defaultResizeValue = GetDefaultValueForType(fieldTypeEnum);
            }

            float width = 120;
            newFoldoutState = EditorGUI.Foldout(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), currentFoldoutState, string.Format("List<{0}>", fieldType), true);
            currentLinePosition += (width + 2);

            width = 120;
            EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            currentLinePosition += (width + 2);

            if (newFoldoutState != currentFoldoutState)
            {
                if (newFoldoutState)
                    listFieldFoldoutState.Add(foldoutKey);
                else
                    listFieldFoldoutState.Remove(foldoutKey);
            }

            object temp = null;
            List<object> list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as List<object>;

            GUIContent content = new GUIContent(GDEStrings.SizeLbl);
            width = GUI.skin.label.CalcSize(content).x;
            EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content);
            currentLinePosition += (width + 2);

            int newListCount;
            string listCountKey = string.Format(GDEConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            width = 40;
            newListCount = EditorGUI.IntField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), newListCount);
            currentLinePosition += (width + 4);

            content.text = GDEStrings.ResizeBtn;
            width = GUI.skin.button.CalcSize(content).x;
            newListCountDict[listCountKey] = newListCount;
            if (newListCount != list.Count && GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
            {
                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                currentLinePosition += (width + 2);
            }

            NewLine();

            if (newFoldoutState)
            {
                for (int i = 0; i < list.Count; i++)
                {
                   currentLinePosition += GDEConstants.Indent*2;

                    switch (fieldTypeEnum) {
                        case BasicFieldType.Bool:
                        {
                            DrawListBool(i, Convert.ToBoolean(list[i]), list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.Int:
                        {
                            DrawListInt(i, Convert.ToInt32(list[i]), list);
                            NewLine();
                            break;
                        }
                        case BasicFieldType.Float:
//.........这里部分代码省略.........
开发者ID:hsienwei,项目名称:ez-item-editor,代码行数:101,代码来源:GDEItemManagerWindow.cs

示例6: Draw2DListField

    void Draw2DListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            object defaultResizeValue;

            string fieldType;
            itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
            }

            content.text = string.Format("List<List<{0}>>", fieldType);
            bool isOpen = DrawFoldout(content.text, foldoutKey, string.Empty, string.Empty, null);

            drawHelper.CurrentLinePosition = Math.Max(drawHelper.CurrentLinePosition, GDEConstants.MinLabelWidth+GDEConstants.Indent+4);
            content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);

            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            drawHelper.CurrentLinePosition += (size.x + 2);

            object temp = null;
            IList list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as IList;

            content.text = GDEConstants.SizeLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            int newListCount;
            string listCountKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            size.x = 40;
            newListCount = EditorGUI.IntField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, drawHelper.StandardHeight()), newListCount);
            drawHelper.CurrentLinePosition += (size.x + 4);

            content.text = GDEConstants.ResizeBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeResizeBtnKey, content, GUI.skin.button, out size);
            newListCountDict[listCountKey] = newListCount;
            if (list != null && newListCount != list.Count && GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
            {
                if (GDEItemManager.IsUnityType(fieldTypeEnum))
                    defaultResizeValue = Activator.CreateInstance(list.GetType().GetGenericArguments()[0]);
                else
                    defaultResizeValue = new List<object>();

                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                drawHelper.CurrentLinePosition += (size.x + 2);
            }

            drawHelper.NewLine();

            if (isOpen)
            {
                defaultResizeValue = GDEItemManager.GetDefaultValueForType(fieldTypeEnum);
                for (int index = 0; index < list.Count; index++)
                {
                    IList subList = list[index] as IList;

                    drawHelper.CurrentLinePosition += GDEConstants.Indent*2;
                    content.text = string.Format("[{0}]:    List<{1}>", index, fieldType);

                    isOpen = DrawFoldout(content.text, foldoutKey+"_"+index, string.Empty, string.Empty, null);
                    drawHelper.CurrentLinePosition += 4;

                    // Draw resize
                    content.text = GDEConstants.SizeLbl;
                    drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
                    EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
                    drawHelper.CurrentLinePosition += (size.x + 2);

                    listCountKey = string.Format(GDMConstants.MetaDataFormat, schemaKey, fieldKey)+"_"+index;
                    if (newListCountDict.ContainsKey(listCountKey))
                    {
                        newListCount = newListCountDict[listCountKey];
                    }
                    else
                    {
                        newListCount = subList.Count;
                        newListCountDict.Add(listCountKey, newListCount);
//.........这里部分代码省略.........
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:101,代码来源:GDEItemManagerWindow.cs

示例7: DrawListField

    void DrawListField(string schemaKey, string itemKey, string fieldKey, Dictionary<string, object> itemData)
    {
        try
        {
            string foldoutKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            bool newFoldoutState;
            bool currentFoldoutState = listFieldFoldoutState.Contains(foldoutKey);
            object defaultResizeValue = null;

            string fieldType;
            itemData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

            BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
            if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
            {
                fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
                fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
                defaultResizeValue = GDEItemManager.GetDefaultValueForType(fieldTypeEnum);
            }

            content.text = string.Format("List<{0}>", fieldType);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, EditorStyles.foldout, out size);
            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            newFoldoutState = EditorGUI.Foldout(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), currentFoldoutState, content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            content.text = fieldKey.HighlightSubstring(filterText, highlightColor);
            drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.LblSuffix, content, labelStyle, out size);
            size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
            GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
            drawHelper.CurrentLinePosition += (size.x + 2);

            if (newFoldoutState != currentFoldoutState)
            {
                if (newFoldoutState)
                    listFieldFoldoutState.Add(foldoutKey);
                else
                    listFieldFoldoutState.Remove(foldoutKey);
            }

            object temp = null;
            IList list = null;

            if (itemData.TryGetValue(fieldKey, out temp))
                list = temp as IList;

            content.text = GDEConstants.SizeLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeSizeLblKey, content, EditorStyles.label, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content);
            drawHelper.CurrentLinePosition += (size.x + 2);

            int newListCount;
            string listCountKey = string.Format(GDMConstants.MetaDataFormat, itemKey, fieldKey);
            if (newListCountDict.ContainsKey(listCountKey))
            {
                newListCount = newListCountDict[listCountKey];
            }
            else
            {
                newListCount = list.Count;
                newListCountDict.Add(listCountKey, newListCount);
            }

            size.x = 40;
            newListCount = EditorGUI.IntField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, drawHelper.StandardHeight()), newListCount);
            drawHelper.CurrentLinePosition += (size.x + 4);

            content.text = GDEConstants.ResizeBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeResizeBtnKey, content, GUI.skin.button, out size);
            newListCountDict[listCountKey] = newListCount;
            if (newListCount != list.Count && GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
            {
                ResizeList(list, newListCount, defaultResizeValue);
                newListCountDict[listCountKey] = newListCount;
                drawHelper.CurrentLinePosition += (size.x + 2);
            }

            drawHelper.NewLine();

            if (newFoldoutState)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    drawHelper.CurrentLinePosition += GDEConstants.Indent*2;
                    content.text = string.Format("[{0}]:", i);

                    switch (fieldTypeEnum) {
                        case BasicFieldType.Bool:
                        {
                            DrawListBool(content, i, Convert.ToBoolean(list[i]), list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Int:
                        {
                            DrawListInt(content, i, Convert.ToInt32(list[i]), list);
                            drawHelper.NewLine();
                            break;
                        }
                        case BasicFieldType.Float:
//.........这里部分代码省略.........
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:101,代码来源:GDEItemManagerWindow.cs

示例8: LoadFromDict

        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetInt(KnockbackKey, out _Knockback);
                dict.TryGetInt(AttackRangeKey, out _AttackRange);
                dict.TryGetInt(CostOfUseKey, out _CostOfUse);
                dict.TryGetInt(numberOfUsesKey, out _numberOfUses);
                dict.TryGetString(itemTypeKey, out _itemType);
                dict.TryGetGameObject(ItemModelKey, out _ItemModel);
                LoadFromSavedData(dataKey);
            }
        }
开发者ID:dirty-casuals,项目名称:Calamity,代码行数:17,代码来源:GDEWeaponItemData.cs

示例9: ShouldFilter

    protected override bool ShouldFilter(string itemKey, Dictionary<string, object> itemData)
    {
        if (itemData == null)
            return true;

        string schemaType = "<unknown>";
        itemData.TryGetString(GDMConstants.SchemaKey, out schemaType);

        // Return if we don't match any of the filter types
        if (GDEItemManager.FilterSchemaKeyArray.IsValidIndex(filterSchemaIndex) &&
            !GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex].Equals(GDEConstants._AllLbl) &&
            !schemaType.Equals(GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex]))
            return true;
        else if (!GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex].Equals(GDEConstants._AllLbl) &&
                 schemaType.Equals(GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex]) &&
                 string.IsNullOrEmpty(filterText))
            return false;

        bool schemaKeyMatch = schemaType.ToLower().Contains(filterText.ToLower());
        bool fieldKeyMatch = !GDEItemManager.ShouldFilterByField(schemaType, filterText);
        bool itemKeyMatch = itemKey.ToLower().Contains(filterText.ToLower());

        // Return if the schema keys don't contain the filter text or
        // if the schema fields don't contain the filter text
        if (!schemaKeyMatch && !fieldKeyMatch && !itemKeyMatch)
            return true;

        return false;
    }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:29,代码来源:GDEItemManagerWindow.cs

示例10: DrawSingleField

    void DrawSingleField(string schemaKey, string fieldKey, Dictionary<string, object> itemData)
    {
        string fieldType;
        itemData.TryGetString(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            if (!fieldTypeEnum.Equals(BasicFieldType.Vector2) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector3) &&
                !fieldTypeEnum.Equals(BasicFieldType.Vector4) &&
                !fieldTypeEnum.Equals(BasicFieldType.Color))
                fieldType = fieldType.ToLower();
        }

        float width = 120;
        EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldType);
        currentLinePosition += (width + 2);

        width = 120;
        EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), fieldKey.HighlightSubstring(filterText, highlightColor), labelStyle);
        currentLinePosition += (width + 2);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
            {
                DrawBool(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Int:
            {
                DrawInt(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Float:
            {
                DrawFloat(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.String:
            {
                DrawString(fieldKey, itemData, GDEStrings.ValueLbl);
                NewLine();
                break;
            }
            case BasicFieldType.Vector2:
            {
                DrawVector2(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector3:
            {
                DrawVector3(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Vector4:
            {
                DrawVector4(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine(GDEConstants.VectorFieldBuffer+1);
                break;
            }
            case BasicFieldType.Color:
            {
                DrawColor(fieldKey, itemData, GDEStrings.ValuesLbl);
                NewLine();
                break;
            }

            default:
            {
                List<string> itemKeys = GetPossibleCustomValues(schemaKey, fieldType);
                DrawCustom(fieldKey, itemData, true, itemKeys);
                NewLine();
                break;
            }
        }
    }
开发者ID:hsienwei,项目名称:ez-item-editor,代码行数:84,代码来源:GDEItemManagerWindow.cs

示例11: LoadFromDict

        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(bool_fieldKey, out _bool_field);
                dict.TryGetInt(int_fieldKey, out _int_field);
                dict.TryGetFloat(float_fieldKey, out _float_field);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetVector4(vector4_fieldKey, out _vector4_field);
                dict.TryGetColor(color_fieldKey, out _color_field);

                string customDataKey;
                dict.TryGetString(custom_fieldKey, out customDataKey);
                GDEDataManager.DataDictionary.TryGetCustom(customDataKey, out _custom_field);
                LoadFromSavedData(dataKey);
            }
        }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:23,代码来源:GDESetSingleData.cs

示例12: LoadFromDict

        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(show_remain_fuelKey, out _show_remain_fuel);
                dict.TryGetBool(long_tap_stage_record_clearKey, out _long_tap_stage_record_clear);
                dict.TryGetBool(soundKey, out _sound);
                dict.TryGetBool(musicKey, out _music);
                dict.TryGetInt(world_countKey, out _world_count);
                dict.TryGetString(versionKey, out _version);
                dict.TryGetString(auto_selected_stage_idKey, out _auto_selected_stage_id);

                dict.TryGetCustomList(stageKey, out stage);
                LoadFromSavedData(dataKey);
            }
        }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:20,代码来源:GDECommonData.cs

示例13: AppendResetVariableMethods

        private static void AppendResetVariableMethods(StringBuilder sb, string schemaKey, Dictionary<string, object> schemaData)
        {
            bool shouldAppendSpace = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection = true;

            string variableType;

            // Append all the single variables first
            foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
            {
                variableType = fieldType.ToString();
                List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), 0);
                foreach(string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace)
                        sb.Append("\n");

                    AppendResetVariableMethod(sb, fieldKey, variableType);
                    shouldAppendSpace = true;
                    isFirstSection = false;
                }
            }

            // Append all list variables
            for(int dimension = 1;  dimension <= 2;  dimension++)
            {
                foreach(BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    variableType = fieldType.ToString();
                    List<string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, variableType, dimension);
                    foreach(string fieldKey in fieldKeys)
                    {
                        if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                        {
                            sb.Append("\n");
                        }

                        AppendResetListVariableMethod(sb, fieldKey, variableType, dimension);
                        shouldAppendSpace = true;
                        didAppendSpaceForSection = true;
                        isFirstSection = false;
                    }
                }
                didAppendSpaceForSection = false;
            }

            // Append all custom variables
            for(int dimension = 0;  dimension <= 2;  dimension++)
            {
                List<string> fieldKeys = GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension);
                foreach(string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);
                    variableType = string.Format(GDECodeGenConstants.DataClassNameFormat, variableType);

                    AppendResetCustomVariableMethod(sb, fieldKey, variableType, dimension);
                    shouldAppendSpace = true;
                    didAppendSpaceForSection = true;
                    isFirstSection = false;
                }

                didAppendSpaceForSection = false;
            }
        }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:70,代码来源:GDECodeGen.cs

示例14: DrawSingleField

    void DrawSingleField(string schemaKey, string fieldKey, Dictionary<string, object> schemaData)
    {
        string fieldPreviewKey = schemaKey+"_"+fieldKey;
        string fieldType;
        schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out fieldType);

        BasicFieldType fieldTypeEnum = BasicFieldType.Undefined;
        if (Enum.IsDefined(typeof(BasicFieldType), fieldType))
        {
            fieldTypeEnum = (BasicFieldType)Enum.Parse(typeof(BasicFieldType), fieldType);
            fieldType = GDEItemManager.GetVariableTypeFor(fieldTypeEnum);
        }

        content.text = fieldType;
        drawHelper.TryGetCachedSize(schemaKey+fieldKey+GDEConstants.TypeSuffix, content, labelStyle, out size);

        size.x = Math.Max(size.x, GDEConstants.MinLabelWidth);
        GUI.Label(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
        drawHelper.CurrentLinePosition += (size.x + 2);

        string editFieldKey = string.Format(GDMConstants.MetaDataFormat, schemaKey, fieldKey);
        DrawEditableLabel(fieldKey, editFieldKey, RenameSchemaField, schemaData);

        switch(fieldTypeEnum)
        {
            case BasicFieldType.Bool:
                DrawBool(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Int:
                DrawInt(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Float:
                DrawFloat(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.String:
                DrawString(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Vector2:
                DrawVector2(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Vector3:
                DrawVector3(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;
            case BasicFieldType.Vector4:
                DrawVector4(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Color:
                DrawColor(fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.GameObject:
                DrawObject<GameObject>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Texture2D:
                DrawObject<Texture2D>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.Material:
                DrawObject<Material>(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            case BasicFieldType.AudioClip:
                DrawAudio(fieldPreviewKey, fieldKey, schemaData, GDEConstants.DefaultValueLbl);
                break;

            default:
                DrawCustom(fieldKey, schemaData, false);
                break;
        }

        content.text = GDEConstants.DeleteBtn;
        drawHelper.TryGetCachedSize(GDEConstants.SizeDeleteBtnKey, content, GUI.skin.button, out size);
        if (fieldTypeEnum.Equals(BasicFieldType.Vector2) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector3) ||
            fieldTypeEnum.Equals(BasicFieldType.Vector4))
        {
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.VerticalMiddleOfLine(), size.x, size.y), content))
                deletedFields.Add(fieldKey);

            drawHelper.NewLine(GDEConstants.VectorFieldBuffer+1);
        }
        else
        {
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content))
                deletedFields.Add(fieldKey);

            drawHelper.NewLine();
        }
    }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:92,代码来源:GDESchemaManagerWindow.cs

示例15: LoadFromDict

        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(bool_fieldKey, out _bool_field);
                dict.TryGetInt(int_fieldKey, out _int_field);
                dict.TryGetFloat(float_fieldKey, out _float_field);
                dict.TryGetString(descriptionKey, out _description);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetColor(color_fieldKey, out _color_field);
                LoadFromSavedData(dataKey);
            }
        }
开发者ID:wang-yichun,项目名称:Sadyrinth,代码行数:19,代码来源:GDESetCustomData.cs


注:本文中的Dictionary.TryGetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。