Example #1
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);

            modelName = sect["Model"];
            
            scale = sect.GetSingle("Radius", 1);

            rot = sect.GetSingle("Amount", 0);

            float radLng = MathEx.Degree2Radian(Longitude);
            float radLat = MathEx.Degree2Radian(Latitude);

            float alt = TerrainData.Instance.QueryHeight(radLng, radLat);

            Position = PlanetEarth.GetPosition(radLng, radLat, PlanetEarth.PlanetRadius + alt * TerrainMeshManager.PostHeightScale);
            Orientation = PlanetEarth.GetOrientation(radLng, radLat);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        public GameConfiguration(string file)
            : base(file, EqualityComparer <string> .Default)
        {
            XmlTextReader xml = new XmlTextReader(File.Open(file, FileMode.Open, FileAccess.Read));

            xml.WhitespaceHandling = WhitespaceHandling.None;

            int depth = xml.Depth;

            GameConfigurationSection currentSection = null;

            string currentAttrib = string.Empty;

            while (MoveToNextElement(xml))
            {
                switch (xml.NodeType)
                {
                case XmlNodeType.Element:
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                    switch (xml.Depth)
                    {
                    case 1:
                        currentSection = new GameConfigurationSection(xml.Name);
                        Add(xml.Name, currentSection);
                        break;

                    case 2:
                        currentAttrib = xml.Name;
                        break;

                    case 3:
                        currentSection.Add(currentAttrib, xml.ReadString());
                        break;
                    }
                    break;
                }
            }

            xml.Close();
        }
Example #4
0
 /// <summary>
 ///  配置文件解析
 /// </summary>
 /// <param name="sect"></param>
 public virtual void Parse(GameConfigurationSection sect)
 {
     Longitude = sect.GetSingle("Longitude");
     Latitude = sect.GetSingle("Latitude");
 }
Example #5
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);

            string type = sect.GetString("Type", string.Empty).ToLowerInvariant();
            if (type == "wood")
            {
                this.Type = NaturalResourceType.Wood;
            }
            else if (type == "petro")
            {
                this.Type = NaturalResourceType.Oil;
            }


            CurrentAmount = sect.GetSingle("Amount", 0);
            //MaxAmount = CurrentAmount * FTimesMaxAmount;

            UpdateLocation();

            Reset(CurrentAmount);
        }
Example #6
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);

            Radius = sect.GetSingle("Radius");

            float radLng = MathEx.Degree2Radian(Longitude);
            float radLat = MathEx.Degree2Radian(Latitude);

            stdPosition = PlanetEarth.GetPosition(radLng, radLat, PlanetEarth.PlanetRadius);
        }
Example #7
0
 public override void Parse(GameConfigurationSection sect)
 {
     base.Parse(sect);
 }
Example #8
0
        public GameConfiguration(ResourceLocation fl)
            : base(fl.Name, EqualityComparer<string>.Default)
        {
            XmlTextReader xml = new XmlTextReader(fl.GetStream);
            xml.WhitespaceHandling = WhitespaceHandling.None;

            int depth = xml.Depth;

            GameConfigurationSection currentSection = null;

            string currentAttrib = string.Empty;

            while (MoveToNextElement(xml))
            {
                switch (xml.NodeType)
                {
                    case XmlNodeType.Element:
                    case XmlNodeType.Text:
                    case XmlNodeType.CDATA:
                        switch (xml.Depth)
                        {
                            case 1:
                                currentSection = new GameConfigurationSection(xml.Name);
                                Add(xml.Name, currentSection);
                                break;
                            case 2:
                                currentAttrib = xml.Name;
                                break;
                            case 3:
                                currentSection.Add(currentAttrib, xml.ReadString());
                                break;
                        }
                        break;
                }
            }

            xml.Close();
        }
Example #9
0
        /// <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;
        }
Example #10
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);

            harvester.SetPosition(MathEx.Degree2Radian(Longitude), MathEx.Degree2Radian(Latitude));
        }
Example #11
0
        public override void Parse(GameConfigurationSection sect)
        {
            base.Parse(sect);
            this.Name = sect.GetString("Name", string.Empty);

            StartUp = sect.GetInt("StartUp", -1);

            linkableCityName = sect.GetStringArray("Linkable", null);

            development = sect.GetSingle("InitialDevelopment", RulesTable.CityInitialDevelopment);
            healthValue = CurrentMaxHealth;




            float facing = MathEx.PIf + (Randomizer.GetRandomSingle() - 0.5f) * MathEx.PiOver2;
            //currentFacing =  MathEx.PIf * (5f / 6 + Randomizer.GetRandomSingle() / 3);
            currentFacing = Quaternion.RotationAxis(Vector3.UnitY, facing);

            UpdateLocation();
        }