public void ReadJson(JToken json, Context context) { MapTile = Serializer.GetHolder <MapTile>(json["tile"], context); Duration = new Slider(json["duration"]); }
public void ReadJson(JToken json) { Context context = new Context(this); World.SetMapId(json["id"].Value <string>(), this); var width = json["width"].Value <int>(); var height = json["height"].Value <int>(); ReadGroups(json["groups"] as JObject, context); Feelings.ReadJson(json["feelings"] as JObject, context); JArray groups = json["groupMap"] as JArray; JArray flags = json["flagMap"] as JArray; JArray tilesAbove = json["tileMap"] as JArray; JArray tilesUnder = json["tileMapUnder"] as JArray; SetSize(width, height); var enumeratorGroups = groups.GetEnumerator(); var enumeratorFlags = flags.GetEnumerator(); var enumeratorTiles = tilesAbove.GetEnumerator(); var enumeratorTilesUnder = tilesUnder.GetEnumerator(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { enumeratorGroups.MoveNext(); enumeratorFlags.MoveNext(); enumeratorTiles.MoveNext(); enumeratorTilesUnder.MoveNext(); var groupJson = enumeratorGroups.Current; var flagJson = enumeratorFlags.Current; var tileJson = enumeratorTiles.Current; var tileUnderJson = enumeratorTilesUnder.Current; var mapTile = Tiles[x, y] = new MapTile(this, x, y); mapTile.Group = context.GetGroup(groupJson.Value <string>()); ReadFlags(flagJson, mapTile); mapTile.Set(context.CreateTile(tileJson)); mapTile.SetUnder(context.CreateTile(tileUnderJson)); } } JArray entitiesArray = json["entities"] as JArray; JArray effectsArray = json["effects"] as JArray; JArray bonusArray = json["bonuses"] as JArray; List <IJsonSerializable> entities = new List <IJsonSerializable>(); foreach (var entityJson in entitiesArray) { var entity = context.CreateEntity(entityJson); entities.Add(entity); } foreach (var effectJson in effectsArray) { var effect = context.CreateEffect(effectJson); if (effect != null) { Effect.Apply(effect); } } foreach (var bonusJson in bonusArray) { string id = bonusJson["id"].Value <string>(); int levelsActive = bonusJson["levelsActive"].Value <int>(); Bonuses.Add(new AppliedBonus(StairBonus.GetStairBonus(id), levelsActive)); } foreach (var entity in entities) { entity.AfterLoad(); } }
public CloudPart(Cloud parent, MapTile mapTile, int duration) { Parent = parent; MapTile = mapTile; Duration = new Slider(duration); }