public LevelScript(JSONTable template) { spawns = new List<List<MinionType>>(); name = template.getString("name", "UNNAMED"); JSONArray spawnTemplate = template.getArray("monsters"); for (int Idx = 0; Idx < spawnTemplate.Length; ++Idx) { List<MinionType> thisTurn = new List<MinionType>(); foreach (string minion in spawnTemplate.getArray(Idx).asStrings()) { MinionType type = MinionType.get(minion); thisTurn.Add(type); } spawns.Add(thisTurn); } scenery = new List<KeyValuePair<MinionType, Point>>(); foreach (JSONArray entry in template.getArray("scenery", JSONArray.empty).asJSONArrays()) { scenery.Add(new KeyValuePair<MinionType,Point>(MinionType.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2)))); } ongoingEffects = new List<KeyValuePair<Card, Point>>(); foreach (JSONArray entry in template.getArray("ongoingEffects", JSONArray.empty).asJSONArrays()) { ongoingEffects.Add(new KeyValuePair<Card, Point>(Card.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2)))); } levelType = LevelType.get(template.getString("type")); string unlock = template.getString("unlock", null); if(unlock != null) unlocksCard = Card.get(unlock); }
public static void load(JSONTable template, ContentManager content) { levelTypes = new Dictionary<string, LevelType>(); foreach (string key in template.Keys) { levelTypes[key] = new LevelType(template.getJSON(key), content); } }