示例#1
0
        public RegionPanel(int mapWidth, int mapHeight, MapRegion region)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_Updating = true;

            m_MapWidth  = mapWidth;
            m_MapHeight = mapHeight;

            NumX.Maximum = mapWidth;
            NumY.Maximum = mapHeight;

            TextBoxRegionName.Text = region.Name;
            TextBoxTypeName.Text   = region.TypeName;
            TextBoxRuneName.Text   = region.RuneName;
            TextBoxMusicName.Text  = region.MusicName;

            checkBoxSmartNoHousing.Visible = false;
            checkBoxGuardsDisabled.Visible = false;

            if (region.LogoutDelayActive == XmlBool.False)
            {
                checkBoxLogoutDelay.Checked = false;
            }
            else
            {
                checkBoxLogoutDelay.Checked = true;
            }

            if (region.TypeName == "NoHousingRegion")
            {
                checkBoxSmartNoHousing.Visible = true;
                if (region.SmartNoHousing == XmlBool.True)
                {
                    checkBoxSmartNoHousing.Checked = true;
                }
                else
                {
                    checkBoxSmartNoHousing.Checked = false;
                }
            }
            else if (region.TypeName == "GuardedRegion" || region.TypeName == "TownRegion")
            {
                checkBoxGuardsDisabled.Visible = true;
                if (region.GuardsDisabled == XmlBool.True)
                {
                    checkBoxGuardsDisabled.Checked = true;
                }
                else
                {
                    checkBoxGuardsDisabled.Checked = false;
                }
            }

            try
            {
                NumX.Value = region.GoLocation.X;
            }
            catch
            {
                NumX.Value = NumX.Minimum;
            }
            try
            {
                NumY.Value = region.GoLocation.Y;
            }
            catch
            {
                NumY.Value = NumY.Minimum;
            }
            try
            {
                NumZ.Value = region.GoLocation.Z;
            }
            catch
            {
                NumY.Value = 0;
            }

            try
            {
                NumMinZ.Value = region.MinZ;
            }
            catch
            {
                NumMinZ.Value = MapRegion.DefaultMinZ;
            }
            try
            {
                NumMaxZ.Value = region.MaxZ;
            }
            catch
            {
                NumMaxZ.Value = MapRegion.DefaultMaxZ;
            }


            try
            {
                NumPriority.Value = region.Priority;
            }
            catch
            {
                NumPriority.Value = 50;
            }

            m_Updating = false;
        }
示例#2
0
        public static MapRegion LoadRegion(XmlElement xml)
        {
            MapRegion r = new MapRegion();

            XmlSupport.ReadString(xml, "name", ref r.m_Name);
            XmlSupport.ReadInt32(xml, "priority", ref r.m_Priority);
            XmlSupport.ReadString(xml, "type", ref r.m_Type);

            XmlElement zrange = xml["zrange"];

            XmlSupport.ReadInt32(zrange, "min", ref r.m_MinZ, false);
            XmlSupport.ReadInt32(zrange, "max", ref r.m_MaxZ, false);

            foreach (XmlElement xmlRect in xml.SelectNodes("rect"))
            {
                MapRect rect = new MapRect();
                if (XmlSupport.ReadRectangle3D(xmlRect, r.m_MinZ, r.m_MaxZ, ref rect))
                {
                    r.m_Area.Add(rect);
                }
            }

            if (!XmlSupport.ReadPoint3D(xml["go"], ref r.m_GoLocation, false) && r.m_Area.Count > 0)
            {
                Point2D start = ((MapRect)r.m_Area[0]).Start;

                Point2D end = ((MapRect)r.m_Area[0]).End;

                int x = start.X + (end.X - start.X) / 2;
                int y = start.Y + (end.Y - start.Y) / 2;

                r.m_GoLocation = new Point3D(x, y, 0);
            }

            int entranceX = int.MinValue;
            int entranceY = int.MinValue;
            int entranceZ = int.MinValue;

            XmlElement entrance = xml["entrance"];

            if (entrance != null)
            {
                XmlSupport.ReadInt32(entrance, "x", ref entranceX);
                XmlSupport.ReadInt32(entrance, "y", ref entranceY);
                XmlSupport.ReadInt32(entrance, "z", ref entranceZ);
            }

            r.m_Entrance.X = entranceX;
            r.m_Entrance.Y = entranceY;
            r.m_Entrance.Z = entranceZ;

            XmlSupport.ReadString(xml["music"], "name", ref r.m_Music);

            // <rune name="Haven City" />
            XmlSupport.ReadString(xml["rune"], "name", ref r.m_Rune);
            // <smartNoHousing active="true" />
            XmlSupport.ReadXmlBool(xml["smartNoHousing"], "active", ref r.m_SmartNoHousing);
            // <logoutDelay active="false" />
            XmlSupport.ReadXmlBool(xml["logoutDelay"], "active", ref r.m_LogoutDelayActive);
            // <guards disabled="true" />
            XmlSupport.ReadXmlBool(xml["guards"], "disabled", ref r.m_GuardsDisabled);


            // spawning, for now just keep a record of the info so we can persist it.
            r.m_Spawning = xml.SelectNodes("spawning");

            // Subregions
            foreach (XmlElement xRegion in xml.SelectNodes("region"))
            {
                MapRegion sub = MapRegion.LoadRegion(xRegion);

                if (sub != null)
                {
                    r.m_SubRegions.Add(sub);
                }
            }

            return(r);
        }