コード例 #1
0
 public void LoadBuildingConf(GlobalPlanetConfiguration globalPlanetConfiguration, Building building)
 {
     if (building is ResourceGenerator)
     {
         this.LoadResourceGeneratorConf(globalPlanetConfiguration, building as ResourceGenerator);
     }
 }
コード例 #2
0
        public List <Resource> PlanetResources(GlobalPlanetConfiguration globalPlanetConfiguration)
        {
            List <Resource> result = new List <Resource>();

            foreach (var resourceId in globalPlanetConfiguration.ResourcesIds)
            {
                var data = Configuration.Resources.FirstOrDefault(x => x.Id == resourceId);
                data.Print = "Planet";
                if (data.LastQuantity == null)
                {
                    data.LastQuantity = 0;
                }
                result.Add(ClassUtil.Copy(data));
            }

            return(result);
        }
コード例 #3
0
        public List <ResourceGenerator> PlanetResourceGenerators(GlobalPlanetConfiguration globalPlanetConfiguration)
        {
            List <ResourceGenerator> result = new List <ResourceGenerator>();

            foreach (var buildingId in globalPlanetConfiguration.BuildingsIds)
            {
                var data = Configuration.ResourceGenerators.FirstOrDefault(x => x.Id == buildingId);
                data.Print = "Planet";
                if (data.Level == null)
                {
                    data.Level = 0;
                }
                result.Add(ClassUtil.Copy(data));
            }

            return(result);
        }
コード例 #4
0
 public void LoadResourceGeneratorConf(GlobalPlanetConfiguration globalPlanetConfiguration, ResourceGenerator generator)
 {
     foreach (var buildingId in globalPlanetConfiguration.BuildingsIds)
     {
         var data = Configuration.ResourceGenerators.FirstOrDefault(x => x.Id == buildingId);
         if (data.Name.Equals(generator.Name))
         {
             generator.OxygenCostFuncString  = data.OxygenCostFuncString;
             generator.OxygenGenFuncString   = data.OxygenGenFuncString;
             generator.SteelCostFuncString   = data.SteelCostFuncString;
             generator.SteelGenFuncString    = data.SteelGenFuncString;
             generator.UraniumCostFuncString = data.UraniumCostFuncString;
             generator.UraniumGenFuncString  = data.UraniumGenFuncString;
             generator.EnergyCostFuncString  = data.EnergyCostFuncString;
             generator.EnergyGenFuncString   = data.EnergyGenFuncString;
         }
     }
 }
コード例 #5
0
        public ActionResult Configure()
        {
            GameAdminVM vm            = new GameAdminVM();
            var         resGlobalConf = db.Configurations.Find(ConfigurationKeys.GlobalGameConfiguration.GetName());
            var         resPlanetConf = db.Configurations.Find(ConfigurationKeys.GlobalPlanetConfiguration.GetName());

            GlobalGameConfiguration   globalConf = new GlobalGameConfiguration();
            GlobalPlanetConfiguration planetConf = new GlobalPlanetConfiguration();

            if (resGlobalConf != null && resPlanetConf != null)
            {
                globalConf = JsonConvert.DeserializeObject <GlobalGameConfiguration>(resGlobalConf.Data);
                planetConf = JsonConvert.DeserializeObject <GlobalPlanetConfiguration>(resPlanetConf.Data);
            }
            else
            {
                resGlobalConf = new Configuration()
                {
                    Key  = ConfigurationKeys.GlobalGameConfiguration.GetName(),
                    Data = JsonConvert.SerializeObject(vm.GlobalGameConfiguration)
                };
                resPlanetConf = new Configuration()
                {
                    Key  = ConfigurationKeys.GlobalPlanetConfiguration.GetName(),
                    Data = JsonConvert.SerializeObject(vm.GlobalPlanetConfiguration)
                };

                db.Configurations.Add(resGlobalConf);
                db.Configurations.Add(resPlanetConf);

                db.SaveChanges();
            }

            vm.GlobalGameConfiguration   = globalConf;
            vm.GlobalPlanetConfiguration = planetConf;
            vm.Resources = ConfigurationsUtil.Instance.Configuration.Resources;
            ClassUtil.IdsUpdater(vm.Resources);
            vm.Buildings = ConfigurationsUtil.Instance.Configuration.ResourceGenerators.ToList <Building>();
            ClassUtil.IdsUpdater(vm.Buildings);

            return(View(vm));
        }
コード例 #6
0
            public GameBuilder AddPlanetsOnSolarSystem(GlobalPlanetConfiguration globalPlanetConfiguration)
            {
                gameBuilder.globalPlanetConfiguration = globalPlanetConfiguration;

                return(gameBuilder);
            }