/// <summary>
        ///  见基类
        /// </summary>
        public override Configuration Clone()
        {
            GameConfiguration ini = new GameConfiguration(base.Name, this.Count);

            foreach (KeyValuePair<string, ConfigurationSection> e1 in this)
            {
                //Dictionary<string, string> newSectData = new Dictionary<string, string>(e1.Value.Count);
                GameConfigurationSection newSect = new GameConfigurationSection(ini, e1.Key, e1.Value.Count);

                foreach (KeyValuePair<string, string> e2 in e1.Value)
                {
                    newSect.Add(e2.Key, e2.Value);
                }

                ini.Add(e1.Key, newSect);
            }

            return ini;
        }
Exemple #2
0
        /// <summary>
        /// 初始化自然资源
        /// </summary>
        void InitializeNaturalResource()
        {
            FileLocation fl = FileSystem.Instance.Locate("resources.xml", GameFileLocs.Config);
            GameConfiguration resCon = new GameConfiguration(fl);
            GameConfiguration.ValueCollection resVals = resCon.Values;

            List<NaturalResource> resources = new List<NaturalResource>(MaxCities);

            foreach (GameConfigurationSection sect in resVals)
            {
                string type = sect.GetString("Type", string.Empty).ToLowerInvariant();

                if (type == "wood")
                {
                    ForestObject forest = new ForestObject(this);
                    forest.Parse(sect);
                    resources.Add(forest);

                }
                else if (type == "petro")
                {
                    OilFieldObject fld = new OilFieldObject(this);
                    fld.Parse(sect);
                    resources.Add(fld);
                }           
            }
            naturalResource = resources.ToArray();

            for (int i = 0; i < cities.Length; i++)
            {
                if ( cities[i].Type == CityType.Oil || cities[i].Type == CityType.Green)
                {
                    ((GatherCity)cities[i]).FindResources(resources);
                }
            }   


        }
Exemple #3
0
        public static void LoadRules()
        {
            FileLocation fl = FileSystem.Instance.Locate("rules.xml", GameFileLocs.Config);
            GameConfiguration con = new GameConfiguration(fl);// Utils.LoadConfig("rules.xml"); 
            ConfigurationSection sect = con["CityCommon"];

            CityBallLimit = sect.GetInt("BallLimit");
            CityMaxDevelopment = sect.GetSingle("MaxDevelopment", 10000);
            CityDevHealthRate = sect.GetSingle("DevHealthRate", 0.1f);
            CityInitialDevelopment = sect.GetSingle("InitialDevelopment", 1000);
            CityRadius = sect.GetSingle("Radius", 300);
            CityDevRBallHealthRate = sect.GetSingle("DevRBallHealthRate");
            CityArmor = sect.GetSingle("Armor");

            sect = con["NRCommon"];
            FRecoverBias = sect.GetSingle("ORecoverBias", 1);
            ORecoverBias = sect.GetSingle("FRecoverBias", 1);
            FRecoverRate = sect.GetSingle("FRecoverRate", 0.0015f);

            sect = con["HarvCommon"];

            HarvLoadingSpeed = sect.GetSingle("LoadingSpeed", 2.5f);
            HarvLoadingTime = sect.GetSingle("HarvLoadingTime", 3);

            #region 各种资源球配置读取
            sect = con["OilBall"];
            OilBallBaseHealth = sect.GetSingle("BaseHealth");
            OilBallCost = sect.GetSingle("Cost");
            OilBallContribution = sect.GetSingle("Contribution");
            OilBallBaseDamage = sect.GetSingle("BaseDamage");
            OilBallBaseHeal = sect.GetSingle("BaseHeal");

            sect = con["GreenBall"];
            GreenBallBaseHealth = sect.GetSingle("BaseHealth");
            GreenBallCost = sect.GetSingle("Cost");
            GreenBallContribution = sect.GetSingle("Contribution");
            GreenBallBaseDamage = sect.GetSingle("BaseDamage");
            GreenBallBaseHeal = sect.GetSingle("BaseHeal");

            sect = con["EducationBall"];
            EducationBallBaseHealth = sect.GetSingle("BaseHealth");
            EducationBallGenInterval = sect.GetSingle("GenInterval");
            EducationBallContribution = sect.GetSingle("Contribution");
            EducationBallBaseDamage = sect.GetSingle("BaseDamage");
            EducationBallBaseHeal = sect.GetSingle("BaseHeal");

            sect = con["HealthBall"];
            HealthBallBaseHealth = sect.GetSingle("BaseHealth");
            HealthBallGenInterval = sect.GetSingle("GenInterval");
            HealthBallContribution = sect.GetSingle("Contribution"); ;
            HealthBallBaseDamage = sect.GetSingle("BaseDamage");
            HealthBallBaseHeal = sect.GetSingle("BaseHeal");
           
            sect = con["DiseaseBall"];
            DiseaseBallBaseHealth = sect.GetSingle("BaseHealth");
            DiseaseBallGenInterval = sect.GetSingle("GenInterval");
            DiseaseBallContribution = sect.GetSingle("Contribution");
            DiseaseBallBaseDamage = sect.GetSingle("BaseDamage");
            DiseaseBallBaseHeal = sect.GetSingle("BaseHeal");

            sect = con["VolienceBall"];
            VolienceBallBaseHealth = sect.GetSingle("BaseHealth");
            VolienceBallGenInterval = sect.GetSingle("GenInterval");
            VolienceBallContribution = sect.GetSingle("Contribution");
            VolienceBallBaseDamage = sect.GetSingle("BaseDamage");
            VolienceBallBaseHeal = sect.GetSingle("BaseHeal");

            #endregion

            #region 各种城市的配置读取
            sect = con["OilCity"];
            OilGatherDistance = sect.GetSingle("GatherDistance", 150);
            OilHarvHP = sect.GetSingle("HarvHealth", 300);
            OilHarvStorage = sect.GetSingle("HarvStorage", 300);
            OilHarvSpeed = sect.GetSingle("HarvSpeed", 1);
            OilDevelopStep = sect.GetSingle("DevelopStep", 10);

            sect = con["GreenCity"];
            GreenGatherDistance = sect.GetSingle("GatherDistance", 150);
            GreenHarvHP = sect.GetSingle("HarvHealth", 300);
            GreenHarvStorage = sect.GetSingle("HarvStorage", 300);
            GreenHarvSpeed = sect.GetSingle("HarvSpeed", 1);
            GreenDevelopStep = sect.GetSingle("DevelopStep", 10);

            sect = con["DiseaseCity"];
            DiseaseDevelopStep = sect.GetSingle("DevelopStep", 10);

            sect = con["VolienceCity"];
            VolienceDevelopStep = sect.GetSingle("VolienceCity", 10);

            sect = con["HealthCity"];
            HealthDevelopStep = sect.GetSingle("HealthCity", 10);

            sect = con["EducationCity"];
            EducationDevelopStep = sect.GetSingle("EducationCity", 10);
            #endregion
        }
Exemple #4
0
        /// <summary>
        /// 初始化城市
        /// </summary>
        private void LoadCities()
        {

            List<City> cityList = new List<City>(MaxCities);

            FileLocation fl = FileSystem.Instance.Locate("cities.xml", GameFileLocs.Config);
            GameConfiguration resCon = new GameConfiguration(fl);
            GameConfiguration.ValueCollection resVals = resCon.Values;
            Dictionary<string, City> resolveTable = new Dictionary<string, City>(MaxCities);
            foreach (GameConfigurationSection sect in resVals)
            {
                City city;
                string typestr = sect.GetString("Type", string.Empty).ToLowerInvariant();

                CityType type = City.ParseType(typestr);

                switch (type)
                {
                    case CityType.Neutral:
                        city = new City(this, null, type);
                        break;
                    case CityType.Oil:
                    case CityType.Green:
                        city = new GatherCity(this, null, type);
                        break;
                    case CityType.Disease:
                    case CityType.Education:
                    case CityType.Health:
                    case CityType.Volience:
                        city = new ProductionCity(this, null, type);
                        break;
                    default:
                        city = new City(this, null, type);
                        break;
                }

                city.Parse(sect);

                resolveTable.Add(sect.Name, city);
                cityList.Add(city);
            }

            for (int i = 0; i < cityList.Count; i++) 
            {
                cityList[i].ResolveCities(resolveTable);
            }

            cities = cityList.ToArray();
        }
 public GameConfigurationSection(GameConfiguration parent, string name, int capacity)
     : base(parent, name, capacity)
 { }