Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public void Default()
        {
            Resources.Add(new ResourceConfig()
            {
                Name = "coin", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "wood", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "rock", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "ore", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "ironore", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "goldore", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "researchpoint", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "milk", IsFood = true
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "meat", IsFood = true
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "egg", IsFood = true
            });

            Resources.Add(new ResourceConfig()
            {
                Name = "cow", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "pig", IsFood = false
            });
            Resources.Add(new ResourceConfig()
            {
                Name = "chicken", IsFood = false
            });

            ResearchAlgo = new ResearchAlgoConfig()
            {
                IncrementAlgoType = AlgoType.Fibonacci
            };

            SatisfactionPrice = new SatisfactionConfig()
            {
                InitialCost       = 2,
                IncrementAlgoType = AlgoType.Exp,
            };
            SellingPrices = new Dictionary <string, List <ResourceAmountConfig> >()
            {
                {
                    "cow",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 10)
                    }
                }, {
                    "pig",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 20)
                    }
                }, {
                    "chicken",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 10)
                    }
                },
            };

            BuyingPrices = new Dictionary <string, List <ResourceAmountConfig> >()
            {
                {
                    "wood",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 1)
                    }
                }, {
                    "rock",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 1)
                    }
                }, {
                    "ore",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 2)
                    }
                }, {
                    "ironore",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 5)
                    }
                }, {
                    "goldore",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 25)
                    }
                }, {
                    "meat",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 10)
                    }
                }, {
                    "milk",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 13)
                    }
                }, {
                    "egg",
                    new List <ResourceAmountConfig>()
                    {
                        new ResourceAmountConfig("coin", 15)
                    }
                },
            };

            ConstructionUnits.Add(new ConstructionUnitConfig()
            {
                UnitType    = "ResourceManagementGameCore.Units.Builder",
                FoodConsume = 1,
                Progress    = 1,
                InitialCost = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("coin", 100)
                },
                CostIncrementAlgoType = AlgoType.Multiple,
                AlgoSecondaryValue    = 1.2
            });

            ProducerUnits.Add(new ProducerUnitConfig()
            {
                UnitType    = "ResourceManagementGameCore.Units.Gatherer",
                FoodConsume = 1,
                InitialProductableResources = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 1), new ResourceAmountConfig("rock", 1)
                },
                AllProductableResources = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 1), new ResourceAmountConfig("rock", 1), new ResourceAmountConfig("ore", 1)
                },
                InitialCost = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("coin", 50)
                },
                CostIncrementAlgoType = AlgoType.Increment,
                AlgoSecondaryValue    = 1
            });

            ConverterUnits.Add(new ConverterUnitConfig()
            {
                UnitType    = "ResourceManagementGameCore.Units.Farmer",
                FoodConsume = 1,
                InitialCost = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("coin", 50)
                },
                CostIncrementAlgoType         = AlgoType.Increment,
                AlgoSecondaryValue            = 1,
                AllConvertableResourceMapping = new Dictionary <string, List <ResourceAmountConfig> >()
                {
                    { "cow", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 2),
                          new ResourceAmountConfig("milk", 2)
                      } },
                    { "pig", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 4),
                      } },
                    { "chicken", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 2),
                          new ResourceAmountConfig("egg", 2)
                      } },
                },
                InitialConvertableResourceMapping = new Dictionary <string, List <ResourceAmountConfig> >()
                {
                    { "cow", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 2),
                          new ResourceAmountConfig("milk", 2)
                      } },
                    { "pig", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 4),
                      } },
                    { "chicken", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("meat", 2),
                          new ResourceAmountConfig("egg", 2)
                      } },
                },
                MaxInput = 5
            });

            ProducerAndConverterUnits.Add(new ProducerAndConverterUnitConfig()
            {
                UnitType    = "ResourceManagementGameCore.Units.Researcher",
                FoodConsume = 1,
                InitialCost = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("coin", 100)
                },
                CostIncrementAlgoType         = AlgoType.Multiple,
                AlgoSecondaryValue            = 1.5,
                AllConvertableResourceMapping = new Dictionary <string, List <ResourceAmountConfig> >()
                {
                    { "ore", new List <ResourceAmountConfig>()
                      {
                          new ResourceAmountConfig("ironore", 1),
                          new ResourceAmountConfig("goldore", 1)
                      } }
                },
                InitialConvertableResourceMapping = new Dictionary <string, List <ResourceAmountConfig> >(),
                InitialProductableResources       = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("researchpoint", 1)
                },
                AllProductableResources = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("researchpoint", 1)
                },
                MaxInput = -1
            });

            WorkplaceBuildings.Add(new WorkplaceConfig()
            {
                BuildingType          = "ResourceManagementGameCore.Buildings.ForestCamp",
                CostIncrementAlgoType = AlgoType.Multiple,
                AlgoSecondaryValue    = 1.5,
                BuildCost             = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 10),
                    new ResourceAmountConfig("rock", 5)
                },
                BuildTime   = 5,
                MaxCapacity = 5,
            });

            WorkplaceBuildings.Add(new WorkplaceConfig()
            {
                BuildingType          = "ResourceManagementGameCore.Buildings.MiningVillage",
                CostIncrementAlgoType = AlgoType.Multiple,
                AlgoSecondaryValue    = 1.3,
                BuildCost             = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 10),
                    new ResourceAmountConfig("rock", 5)
                },
                BuildTime   = 5,
                MaxCapacity = 5,
            });

            WorkplaceBuildings.Add(new WorkplaceConfig()
            {
                BuildingType          = "ResourceManagementGameCore.Buildings.Lab",
                CostIncrementAlgoType = AlgoType.Multiple,
                AlgoSecondaryValue    = 1.3,
                BuildCost             = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 30),
                    new ResourceAmountConfig("rock", 20),
                    new ResourceAmountConfig("ironore", 10)
                },
                BuildTime   = 10,
                MaxCapacity = 5,
            });

            WorkplaceBuildings.Add(new WorkplaceConfig()
            {
                BuildingType          = "ResourceManagementGameCore.Buildings.Farm",
                CostIncrementAlgoType = AlgoType.Multiple,
                AlgoSecondaryValue    = 2,
                BuildCost             = new List <ResourceAmountConfig>()
                {
                    new ResourceAmountConfig("wood", 50),
                    new ResourceAmountConfig("rock", 10),
                    new ResourceAmountConfig("ironore", 10)
                },
                BuildTime   = 7,
                MaxCapacity = 1,
            });
        }