public UnitTests() { ResourceType.AddResourceType("coin", false); ResourceType.AddResourceType("wood", false); ResourceType.AddResourceType("rock", false); ResourceType.AddResourceType("ore", false); ResourceType.AddResourceType("ironore", false); ResourceType.AddResourceType("goldore", false); ResourceType.AddResourceType("researchpoint", false); ResourceType.AddResourceType("milk", true); ResourceType.AddResourceType("meat", true); ResourceType.AddResourceType("egg", true); ResourceType.AddResourceType("cow", false); ResourceType.AddResourceType("pig", false); ResourceType.AddResourceType("chicken", false); }
private ConfigurationManager() { try { var config = JsonConvert.DeserializeObject <ConfigFile>(allJson); foreach (var item in config.Resources) { ResourceType.AddResourceType(item.Name, item.IsFood); } foreach (var item in config.ProducerUnits) { var type = Type.GetType(item.UnitType); if (!ProducerUnits.ContainsKey(type)) { ProducerUnits.Add(type, item); } } foreach (var item in config.ConverterUnits) { var type = Type.GetType(item.UnitType); if (!ConverterUnits.ContainsKey(type)) { ConverterUnits.Add(type, item); } } foreach (var item in config.ProducerAndConverterUnits) { var type = Type.GetType(item.UnitType); if (!ProducerAndConverterUnits.ContainsKey(type)) { ProducerAndConverterUnits.Add(type, item); } } foreach (var item in config.ConstructionUnits) { var type = Type.GetType(item.UnitType); if (!ConstructionUnits.ContainsKey(type)) { ConstructionUnits.Add(type, item); } } foreach (var item in config.DecorBuildings) { DecorBuildings.Add(Type.GetType(item.BuildingType), item); } foreach (var item in config.WorkplaceBuildings) { var type = Type.GetType(item.BuildingType); if (!WorkplaceBuildings.ContainsKey(type)) { WorkplaceBuildings.Add(Type.GetType(item.BuildingType), item); } } SatisfactionBoostAlgo = config.SatisfactionPrice.IncrementAlgoType; SatisfactionBoostInitialCost = config.SatisfactionPrice.InitialCost; SatisfactionBoostAlgoValue = config.SatisfactionPrice.AlgoSecondValue; foreach (var item in config.SellingPrices) { if (!SellingPrices.ContainsKey(item.Key)) { SellingPrices.Add(item.Key, item.Value.Select(r => new ResourceAmount(r.Type, r.Amount)).ToList()); } } foreach (var item in config.BuyingPrices) { if (!BuyingPrices.ContainsKey(item.Key)) { BuyingPrices.Add(item.Key, item.Value.Select(r => new ResourceAmount(r.Type, r.Amount)).ToList()); } } ResearchIncrementAlgo = config.ResearchAlgo; } catch (Exception ex) { Debug.WriteLine("Serialization error"); Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); Debugger.Break(); return; } }