Exemplo n.º 1
0
    private void DoItemFields()
    {
        for (var i = 0; i < filedList.Count; i++)
        {
            FieldData field = filedList[i];
            if (field.fieldName.StartsWith("#A"))
            {
                var pos = field.fieldName.IndexOf("_");
                if (pos >= 0)
                {
                    var realFieldName = field.fieldName.Substring(pos + 1, field.fieldName.Length - pos - 1);
                    field.fieldName = realFieldName;
                    field.objType   = FieldObjectType.ITEM;

                    for (var j = 0; j < field.dataList.Count; j++)
                    {
                        var             temp         = field.dataList[j];
                        var             itemStrArray = temp.Split('|');
                        List <ItemData> itemData     = new List <ItemData>();
                        for (var itemCount = 0; itemCount < itemStrArray.Length; itemCount++)
                        {
                            var strArray = itemStrArray[itemCount].Split(',');
                            if (strArray.Length >= 2)
                            {
                                int type  = 0;
                                int id    = int.Parse(strArray[0]);
                                int count = int.Parse(strArray[1]);

                                if (id < 0)
                                {
                                    id   = 0;
                                    type = Math.Abs(id);
                                }
                                else
                                {
                                    type = 100; //约定100是道具 类型
                                }

                                ItemData item = new ItemData();
                                item.type  = type;
                                item.id    = id;
                                item.count = count;
                                itemData.Add(item);
                            }
                        }

                        field.AddItemList(itemData);
                    }
                }
            }
        }
    }