public ShopDefinition GetShopDefinition(int chapterId, ShopType shopType) { int key = ShopDefinition.DefinitionKey(chapterId, shopType); if (this.shopDefinitions.ContainsKey(key)) { return(this.shopDefinitions[key]); } return(null); }
private void LoadShopDefinitions() { shopDefinitions = new Dictionary <int, ShopDefinition>(); ResourceDataFile fileReader = new ResourceDataFile(@"Data/Shop"); ShopDefinition def = null; while ((def = ShopDefinition.ReadFromFile(fileReader)) != null) { shopDefinitions[def.Key] = def; } }
public static ShopDefinition ReadFromFile(ResourceDataFile reader) { ShopDefinition def = new ShopDefinition(); def.ChapterId = reader.ReadInt(); if (def.ChapterId == -1) { return(null); } def.Type = (ShopType)reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { int itemId = reader.ReadInt(); def.Items.Add(itemId); } return(def); }