Example #1
0
        void DrawLink(Graphics g, MapCity city, int x, int y)
        {
            string[] v = city.LinkableCity;
            if (v != null)
            {
                for (int i = 0; i < v.Length; i++)
                {
                    int cx, cy;

                    MapCity cc = cityTable[v[i]];


                    MapObject.GetMapCoord(Apoc3D.MathLib.MathEx.Degree2Radian(cc.Longitude), Apoc3D.MathLib.MathEx.Degree2Radian(cc.Latitude), out cx, out cy);
                    g.DrawLine(pen, new Point(x, y), new Point(cx, cy));
                }
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (selectedObject != null)
            {
                switch (selectedObject.Type)
                {
                case ObjectType.City:
                    MapCity city = (MapCity)selectedObject.Tag;

                    city.Name      = textBox1.Text;
                    city.FarmCount = (int)numericUpDown2.Value;


                    city.ProblemHunger      = (float)numericUpDown1.Value;
                    city.ProblemEducation   = (float)numericUpDown3.Value;
                    city.ProblemGender      = (float)numericUpDown4.Value;
                    city.ProblemChild       = (float)numericUpDown5.Value;
                    city.ProblemMaternal    = (float)numericUpDown6.Value;
                    city.ProblemDisease     = (float)numericUpDown7.Value;
                    city.ProblemEnvironment = (float)numericUpDown8.Value;

                    if (radioButton5.Checked)
                    {
                        city.Size = UrbanSize.Small;
                    }
                    else if (radioButton6.Checked)
                    {
                        city.Size = UrbanSize.Medium;
                    }
                    else if (radioButton7.Checked)
                    {
                        city.Size = UrbanSize.Large;
                    }

                    city.StartUp      = (int)numericUpDown14.Value;
                    city.LinkableCity = textBox4.Text.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    if (string.IsNullOrEmpty(selectedObject.SectionName))
                    {
                        selectedObject.SectionName = "City" + Guid.NewGuid().ToString("N");
                    }
                    selectedObject.StringDisplay = city.Name;
                    break;

                case ObjectType.ResOil:
                case ObjectType.ResWood:
                    MapResource oil = (MapResource)selectedObject.Tag;

                    oil.Amount = (float)numericUpDown9.Value;
                    oil.Radius = (float)numericUpDown10.Value;

                    if (radioButton1.Checked)
                    {
                        oil.Type = NaturalResourceType.Wood;
                    }
                    else if (radioButton2.Checked)
                    {
                        oil.Type = NaturalResourceType.Petro;
                    }
                    if (string.IsNullOrEmpty(selectedObject.SectionName))
                    {
                        selectedObject.SectionName = "Resource" + Guid.NewGuid().ToString("N");
                    }
                    selectedObject.StringDisplay = (selectedObject.Type == ObjectType.ResOil ? "O" : "W") + oil.Amount.ToString();
                    selectedObject.Radius        = oil.Radius;
                    break;

                case ObjectType.Scene:
                    MapSceneObject so = (MapSceneObject)selectedObject.Tag;

                    so.IsForest = checkBox1.Checked;

                    so.Amount = (float)numericUpDown12.Value;
                    so.Radius = (float)numericUpDown13.Value;
                    so.Model  = textBox3.Text;

                    if (string.IsNullOrEmpty(selectedObject.SectionName))
                    {
                        selectedObject.SectionName = "Scene" + Guid.NewGuid().ToString("N");
                    }
                    selectedObject.StringDisplay = so.Model;
                    selectedObject.Radius        = so.Radius;
                    break;

                case ObjectType.Sound:
                    MapSoundObject sndObj = (MapSoundObject)selectedObject.Tag;

                    sndObj.Radius  = (float)numericUpDown11.Value;
                    sndObj.SFXName = comboBox2.Text;

                    if (string.IsNullOrEmpty(selectedObject.SectionName))
                    {
                        selectedObject.SectionName = "Sound" + Guid.NewGuid().ToString("N");
                    }
                    selectedObject.StringDisplay = sndObj.SFXName;
                    selectedObject.Radius        = sndObj.Radius;
                    break;
                }
            }
        }
Example #3
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                #region city info
                StreamWriter sw = new StreamWriter(
                    File.Open(Path.Combine(folderBrowserDialog1.SelectedPath, "cities.xml"), FileMode.OpenOrCreate),
                    Encoding.UTF8);
                sw.BaseStream.SetLength(0);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<cities>");
                for (int i = 0; i < objectList.Count; i++)
                {
                    MapObject obj = objectList[i];
                    if (obj.Type == ObjectType.City)
                    {
                        MapCity city = (MapCity)obj.Tag;

                        sw.Write("    <"); sw.Write(obj.SectionName); sw.WriteLine(@">");

                        sw.Write("        ");
                        sw.Write("<Name>"); sw.Write(city.Name); sw.WriteLine(@"</Name>");

                        sw.Write("        ");
                        sw.Write("<Longitude>"); sw.Write(obj.Longitude); sw.WriteLine("</Longitude>");

                        sw.Write("        ");
                        sw.Write("<Latitude>"); sw.Write(obj.Latitude); sw.WriteLine("</Latitude>");

                        sw.Write("        ");
                        sw.Write("<Size>"); sw.Write(city.Size.ToString()); sw.WriteLine("</Size>");

                        if (city.ProblemChild != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Child>"); sw.Write(city.ProblemChild); sw.WriteLine("</Child>");
                        }
                        if (city.ProblemDisease != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Disease>"); sw.Write(city.ProblemDisease); sw.WriteLine("</Disease>");
                        }
                        if (city.ProblemEducation != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Education>"); sw.Write(city.ProblemEducation); sw.WriteLine("</Education>");
                        }
                        if (city.ProblemEnvironment != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Environment>"); sw.Write(city.ProblemEnvironment); sw.WriteLine("</Environment>");
                        }
                        if (city.ProblemGender != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Gender>"); sw.Write(city.ProblemGender); sw.WriteLine("</Gender>");
                        }
                        if (city.ProblemHunger != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Hunger>"); sw.Write(city.ProblemHunger); sw.WriteLine("</Hunger>");
                        }
                        if (city.ProblemMaternal != City.DefaultProblemWeight)
                        {
                            sw.Write("        ");
                            sw.Write("<Maternal>"); sw.Write(city.ProblemMaternal); sw.WriteLine("</Maternal>");
                        }
                        if (city.StartUp != -1)
                        {
                            sw.Write("        ");
                            sw.Write("<StartUp>"); sw.Write(city.StartUp); sw.WriteLine("</StartUp>");
                        }
                        if (city.FarmCount != 0)
                        {
                            sw.Write("        ");
                            sw.Write("<Farm>"); sw.Write(city.FarmCount); sw.WriteLine("</Farm>");
                        }



                        string[] linkable = city.LinkableCity;
                        if (linkable != null && linkable.Length > 0)
                        {
                            sw.Write("        "); sw.Write("<Linkable>");
                            for (int j = 0; j < linkable.Length; j++)
                            {
                                sw.Write(linkable[j]);
                                if (j != linkable.Length - 1)
                                {
                                    sw.Write(", ");
                                }
                            }
                        }
                        sw.WriteLine("</Linkable>");

                        sw.Write("    </"); sw.Write(obj.SectionName); sw.WriteLine(@">");
                    }
                }
                sw.WriteLine("</cities>");
                sw.Close();
                #endregion

                #region resource
                sw = new StreamWriter(
                    File.Open(Path.Combine(folderBrowserDialog1.SelectedPath, "resources.xml"), FileMode.OpenOrCreate),
                    Encoding.UTF8);

                sw.BaseStream.SetLength(0);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<Resources>");
                for (int i = 0; i < objectList.Count; i++)
                {
                    MapObject obj = objectList[i];
                    if (obj.Type == ObjectType.ResOil || obj.Type == ObjectType.ResWood)
                    {
                        MapResource res = (MapResource)obj.Tag;

                        sw.Write("    <"); sw.Write(obj.SectionName); sw.WriteLine(@">");

                        sw.Write("        ");
                        sw.Write("<Longitude>"); sw.Write(obj.Longitude); sw.WriteLine("</Longitude>");

                        sw.Write("        ");
                        sw.Write("<Latitude>"); sw.Write(obj.Latitude); sw.WriteLine("</Latitude>");

                        sw.Write("        ");
                        sw.Write("<Type>"); sw.Write(res.Type.ToString()); sw.WriteLine("</Type>");

                        sw.Write("        ");
                        sw.Write("<Amount>"); sw.Write(res.Amount); sw.WriteLine("</Amount>");


                        if (res.Type == NaturalResourceType.Wood)
                        {
                            sw.Write("        ");
                            sw.Write("<Radius>"); sw.Write(res.Radius); sw.WriteLine("</Radius>");
                        }
                        sw.Write("    </"); sw.Write(obj.SectionName); sw.WriteLine(@">");
                    }
                }

                sw.WriteLine("</Resources>");
                sw.Close();

                #endregion

                #region
                sw = new StreamWriter(
                    File.Open(Path.Combine(folderBrowserDialog1.SelectedPath, "sceneObjects.xml"), FileMode.OpenOrCreate),
                    Encoding.UTF8);

                sw.BaseStream.SetLength(0);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<Scenery>");
                for (int i = 0; i < objectList.Count; i++)
                {
                    MapObject obj = objectList[i];
                    if (obj.Type == ObjectType.Scene)
                    {
                        MapSceneObject sceObj = (MapSceneObject)obj.Tag;

                        sw.Write("    <"); sw.Write(obj.SectionName); sw.WriteLine(@">");

                        sw.Write("        ");
                        sw.Write("<Longitude>"); sw.Write(obj.Longitude); sw.WriteLine("</Longitude>");

                        sw.Write("        ");
                        sw.Write("<Latitude>"); sw.Write(obj.Latitude); sw.WriteLine("</Latitude>");

                        sw.Write("        ");
                        sw.Write("<IsForest>"); sw.Write(sceObj.IsForest); sw.WriteLine("</IsForest>");

                        sw.Write("        ");
                        sw.Write("<Radius>"); sw.Write(sceObj.Radius); sw.WriteLine("</Radius>");

                        sw.Write("        ");
                        sw.Write("<Amount>"); sw.Write(sceObj.Amount); sw.WriteLine("</Amount>");

                        sw.Write("        ");
                        sw.Write("<Model>"); sw.Write(sceObj.Model); sw.WriteLine("</Model>");

                        sw.Write("    </"); sw.Write(obj.SectionName); sw.WriteLine(@">");
                    }
                }
                sw.WriteLine("</Scenery>");
                sw.Close();
                #endregion

                #region
                sw = new StreamWriter(
                    File.Open(Path.Combine(folderBrowserDialog1.SelectedPath, "soundObjects.xml"), FileMode.OpenOrCreate),
                    Encoding.UTF8);

                sw.BaseStream.SetLength(0);
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sw.WriteLine("<SoundObjects>");
                for (int i = 0; i < objectList.Count; i++)
                {
                    MapObject obj = objectList[i];
                    if (obj.Type == ObjectType.Sound)
                    {
                        MapSoundObject sndObj = (MapSoundObject)obj.Tag;

                        sw.Write("    <"); sw.Write(obj.SectionName); sw.WriteLine(@">");

                        sw.Write("        ");
                        sw.Write("<Longitude>"); sw.Write(obj.Longitude); sw.WriteLine("</Longitude>");

                        sw.Write("        ");
                        sw.Write("<Latitude>"); sw.Write(obj.Latitude); sw.WriteLine("</Latitude>");

                        sw.Write("        ");
                        sw.Write("<SFX>"); sw.Write(sndObj.SFXName); sw.WriteLine("</SFX>");

                        sw.Write("        ");
                        sw.Write("<Radius>"); sw.Write(sndObj.Radius); sw.WriteLine("</Radius>");



                        sw.Write("    </"); sw.Write(obj.SectionName); sw.WriteLine(@">");
                    }
                }
                sw.WriteLine("</SoundObjects>");
                sw.Close();
                #endregion
            }
        }
Example #4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SimulationWorld sim = new SimulationWorld();

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string dir = folderBrowserDialog1.SelectedPath;

                Configuration config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "cities.xml")));

                foreach (KeyValuePair <string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;
                    MapCity city = new MapCity(sim, sect);

                    MapObject obj = new MapObject();
                    obj.Longitude     = city.Longitude;
                    obj.Latitude      = city.Latitude;
                    obj.Tag           = city;
                    obj.Type          = ObjectType.City;
                    obj.StringDisplay = city.Name;
                    obj.SectionName   = sect.Name;

                    cityTable.Add(sect.Name, city);

                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "sceneObjects.xml")));
                foreach (KeyValuePair <string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapSceneObject sceObj = new MapSceneObject(sect);
                    MapObject      obj    = new MapObject();
                    obj.Longitude     = sect.GetSingle("Longitude");
                    obj.Latitude      = sect.GetSingle("Latitude");
                    obj.Type          = ObjectType.Scene;
                    obj.Tag           = sceObj;
                    obj.StringDisplay = sceObj.Model;
                    obj.Radius        = sceObj.Radius;
                    obj.SectionName   = sect.Name;
                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "resources.xml")));

                foreach (KeyValuePair <string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapResource res = new MapResource(sim, sect);

                    MapObject obj = new MapObject();

                    obj.Longitude = res.Longitude;
                    obj.Latitude  = res.Latitude;
                    obj.Tag       = res;
                    if (res.Type == NaturalResourceType.Wood)
                    {
                        obj.Type = ObjectType.ResWood;
                    }
                    else if (res.Type == NaturalResourceType.Petro)
                    {
                        obj.Type = ObjectType.ResOil;
                    }
                    obj.StringDisplay = (obj.Type == ObjectType.ResOil ? "O" : "W") + res.Amount.ToString();
                    obj.Radius        = res.Radius;
                    obj.SectionName   = sect.Name;
                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundObjects.xml")));
                foreach (KeyValuePair <string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapSoundObject sndObj = new MapSoundObject(sect);

                    MapObject obj = new MapObject();
                    obj.Longitude = sect.GetSingle("Longitude");
                    obj.Latitude  = sect.GetSingle("Latitude");

                    obj.Type = ObjectType.Sound;

                    obj.Tag           = sndObj;
                    obj.StringDisplay = sndObj.SFXName;
                    obj.Radius        = sndObj.Radius;
                    obj.SectionName   = sect.Name;
                    objectList.Add(obj);
                }


                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundEffect.xml")));
                foreach (KeyValuePair <string, ConfigurationSection> s in config)
                {
                    comboBox2.Items.Add(s.Key);
                }
            }
            pictureBox1.Refresh();
        }
Example #5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SimulationWorld sim = new SimulationWorld();

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string dir = folderBrowserDialog1.SelectedPath;

                Configuration config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "cities.xml")));

                foreach (KeyValuePair<string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;
                    MapCity city = new MapCity(sim, sect);

                    MapObject obj = new MapObject();
                    obj.Longitude = city.Longitude;
                    obj.Latitude = city.Latitude;
                    obj.Tag = city;
                    obj.Type = ObjectType.City;
                    obj.StringDisplay = city.Name;
                    obj.SectionName = sect.Name;
                    
                    cityTable.Add(sect.Name, city);

                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "sceneObjects.xml")));
                foreach (KeyValuePair<string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapSceneObject sceObj = new MapSceneObject(sect);
                    MapObject obj = new MapObject();
                    obj.Longitude = sect.GetSingle("Longitude");
                    obj.Latitude = sect.GetSingle("Latitude");
                    obj.Type = ObjectType.Scene;
                    obj.Tag = sceObj;
                    obj.StringDisplay = sceObj.Model;
                    obj.Radius = sceObj.Radius;
                    obj.SectionName = sect.Name;
                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "resources.xml")));

                foreach (KeyValuePair<string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapResource res = new MapResource(sim, sect);

                    MapObject obj = new MapObject();

                    obj.Longitude = res.Longitude;
                    obj.Latitude = res.Latitude;
                    obj.Tag = res;
                    if (res.Type == NaturalResourceType.Wood)
                    {
                        obj.Type = ObjectType.ResWood;
                    }
                    else if (res.Type == NaturalResourceType.Petro)
                    {
                        obj.Type = ObjectType.ResOil;
                    }
                    obj.StringDisplay = (obj.Type == ObjectType.ResOil ? "O" : "W") + res.Amount.ToString();
                    obj.Radius = res.Radius;
                    obj.SectionName = sect.Name;
                    objectList.Add(obj);
                }

                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundObjects.xml")));
                foreach (KeyValuePair<string, ConfigurationSection> s in config)
                {
                    ConfigurationSection sect = s.Value;

                    MapSoundObject sndObj = new MapSoundObject(sect);

                    MapObject obj = new MapObject();
                    obj.Longitude = sect.GetSingle("Longitude");
                    obj.Latitude = sect.GetSingle("Latitude");

                    obj.Type = ObjectType.Sound;

                    obj.Tag = sndObj;
                    obj.StringDisplay = sndObj.SFXName;
                    obj.Radius = sndObj.Radius;
                    obj.SectionName = sect.Name;
                    objectList.Add(obj);
                  
                    
                }


                config = ConfigurationManager.Instance.CreateInstance(new FileLocation(Path.Combine(dir, "soundEffect.xml")));
                foreach (KeyValuePair<string, ConfigurationSection> s in config)
                {
                    comboBox2.Items.Add(s.Key);
                }
            }
            pictureBox1.Refresh();
        }
Example #6
0
        void DrawLink(Graphics g, MapCity city, int x, int y)
        {

            string[] v = city.LinkableCity;
            if (v != null)
            {

                for (int i = 0; i < v.Length; i++)
                {
                    int cx, cy;

                    MapCity cc = cityTable[v[i]];


                    MapObject.GetMapCoord(Apoc3D.MathLib.MathEx.Degree2Radian(cc.Longitude), Apoc3D.MathLib.MathEx.Degree2Radian(cc.Latitude), out cx, out cy);
                    g.DrawLine(pen, new Point(x, y), new Point(cx, cy));

                }
            }
        }