public LevelMatrix(LevelMatrix matrix) { _values = new char[matrix.width, matrix.height]; for (int y = 0; y < _values.GetLength(1); y++) { for (int x = 0; x < _values.GetLength(0); x++) { _values[x, y] = matrix.Get(x, y); } } }
void ParseLayers(JSONObject dict) { foreach (var layerKey in dict.Keys) { var layerData = ((JSONNode)dict).GetDictionary(layerKey); var layer = _layers[layerKey]; foreach (var typeKey in layerData.Keys) { var typeData = layerData[typeKey].AsCollection(); if (typeKey == "connections" || typeKey == ConfigLayerId.OPTIONS) { var matrix = new LevelMatrix(typeData, width, height); if (layer.ContainsKey(ConfigLayerId.OPTIONS)) { for (int x = 0; x < matrix.width; x++) { for (int y = 0; y < matrix.height; y++) { if (layer[ConfigLayerId.OPTIONS].Get(x, y) != '-') { if (matrix.Get(x, y) == '-') { matrix.Set(x, y, layer[ConfigLayerId.OPTIONS].Get(x, y)); } else { Debug.LogError("MERGE CONFLICT Cannot merge level " + id + ", " + name); } } } } } layer[ConfigLayerId.OPTIONS] = matrix; } else { layer[typeKey] = new LevelMatrix(typeData, width, height); } } } }