Exemple #1
0
        public void MergeAllData(DefaultDataCollection defaultDataCollection, GameDataCollection gameDataCollection)
        {
            // Merge data from default do game

            // Add all buildings do Game Collection
            gameDataCollection.AllBuildings = defaultDataCollection.Buildings;
            gameDataCollection.Countrys     = new StaticDictionary <GameCountry>();

            foreach (var country in defaultDataCollection.Countries.Values)
            {
                gameDataCollection.Countrys.Add(country.TagName, new GameCountry(country));
            }

            foreach (var country in gameDataCollection.Countrys.Values)
            {
                country.Regions = new StaticDictionary <GameRegion>();
                foreach (var region in defaultDataCollection.Regions.Values.Where(x => x.CountryTag == country.TagName))
                {
                    var gameRegion = new GameRegion(region);

                    gameRegion.City = new GameCity(defaultDataCollection.Citys[region.CityTag]);
                    MergeBuildings(defaultDataCollection, gameRegion.City, RequiredEnum.City);

                    gameRegion.Farm = new GameFarm(defaultDataCollection.Farms[region.FarmTag]);
                    MergeBuildings(defaultDataCollection, gameRegion.Farm, RequiredEnum.Farm);

                    gameRegion.Port = new GamePort(defaultDataCollection.Ports[region.PortTag]);
                    MergeBuildings(defaultDataCollection, gameRegion.Port, RequiredEnum.Port);

                    gameRegion.Industry = new GameIndustry(defaultDataCollection.Industries[region.IndustryTag]);
                    MergeBuildings(defaultDataCollection, gameRegion.Industry, RequiredEnum.Industry);

                    gameRegion.Infrastructure = new GameInfrastructure(defaultDataCollection.Infrastructures[region.InfrastructureTag]);
                    MergeBuildings(defaultDataCollection, gameRegion.Infrastructure, RequiredEnum.Infrastructure);

                    country.Regions.Add(gameRegion.TagName, gameRegion);
                }

                foreach (var provinceTag in defaultDataCollection.Regions.Values.Select(x => x.ProvinceTag).Distinct())
                {
                    foreach (var province in defaultDataCollection.Provinces.Values.Where(x => x.TagName == provinceTag))
                    {
                        country.Provinces.Add(province.TagName, new GameProvince(province));
                    }
                }
            }


            gameDataCollection.AllBuildings = defaultDataCollection.Buildings;


            //MergeRegionData(defaultDataCollection);

            //MergeBuildings(defaultDataCollection.Infrastructures, defaultDataCollection.Buildings);
            //MergeBuildings(defaultDataCollection.Farms, defaultDataCollection.Buildings);
        }
Exemple #2
0
        public DefaultDataCollection LoadAllData(string path)
        {
            var data = new DefaultDataCollection();

            data.Players         = Load <StaticDictionary <StaticActor> >(Constants.PlayersFileName, path);
            data.Countries       = Load <StaticDictionary <StaticCountry> >(Constants.CountriesFileName, path);
            data.Provinces       = Load <StaticDictionary <StaticProvince> >(Constants.ProvincesFileName, path);
            data.Regions         = Load <StaticDictionary <StaticRegion> >(Constants.RegionsFileName, path);
            data.Citys           = Load <StaticDictionary <StaticCity> >(Constants.CitysFileName, path);
            data.Farms           = Load <StaticDictionary <StaticFarm> >(Constants.FarmsFileName, path);
            data.Ports           = Load <StaticDictionary <StaticPort> >(Constants.PortsFileName, path);
            data.Infrastructures = Load <StaticDictionary <StaticInfrastructure> >(Constants.InfrastructureFileName, path);
            data.Industries      = Load <StaticDictionary <StaticIndustry> >(Constants.IndustryFileName, path);
            data.Buildings       = Load <StaticDictionary <StaticBuilding> >(Constants.BuildingsFileName, path);

            return(data);
        }
        public static void MergeRegionData(DefaultDataCollection collection)
        {
            foreach (var region in collection.Regions.Data)
            {
                //if (region.Value.CanBuildPort)
                //{
                //    region.Value.Port = collection.Ports.Data[region.Value.PortTag];
                //}

                //region.Value.City = collection.Citys.Data[region.Value.CityTag];

                //region.Value.Farm = collection.Farms.Data[region.Value.FarmTag];


                //region.Value.Infrastructure = collection.Infrastructures.Data[region.Value.InfrastructureTag];
            }
        }
Exemple #4
0
        private void MergeBuildings(DefaultDataCollection collection, IGameBuilding data, RequiredEnum requiredEnum)
        {
            data.ListOfCompleteBuilding = new StaticDictionary <GameBuilding>();
            if (((IBuilding)data).BuildingTag != null)
            {
                foreach (var building in ((IBuilding)data).BuildingTag)
                {
                    data.ListOfCompleteBuilding.Add(building, new GameBuilding(collection.Buildings.Values.Single(x => x.TagName == building)));
                }
            }

            data.ListOfPotentialBuilding = new StaticDictionary <GameBuilding>();

            foreach (var building in collection.Buildings.Values.Where(x => x.RequiredEnum == requiredEnum))
            {
                data.ListOfPotentialBuilding.Add(building.TagName, new GameBuilding(building));
            }


            // Add potential buildings

            // Add buildings that are building at the moment
        }
Exemple #5
0
        public void ReadWriteTest()
        {
            var datas = new DefaultDataCollection();

            datas.Set("string", "a");
            datas.Set(2, 1);
            datas.Set(typeof(DefaultDataCollectionTest), new DefaultDataCollectionTest());

            Assert.True(datas.Get <string>("string") == "a");
            Assert.True(datas.Get <int>(2) == 1);

            var state = datas.TryGetValue(typeof(DefaultDataCollectionTest), out var value);

            Assert.True(state && value is DefaultDataCollectionTest);

            state = datas.TryGetValue <DefaultDataCollectionTest>(typeof(DefaultDataCollectionTest), out var tValue);
            Assert.True(state && tValue != null);

            state = datas.TryGetValue <DefaultDataCollectionTest>(typeof(string), out _);
            Assert.False(state);

            datas.TryRemove("string", out _);
            Assert.True(datas.Get <string>("string") == default);
        }
Exemple #6
0
 public TurnManager(DefaultDataCollection collection)
 {
     _collection = collection;
 }
Exemple #7
0
 public void MergeRegionData(DefaultDataCollection collection)
 {
     MergeData.MergeRegionData(collection);
 }
 public SelectManager(DefaultDataCollection defaultDataCollection, GameDataCollection gameDataCollection)
 {
     DefaultCollection = defaultDataCollection;
     GameCollection    = gameDataCollection;
 }