void ParseConditions(JSONObject conditions) { typeWinningConditions.Clear(); colorWinningConditions.Clear(); skillWinningConditions.Clear(); var keys = conditions.Keys; foreach (string key in keys) { if (key == SCORE) { minScoreWinningCondition = (int)conditions[key]; } else if (key == MOVESOVER) { movesOver = (int)conditions[key] > 0?true:false; } else { if (LevelEditorInfo.Instance.levelSettingConfig.ObjectiveCollection.Contains(key)) { int amount = (int)conditions[key]; typeWinningConditions.Add(key, amount); } else { try { string[] colorsStrings = key.Split(','); var colorIds = new List <ColorId>(); foreach (string colorString in colorsStrings) { ColorId colorId = LevelEditorUtils.ParseEnum <ColorId>(colorString.UppercaseFirst()); colorIds.Add(colorId); } int amount = (int)conditions[key]; var colorWinningCondition = new ColorWinningCondition(); colorWinningCondition.amount = amount; colorWinningCondition.colors = colorIds; colorWinningConditions.Add(colorWinningCondition); } catch { try { CompanionTypeId skillType = LevelEditorUtils.ParseEnum <CompanionTypeId>(key); int amount = (int)conditions[key]; skillWinningConditions.Add(skillType, amount); } catch { Debug.LogWarning("Could not parse winning condition for key = " + key + ", levelNum = " + levelNum); } } } } } }
public void SaveSettingsToLevelData() { //单个数据 _level.name = _levelName; _level.levelNum = _levelNum; _level.maxMoves = _moves; _level.companionType = _companionType; _level.companionRequiredCharge = _companionCharge; _level.acsMax = _acsMax; _level.acsMin = _acsMin; _level.starThresholds = new List <int>(_mastery); //supergem _level.superMergingEnabled = _superMergingEnabled; _level.preventItems = new List <string>(_preventItems); //Items List <ColorId> colorOrderList = new List <ColorId>(); for (int i = 0; i < 6; i++) { var item = _colorOrder.Find(x => x.amount == i); if (item != null) { colorOrderList.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType)); } } _level.colorSpawningOrder = colorOrderList; foreach (var item in _itemSpawnChance) { _level.itemSpawnPercentages[item.itemType] = item.amount; } foreach (var item in _itemSpawnMin) { _level.itemSpawnMin[item.itemType] = item.amount; } foreach (var item in _itemSpawnMax) { _level.itemSpawnMax[item.itemType] = item.amount; } foreach (var item in _totalMin) { _level.itemTotalSpawnMin[item.itemType] = item.amount; } foreach (var item in _totalMax) { _level.itemTotalSpawnMax[item.itemType] = item.amount; } foreach (var item in _ensureItems) { _level.ensureItems[item.itemType] = item.amount; } List <ColorWinningCondition> colorWinningCondition = new List <ColorWinningCondition>(); if (_combineObjective) { ColorWinningCondition condition = new ColorWinningCondition(); condition.colors = new List <ColorId>(); foreach (var item in _objectiveColor) { if (item.amount != 0) { condition.colors.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType)); } } if (condition.colors.Count != 0) { condition.amount = _combineTotal; colorWinningCondition.Add(condition); } } else { foreach (var item in _objectiveColor) { if (item.amount != 0) { ColorWinningCondition condition = new ColorWinningCondition(); condition.colors = new List <ColorId>(); condition.colors.Add(LevelEditorUtils.ParseEnum <ColorId>(item.itemType)); condition.amount = item.amount; colorWinningCondition.Add(condition); } } } _level.colorWinningConditions = colorWinningCondition; foreach (var item in _objectives) { if (item.amount != 0) { _level.typeWinningConditions[item.itemType] = item.amount; } } _level.movesOver = _moveOver; //boss _level.bossName = _bossNames[_bossIndex] == NO_BOSS_STRING ? "0" : _bossNames[_bossIndex]; if (_spawningSetIndex < 0) { _level.spawningSetName = ""; } else { _level.spawningSetName = _spawningSets[_spawningSetIndex]; } }