示例#1
0
    // Display (known / locally present) art using the slot settings.
    public void DisplayArt(SlotSettings slot)
    {
        ArtMetaData meta = slot.MetaData;
        string      tag  = slotNrToTag(slot.SlotNumber);

        DisplayArt(meta, tag);
    }
示例#2
0
    private void ReceiveArtAssetRPC(byte[] asset, byte[] hash)
    {
        Checksum     checksum = Serial.DeserializeByteArray <Checksum>(hash);
        SlotSettings slot     = slotSettings[checksum];

        ImportAsset(asset, slot.MetaData);
        DisplayArt(slot);

        // Transfer of asset complete.
    }
            public void Initialize(JsonObject properties, ModelTransform defaultTansform)
            {
                _dict.Clear();
                if (properties?.Exists != true)
                {
                    if (!DEFAULT_ANIMATION.TryGetValue(CarrySlot.Hands, out var anim))
                    {
                        anim = null;
                    }
                    _dict.Add(CarrySlot.Hands, new SlotSettings {
                        Animation = anim
                    });
                }
                else
                {
                    foreach (var slot in Enum.GetValues(typeof(CarrySlot)).Cast <CarrySlot>())
                    {
                        var slotProperties = properties[slot.ToString()];
                        if (slotProperties?.Exists != true)
                        {
                            continue;
                        }

                        if (!_dict.TryGetValue(slot, out var settings))
                        {
                            if (!DEFAULT_ANIMATION.TryGetValue(slot, out var anim))
                            {
                                anim = null;
                            }
                            _dict.Add(slot, settings = new SlotSettings {
                                Animation = anim
                            });
                        }

                        settings.Transform = GetTransform(slotProperties, defaultTansform);
                        settings.Animation = slotProperties["animation"].AsString(settings.Animation);

                        if (!DEFAULT_WALKSPEED.TryGetValue(slot, out var speed))
                        {
                            speed = 0.0F;
                        }
                        settings.WalkSpeedModifier = slotProperties["walkSpeedModifier"].AsFloat(speed);
                    }
                }
            }
示例#4
0
    private void ReceiveManifestRPC(byte[] manifest)
    {
        // XXX: For testing. Simulate that client has no art assets.
        //artReg = ArtRegistry.GetEmptyArtRegistry();
        ArtManifest artManifest = Serial.DeserializeByteArray <ArtManifest>(manifest);

        slotSettings = new Dictionary <Checksum, SlotSettings>();
        List <Checksum> missing = new List <Checksum>();

        foreach (SlotSettings slot in artManifest.Slots)
        {
            SlotSettings ss       = slot;
            Checksum     checksum = slot.MetaData.Checksum;
            if (artReg.HasArt(checksum))
            {
                Debug.Log("Visitor already has art " + checksum.ToString());
                // Use existing meta data from registry.
                ss = slot.WithMeta(artReg.Get(checksum));
                slotSettings.Add(checksum, ss);
                DisplayArt(ss);
            }
            else
            {
                ArtMetaData absolute = ss.MetaData.MakeAbsolutePath(root);
                ss = slot.WithMeta(absolute);
                slotSettings.Add(ss.MetaData.Checksum, ss);
                if (alreadyDownloaded(ss.MetaData))
                {
                    artReg.AddArt(absolute);
                    DisplayArt(ss);
                }
                else
                {
                    Debug.Log("Visitor does NOT have art " + checksum.ToString());
                    missing.Add(checksum);
                    // TODO:
                    // instantiate some place holder for missing?
                }
            }
        }
        if (missing.Count > 0)
        {
            RequestArtAssets(missing);
        }
    }
示例#5
0
    void DrawFieldView()
    {
        int2 key = null;

        for (int x = 0; x < profile.width; x++)
        {
            for (int y = 0; y < profile.height; y++)
            {
                key = new int2(x, y);
                if (DrawSlotButton(key, rect))
                {
                    if (wait_target)
                    {
                        if (slots.ContainsKey(key))
                        {
                            target_selection = slots[key];
                            continue;
                        }
                        else
                        {
                            wait_target = false;
                        }
                    }

                    if (Event.current.shift && selected.Count > 0)
                    {
                        int2 start = selected.Last().GetClone();
                        int2 delta = new int2();
                        delta.x = start.x < x ? 1 : -1;
                        delta.y = start.y < y ? 1 : -1;
                        int2 cursor = new int2();
                        for (cursor.x = start.x; cursor.x != x + delta.x; cursor.x += delta.x)
                        {
                            for (cursor.y = start.y; cursor.y != y + delta.y; cursor.y += delta.y)
                            {
                                if (!selected.Contains(cursor))
                                {
                                    selected.Add(cursor.GetClone());
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Event.current.control)
                        {
                            selected.Clear();
                        }
                        if (selected.Contains(key))
                        {
                            selected.Remove(key);
                        }
                        else
                        {
                            selected.Add(key);
                        }
                    }
                }
            }
        }

        for (int x = 0; x < profile.width; x++)
        {
            GUI.Box(new Rect(rect.xMin + x * (cellSize + slotOffset) + legendSize,
                             rect.yMin + (profile.height) * (cellSize + slotOffset), cellSize, legendSize), x.ToString(), EditorStyles.centeredGreyMiniLabel);
        }
        for (int y = 0; y < profile.height; y++)
        {
            GUI.Box(new Rect(rect.xMin, rect.yMin + (profile.height - y - 1) * (cellSize + slotOffset) + slotOffset,
                             legendSize, cellSize), y.ToString(), EditorStyles.centeredGreyMiniLabel);
        }
    }
示例#6
0
    void DrawSlotSettings()
    {
        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true), GUILayout.Height(170));

        if (selected.Count == 0)
        {
            GUILayout.Label("Nothing selected", EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
            EditorGUILayout.EndVertical();
            return;
        }

        #region Slots property
        DrawMixedProperty(
            mask: (int2 coord) => {
            return(true);
        },
            getValue: (int2 coord) => { return(slots.ContainsKey(coord)); },
            setValue: (int2 coord, bool value) => {
            if (value && !slots.ContainsKey(coord))
            {
                NewSlotSettings(coord);
            }
            if (!value && slots.ContainsKey(coord))
            {
                slots.Remove(coord);
            }
        },
            drawSingle: (bool value) => { return(EditorGUILayout.Toggle("Active", value)); },
            drawMixed: (Action <bool> setDefault) => {
            if (EditorGUILayout.Toggle("Active", false))
            {
                setDefault(true);
                return(true);
            }
            return(false);
        });
        #endregion

        #region Generators property
        DrawMixedProperty(
            mask: (int2 coord) => {
            return(slots.ContainsKey(coord));
        },
            getValue: (int2 coord) => { return(slots[coord].generator); },
            setValue: (int2 coord, bool value) => {
            slots[coord].generator = value;
        },
            drawSingle: (bool value) => {
            return(EditorGUILayout.Toggle("Generator", value));
        },
            drawMixed: (Action <bool> setDefault) => {
            if (EditorGUILayout.Toggle("Generator", false))
            {
                setDefault(true);
                return(true);
            }
            return(false);
        });
        #endregion

        #region Sugar drop target property
        if (profile.target == FieldTarget.SugarDrop)
        {
            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord));
            },
                getValue: (int2 coord) => {
                return(slots[coord].tags.Contains("SugarDrop"));
            },
                setValue: (int2 coord, bool value) => {
                if (!value && slots[coord].tags.Contains("SugarDrop"))
                {
                    slots[coord].tags.Remove("SugarDrop");
                }
                else if (value && !slots[coord].tags.Contains("SugarDrop"))
                {
                    slots[coord].tags.Add("SugarDrop");
                }
            },
                drawSingle: (bool value) => {
                return(EditorGUILayout.Toggle("Sugar Drop slot", value));
            },
                drawMixed: (Action <bool> setDefault) => {
                if (EditorGUILayout.Toggle("Sugar Drop slot", false))
                {
                    setDefault(true);
                    return(true);
                }
                return(false);
            });
        }
        #endregion

        #region Gravity property
        Dictionary <int, string> gravity = Utils.straightSides.ToDictionary(x => (int)x, x => x.ToString());
        gravity.Add((int)Side.Null, Side.Null.ToString());
        DrawMixedProperty(
            mask: (int2 coord) => {
            return(slots.ContainsKey(coord));
        },
            getValue: (int2 coord) => { return(slots[coord].gravity); },
            setValue: (int2 coord, Side value) => {
            slots[coord].gravity = value;
        },
            drawSingle: (Side value) => {
            return((Side)EditorGUILayout.IntPopup("Gravity", (int)value, gravity.Values.ToArray(), gravity.Keys.ToArray()));
        },
            drawMixed: (Action <Side> setDefault) => {
            int side = EditorGUILayout.IntPopup("Gravity", -1, gravity.Values.ToArray(), gravity.Keys.ToArray());
            if (side != -1)
            {
                setDefault((Side)side);
                return(true);
            }
            return(false);
        });
        #endregion

        #region Chip property
        if (SessionAssistant.main.chipInfos.Count > 0)
        {
            List <string> chips = new List <string>();
            chips.Add("Empty");
            foreach (SessionAssistant.ChipInfo chip in SessionAssistant.main.chipInfos)
            {
                if (!chips.Contains(chip.name))
                {
                    chips.Add(chip.name);
                }
            }


            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord) && (slots[coord].block_type == "" || blockInfos[slots[coord].block_type].chip));
            },
                getValue: (int2 coord) => { return(slots[coord].chip); },
                setValue: (int2 coord, string value) => {
                slots[coord].chip = value;
                if (!chipInfos.ContainsKey(value) || !chipInfos[value].color)
                {
                    slots[coord].color_id = -1;
                }
            },
                drawSingle: (string value) => {
                int id = chips.IndexOf(value);
                if (id == -1)
                {
                    id = 0;
                }
                id = EditorGUILayout.Popup("Chip type", id, chips.ToArray());
                return(chips[id] == "Empty" ? "" : chips[id]);
            },
                drawMixed: (Action <string> setDefault) => {
                int id = EditorGUILayout.Popup("Chip type", -1, chips.ToArray());
                if (id != -1)
                {
                    setDefault(chips[id] == "Empty" ? "" : chips[id]);
                    return(true);
                }
                return(false);
            });
        }
        #endregion

        #region Chip color property
        List <string> colors = new List <string>();
        colors.Add("Random");
        for (int i = 0; i < profile.colorCount; i++)
        {
            colors.Add(Chip.chipTypes[i]);
        }
        DrawMixedProperty(
            mask: (int2 coord) => {
            return(slots.ContainsKey(coord) && slots[coord].chip != "" && chipInfos[slots[coord].chip].color);
        },
            getValue: (int2 coord) => { return(slots[coord].color_id); },
            setValue: (int2 coord, int value) => {
            slots[coord].color_id = value;
        },
            drawSingle: (int value) => {
            return(EditorGUILayout.Popup("Chip color group", Mathf.Max(0, value), colors.ToArray()));
        },
            drawMixed: (Action <int> setDefault) => {
            int id = EditorGUILayout.Popup("Chip color group", -1, colors.ToArray());
            if (id != -1)
            {
                setDefault(id);
                return(true);
            }
            return(false);
        });
        #endregion

        #region Jelly level property
        if (profile.target == FieldTarget.Jelly)
        {
            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord));
            },
                getValue: (int2 coord) => {
                return(slots[coord].jelly_level);
            },
                setValue: (int2 coord, int value) => {
                slots[coord].jelly_level = value;
            },
                drawSingle: (int value) => {
                return(Mathf.RoundToInt(EditorGUILayout.Slider("Jelly level", value, 0, 3)));
            },
                drawMixed: (Action <int> setDefault) => {
                float level = EditorGUILayout.Slider("Jelly level", -1, -1, 3);
                if (level != -1)
                {
                    setDefault(Mathf.RoundToInt(level));
                    return(true);
                }
                return(false);
            });
        }
        #endregion

        #region Jam property
        if (profile.target == FieldTarget.Jam)
        {
            List <string> options = new List <string>();
            options.Add("None");
            options.Add("Jam A");
            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord));
            },
                getValue: (int2 coord) => {
                if (slots[coord].jam == "")
                {
                    return("None");
                }
                return(slots[coord].jam);
            },
                setValue: (int2 coord, string value) => {
                slots[coord].jam = value == "None" ? "" : value;
            },
                drawSingle: (string value) => {
                if (options.Count == 2)
                {
                    if (EditorGUILayout.Toggle("Jam", value != options[0]))
                    {
                        return(options[1]);
                    }
                    else
                    {
                        return(options[0]);
                    }
                }
                return(options[EditorGUILayout.Popup("Jam", options.IndexOf(value), options.ToArray())]);
            },
                drawMixed: (Action <string> setDefault) => {
                if (options.Count == 2)
                {
                    if (EditorGUILayout.Toggle("Jam", false))
                    {
                        setDefault(options[1]);
                        return(true);
                    }
                }
                else
                {
                    int id = EditorGUILayout.Popup("Jam", -1, options.ToArray());
                    if (id != -1)
                    {
                        setDefault(options[id]);
                        return(true);
                    }
                }
                return(false);
            });
        }
        #endregion

        #region Block property
        if (SessionAssistant.main.blockInfos.Count > 0)
        {
            Dictionary <string, SessionAssistant.BlockInfo> blocks = new Dictionary <string, SessionAssistant.BlockInfo>();
            blocks.Add("Empty", null);
            foreach (SessionAssistant.BlockInfo block in SessionAssistant.main.blockInfos)
            {
                if (!blocks.ContainsKey(block.name))
                {
                    blocks.Add(block.name, block);
                }
            }
            List <string> block_keys = new List <string>(blocks.Keys);

            #region Block type
            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord));
            },
                getValue: (int2 coord) => {
                return(slots[coord].block_type);
            },
                setValue: (int2 coord, string value) => {
                slots[coord].block_type = value;
                if (value != "" && !blockInfos[value].chip)
                {
                    slots[coord].chip = "";
                }
            },
                drawSingle: (string value) => {
                int id = block_keys.IndexOf(value);
                if (id == -1)
                {
                    id = 0;
                }
                id = EditorGUILayout.Popup("Block type", id, block_keys.ToArray());
                return(block_keys[id] == "Empty" ? "" : block_keys[id]);
            },
                drawMixed: (Action <string> setDefault) => {
                int id = EditorGUILayout.Popup("Block type", -1, block_keys.ToArray());
                if (id != -1)
                {
                    setDefault(block_keys[id] == "Empty" ? "" : block_keys[id]);
                    return(true);
                }
                return(false);
            });
            #endregion

            #region Block level
            int max = 1000;
            DrawMixedProperty(
                mask: (int2 coord) => {
                if (!slots.ContainsKey(coord) || slots[coord].block_type == "" || blocks[slots[coord].block_type].levelCount <= 1)
                {
                    return(false);
                }
                max = Mathf.Min(max, blocks[slots[coord].block_type].levelCount);
                return(true);
            },
                getValue: (int2 coord) => {
                return(slots[coord].block_level);
            },
                setValue: (int2 coord, int value) => {
                slots[coord].block_level = value;
            },
                drawSingle: (int value) => {
                return(Mathf.RoundToInt(EditorGUILayout.Slider("Block level", value + 1, 1, max)) - 1);
            },
                drawMixed: (Action <int> setDefault) => {
                float level = EditorGUILayout.Slider("Block level", -1, -1, max);
                if (level != -1)
                {
                    setDefault(Mathf.RoundToInt(level) - 1);
                    return(true);
                }
                return(false);
            });
            #endregion
        }
        #endregion

        #region Teleport property
        DrawMixedProperty(
            mask: (int2 coord) => {
            return(slots.ContainsKey(coord));
        },
            getValue: (int2 coord) => {
            return(slots[coord].teleport);
        },
            setValue: (int2 coord, int2 value) => {
            if (coord == value || value == null)
            {
                slots[coord].teleport = int2.Null;
            }
            else
            {
                slots[coord].teleport = value;
            }
        },
            drawSingle: (int2 value) => {
            EditorGUILayout.BeginHorizontal();
            defaultColor = GUI.color;
            if (wait_target)
            {
                GUI.color = Color.cyan;
            }
            GUILayout.Label("Teleport", GUILayout.ExpandWidth(true));
            int2 result = value;
            if (GUILayout.Button(value == int2.Null ? "None" : value.ToString(), EditorStyles.miniButton, GUILayout.Width(60)))
            {
                wait_target      = true;
                target_selection = null;
            }
            if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)))
            {
                wait_target      = false;
                target_selection = null;
                result           = int2.Null;
            }
            EditorGUILayout.EndHorizontal();
            if (wait_target && target_selection != null)
            {
                wait_target = false;
                result      = target_selection.position;
            }
            GUI.color = defaultColor;
            return(result);
        },
            drawMixed: (Action <int2> setDefault) => {
            EditorGUILayout.BeginHorizontal();
            defaultColor = GUI.color;
            if (wait_target)
            {
                GUI.color = Color.cyan;
            }
            GUILayout.Label("Teleport", GUILayout.ExpandWidth(true));
            bool result = false;
            if (GUILayout.Button("-", GUILayout.Width(60)))
            {
                wait_target      = true;
                target_selection = null;
            }
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                wait_target      = false;
                target_selection = null;
                result           = true;
                setDefault(int2.Null);
            }
            EditorGUILayout.EndHorizontal();
            if (wait_target && target_selection != null)
            {
                wait_target = false;
                result      = true;
                setDefault(target_selection.position);
            }
            GUI.color = defaultColor;
            return(result);
        });
        #endregion

        #region Walls property
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Walls", GUILayout.ExpandWidth(true));

        foreach (Side side in Utils.straightSides)
        {
            DrawMixedProperty(
                mask: (int2 coord) => {
                return(slots.ContainsKey(coord) && slots.ContainsKey(coord + side));
            },
                getValue: (int2 coord) => {
                return(IsWall(coord, side));
            },
                setValue: (int2 coord, bool value) => {
                if (value != IsWall(coord, side))
                {
                    SetWall(coord, side, value);
                }
            },
                drawSingle: (bool value) => {
                return(GUILayout.Toggle(value, side.ToString(), EditorStyles.miniButtonMid, GUILayout.Width(55)));
            },
                drawMixed: (Action <bool> setDefault) => {
                if (GUILayout.Toggle(false, "[" + side.ToString() + "]", EditorStyles.miniButtonMid, GUILayout.Width(55)))
                {
                    setDefault.Invoke(true);
                    return(true);
                }
                return(false);
            },
                drawEmpty: () => {
                GUILayout.Space(55);
            });
        }

        EditorGUILayout.EndHorizontal();
        #endregion

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
    }
示例#7
0
    LevelProfile OldXmlToLevelProfile(XmlNode node)
    {
        LevelProfile level = new LevelProfile();

        foreach (XmlAttribute attribute in node.Attributes)
        {
            if (attribute.Name == "number")
            {
                level.level = int.Parse(attribute.Value);
            }
            if (attribute.Name == "width")
            {
                level.width = int.Parse(attribute.Value);
            }
            if (attribute.Name == "height")
            {
                level.height = int.Parse(attribute.Value);
            }
            if (attribute.Name == "color_count")
            {
                level.colorCount = int.Parse(attribute.Value);
            }
            if (attribute.Name == "stones")
            {
                level.stonePortion = float.Parse(attribute.Value);
            }
            if (attribute.Name == "star1")
            {
                level.firstStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "star2")
            {
                level.secondStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "star3")
            {
                level.thirdStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "limitation")
            {
                level.limitation = (Limitation)System.Enum.Parse(typeof(Limitation), attribute.Value);
            }
            if (attribute.Name == "limit")
            {
                level.limit = int.Parse(attribute.Value);
            }
            if (attribute.Name == "target")
            {
                level.target = (FieldTarget)System.Enum.Parse(typeof(FieldTarget), attribute.Value);
            }
            if (attribute.Name == "target_color_count")
            {
                level.targetColorCount = int.Parse(attribute.Value);
            }
            if (attribute.Name == "target_color_values")
            {
                level.countOfEachTargetCount = attribute.Value.Split(',').ToArray().Select(x => int.Parse(x)).ToArray();
            }
            if (attribute.Name == "target_sdrop_count")
            {
                level.targetSugarDropsCount = int.Parse(attribute.Value);
            }
        }

        foreach (XmlNode child in node.ChildNodes)
        {
            int x = -1;
            int y = -1;
            foreach (XmlAttribute attribute in child.Attributes)
            {
                if (attribute.Name == "x")
                {
                    x = int.Parse(attribute.Value);
                }
                if (attribute.Name == "y")
                {
                    y = int.Parse(attribute.Value);
                }
            }
            if (x == -1 || y == -1)
            {
                continue;
            }
            y = level.height - y - 1;
            if (child.Name == "slot")
            {
                SlotSettings slot = new SlotSettings(new int2(x, y));
                slot.chip = "SimpleChip";
                level.slots.Add(slot);
                foreach (XmlAttribute attribute in child.Attributes)
                {
                    if (attribute.Name == "generator")
                    {
                        slot.generator = true;
                    }
                    if (attribute.Name == "jelly")
                    {
                        slot.jelly_level = int.Parse(attribute.Value);
                    }
                    if (attribute.Name == "block")
                    {
                        int id = int.Parse(attribute.Value);
                        if (id > 0 && id <= 3)
                        {
                            slot.block_type  = "Block";
                            slot.block_level = id;
                            slot.chip        = "";
                        }
                        if (id == 4)
                        {
                            slot.block_type = "Weed";
                            slot.chip       = "";
                        }
                        if (id == 5)
                        {
                            slot.block_type = "Branch";
                        }
                    }
                    if (attribute.Name == "teleport")
                    {
                        int id = int.Parse(attribute.Value) - 1;
                        slot.teleport   = new int2(0, 0);
                        slot.teleport.y = level.height - Mathf.FloorToInt(1f * id / 12) - 1;
                        slot.teleport.x = id % 12;
                    }

                    if (attribute.Name == "gravity")
                    {
                        switch (int.Parse(attribute.Value))
                        {
                        case 0: slot.gravity = Side.Bottom; break;

                        case 1: slot.gravity = Side.Left; break;

                        case 2: slot.gravity = Side.Top; break;

                        case 3: slot.gravity = Side.Right; break;
                        }
                    }

                    if (attribute.Name == "sugar_drop")
                    {
                        slot.tags.Add("SugarDrop");
                    }
                    if (attribute.Name == "chip")
                    {
                        int id = int.Parse(attribute.Value);

                        slot.color_id = id;
                        if (id == -1)
                        {
                            slot.chip = "";
                        }

                        if (id == 9)
                        {
                            slot.color_id = Chip.uncoloredId;
                            slot.chip     = "Stone";
                        }
                    }
                    if (attribute.Name == "powerup")
                    {
                        switch (int.Parse(attribute.Value))
                        {
                        case 1: slot.chip = "CrossBomb"; break;

                        case 2: slot.chip = "SimpleBomb"; break;

                        case 3: slot.chip = "ColorBomb"; break;

                        case 4: slot.chip = "RaindowBomb"; break;

                        case 5: slot.chip = "Ladybird"; break;

                        case 6: slot.chip = "HLineBomb"; break;

                        case 7: slot.chip = "VLineBomb"; break;

                        case 8: slot.chip = "UltraColorBomb"; break;
                        }
                    }
                }
            }
            if (child.Name == "wallh")
            {
                level.wall_horizontal.Add(new int2(x, y));
            }
            if (child.Name == "wallv")
            {
                level.wall_vertical.Add(new int2(x + 1, y));
            }
        }
        return(level);
    }
示例#8
0
    LevelProfile XmlToLevelProfile(XmlNode node)
    {
        LevelProfile level = new LevelProfile();

        foreach (XmlAttribute attribute in node.Attributes)
        {
            if (attribute.Name == "number")
            {
                level.level = int.Parse(attribute.Value);
            }
            if (attribute.Name == "width")
            {
                level.width = int.Parse(attribute.Value);
            }
            if (attribute.Name == "height")
            {
                level.height = int.Parse(attribute.Value);
            }
            if (attribute.Name == "color_count")
            {
                level.colorCount = int.Parse(attribute.Value);
            }
            if (attribute.Name == "stones")
            {
                level.stonePortion = float.Parse(attribute.Value);
            }
            if (attribute.Name == "star1")
            {
                level.firstStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "star2")
            {
                level.secondStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "star3")
            {
                level.thirdStarScore = int.Parse(attribute.Value);
            }
            if (attribute.Name == "limitation")
            {
                level.limitation = (Limitation)System.Enum.Parse(typeof(Limitation), attribute.Value);
            }
            if (attribute.Name == "limit")
            {
                level.limit = int.Parse(attribute.Value);
            }
            if (attribute.Name == "target")
            {
                level.target = (FieldTarget)System.Enum.Parse(typeof(FieldTarget), attribute.Value);
            }
            if (attribute.Name == "target_color_count")
            {
                level.targetColorCount = int.Parse(attribute.Value);
            }
            if (attribute.Name == "target_color_values")
            {
                level.countOfEachTargetCount = attribute.Value.Split(',').ToArray().Select(x => int.Parse(x)).ToArray();
            }
            if (attribute.Name == "target_sdrop_count")
            {
                level.targetSugarDropsCount = int.Parse(attribute.Value);
            }
            if (attribute.Name == "ai_difficult")
            {
                level.ai_difficult = float.Parse(attribute.Value);
            }
        }

        foreach (XmlNode child in node.ChildNodes)
        {
            int x = -1;
            int y = -1;
            foreach (XmlAttribute attribute in child.Attributes)
            {
                if (attribute.Name == "x")
                {
                    x = int.Parse(attribute.Value);
                }
                if (attribute.Name == "y")
                {
                    y = int.Parse(attribute.Value);
                }
            }

            if (x == -1 || y == -1)
            {
                continue;
            }

            if (child.Name == "slot")
            {
                SlotSettings slot = new SlotSettings(new int2(x, y));
                slot.chip = "";
                level.slots.Add(slot);
                foreach (XmlAttribute attribute in child.Attributes)
                {
                    if (attribute.Name == "generator")
                    {
                        slot.generator = true;
                    }
                    if (attribute.Name == "jelly")
                    {
                        slot.jelly_level = int.Parse(attribute.Value);
                    }
                    if (attribute.Name == "jam")
                    {
                        slot.jam = attribute.Value;
                    }
                    if (attribute.Name == "block")
                    {
                        slot.block_type = attribute.Value;
                    }
                    if (attribute.Name == "block_level")
                    {
                        slot.block_level = int.Parse(attribute.Value);
                    }
                    if (attribute.Name == "teleport")
                    {
                        int[] coord = attribute.Value.Split(',').Select(s => int.Parse(s)).ToArray();
                        slot.teleport = new int2(coord[0], coord[1]);
                    }
                    if (attribute.Name == "gravity")
                    {
                        slot.gravity = (Side)System.Enum.Parse(typeof(Side), attribute.Value);
                    }
                    if (attribute.Name == "tags")
                    {
                        slot.tags = attribute.Value.Split(',').ToList();
                    }
                    if (attribute.Name == "chip")
                    {
                        slot.chip = attribute.Value;
                    }
                    if (attribute.Name == "color_id")
                    {
                        slot.color_id = int.Parse(attribute.Value);
                    }
                }
            }
            if (child.Name == "wallh")
            {
                level.wall_horizontal.Add(new int2(x, y));
            }
            if (child.Name == "wallv")
            {
                level.wall_vertical.Add(new int2(x, y));
            }
        }
        return(level);
    }