Esempio n. 1
0
 public MapRegion()
 {
     m_GoLocation = new Point3D(-1, -1, 0);
     m_Area = new ArrayList();
     m_SubRegions = new ArrayList();
     m_Entrance = new Point3D(int.MinValue, int.MinValue, int.MinValue);
 }
Esempio n. 2
0
        public XmlElement GetXml(XmlDocument dom)
        {
            XmlElement x = dom.CreateElement("region");

            if (m_Type != string.Empty)
                x.SetAttribute("type", m_Type);

            if (m_Priority != 50)
                x.SetAttribute("priority", m_Priority.ToString());

            if (m_Name != string.Empty)
                x.SetAttribute("name", m_Name);

            if (m_MinZ != DefaultMinZ || m_MaxZ != DefaultMaxZ)
            {
                XmlElement xRange = dom.CreateElement("zrange");

                if (m_MinZ != DefaultMinZ)
                    xRange.SetAttribute("min", m_MinZ.ToString());
                if (m_MaxZ != DefaultMaxZ)
                    xRange.SetAttribute("max", m_MaxZ.ToString());

                x.AppendChild(xRange);
            }

            foreach (MapRect rect in m_Area)
            {
                XmlElement xRect = dom.CreateElement("rect");
                xRect.SetAttribute("x", rect.Start.X.ToString());
                xRect.SetAttribute("y", rect.Start.Y.ToString());
                xRect.SetAttribute("width", rect.Width.ToString());
                xRect.SetAttribute("height", rect.Height.ToString());

                if (rect.MinZ != m_MinZ)
                    xRect.SetAttribute("zmin", rect.MinZ.ToString());
                if (rect.MaxZ != m_MaxZ)
                    xRect.SetAttribute("zmax", rect.MaxZ.ToString());

                x.AppendChild(xRect);
            }

            if (m_Area != null && m_Area.Count > 0)
            {
                MapRect rect = m_Area[0] as MapRect;
                Point3D DefaultGoLocation = new Point3D(rect.Start.X + (rect.End.X - rect.Start.X) / 2, rect.Start.Y + (rect.End.Y - rect.Start.Y) / 2, 0);

                if (m_GoLocation != DefaultGoLocation && m_GoLocation.X != -1 && m_GoLocation.Y != -1)
                {
                    XmlElement xGoLocation = dom.CreateElement("go");
                    xGoLocation.SetAttribute("x", m_GoLocation.X.ToString());
                    xGoLocation.SetAttribute("y", m_GoLocation.Y.ToString());
                    xGoLocation.SetAttribute("z", m_GoLocation.Z.ToString());
                    x.AppendChild(xGoLocation);
                }
            }

            if (m_Entrance.X != int.MinValue && m_Entrance.Y != int.MinValue)
            {
                XmlElement xEntrance = dom.CreateElement("entrance");
                xEntrance.SetAttribute("x", m_Entrance.X.ToString());
                xEntrance.SetAttribute("y", m_Entrance.Y.ToString());
                if (m_Entrance.Z != int.MinValue)
                    xEntrance.SetAttribute("z", m_Entrance.Z.ToString());
                x.AppendChild(xEntrance);
            }

            if (m_Music != string.Empty)
            {
                XmlElement xMusic = dom.CreateElement("music");
                xMusic.SetAttribute("name", m_Music);
                x.AppendChild(xMusic);
            }

            // Begin other data

            // <rune name="Haven City" />
            if (m_Rune != null && m_Rune != string.Empty)
            {
                XmlElement xRune = dom.CreateElement("rune");
                xRune.SetAttribute("name", m_Rune);
                x.AppendChild(xRune);
            }

            // <smartNoHousing active="true" />
            if (m_SmartNoHousing != XmlBool.Unspecified)
            {
                XmlElement xHouse = dom.CreateElement("smartNoHousing");
                xHouse.SetAttribute("active", m_SmartNoHousing.ToString().ToLower());
                x.AppendChild(xHouse);
            }

            // <logoutDelay active="false" />
            if (m_LogoutDelayActive != XmlBool.Unspecified)
            {
                XmlElement xLogout = dom.CreateElement("logoutDelay");
                xLogout.SetAttribute("active", m_LogoutDelayActive.ToString().ToLower());
                x.AppendChild(xLogout);
            }

            // <guards disabled="true" />
            if (m_GuardsDisabled != XmlBool.Unspecified)
            {
                XmlElement xGuards = dom.CreateElement("guards");
                xGuards.SetAttribute("disabled", m_GuardsDisabled.ToString().ToLower());
                x.AppendChild(xGuards);
            }

            // spawning, for now just keep a record of the info so we can persist it.
            if (m_Spawning != null)
            {
                foreach (XmlElement spawning in m_Spawning)
                {
                    XmlNode xSpawn = dom.ImportNode(spawning, true);
                    x.AppendChild(xSpawn);
                }
            }

            // Subregions
            foreach (MapRegion sub in m_SubRegions)
            {
                XmlElement xSub = sub.GetXml(dom);
                x.AppendChild(xSub);
            }

            return x;
        }
Esempio n. 3
0
        public static bool ReadPoint3D( XmlElement xml, ref Point3D value, bool mandatory )
        {
            int x = 0, y = 0, z = 0;

            bool xyOk = ReadInt32( xml, "x", ref x, mandatory ) & ReadInt32( xml, "y", ref y, mandatory );
            bool zOk = ReadInt32( xml, "z", ref z, mandatory );

            if ( xyOk && zOk )
            {
                if ( !zOk )
                    z = 0;

                value = new Point3D( x, y, z );
                return true;
            }

            return false;
        }
Esempio n. 4
0
 public static bool ReadPoint3D( XmlElement xml, ref Point3D value )
 {
     return ReadPoint3D( xml, ref value, true );
 }
Esempio n. 5
0
 public bool Contains(Point3D p)
 {
     return (p.m_X >= m_Start.m_X)
         && (p.m_X < m_End.m_X)
         && (p.m_Y >= m_Start.m_Y)
         && (p.m_Y < m_End.m_Y)
         && (p.m_Z >= m_MinZ)
         && (p.m_Z < m_MaxZ);
 }
Esempio n. 6
0
 public bool Contains(Point3D p)
 {
     return (m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y);
     //return ( m_Start <= p && m_End > p );
 }