Example #1
0
		public Region(XmlElement xml, Map map, Region parent)
		{
			m_Map = map;
			m_Parent = parent;
			m_Dynamic = false;

			if (m_Parent == null)
			{
				m_ChildLevel = 0;
				m_Priority = DefaultPriority;
			}
			else
			{
				m_ChildLevel = m_Parent.ChildLevel + 1;
				m_Priority = m_Parent.Priority;
			}

			ReadString(xml, "name", ref m_Name, false);

			if (parent == null)
			{
				ReadInt32(xml, "priority", ref m_Priority, false);
			}

			int minZ = MinZ;
			int maxZ = MaxZ;

			XmlElement zrange = xml["zrange"];
			ReadInt32(zrange, "min", ref minZ, false);
			ReadInt32(zrange, "max", ref maxZ, false);

			var area = new List<Rectangle3D>();
			foreach (XmlElement xmlRect in xml.SelectNodes("rect"))
			{
				var expansion = Expansion.None;

				if (ReadEnum(xmlRect, "expansion", ref expansion, false) && expansion > Core.Expansion)
				{
					continue;
				}

				Rectangle3D rect = new Rectangle3D();
				if (ReadRectangle3D(xmlRect, minZ, maxZ, ref rect))
				{
					area.Add(rect);
				}
			}

			m_Area = area.ToArray();

			if (m_Area.Length == 0)
			{
				Utility.PushColor(ConsoleColor.Red);
				Console.WriteLine("Empty area for region '{0}'", this);
				Utility.PopColor();
			}

			if (!ReadPoint3D(xml["go"], map, ref m_GoLocation, false) && m_Area.Length > 0)
			{
				Point3D start = m_Area[0].Start;
				Point3D end = m_Area[0].End;

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

				m_GoLocation = new Point3D(x, y, m_Map.GetAverageZ(x, y));
			}

			MusicName music = DefaultMusic;

			ReadEnum(xml["music"], "name", ref music, false);

			Music = music;
		}
Example #2
0
		public static bool CheckLuck( int chance )
		{
			return ( chance > Utility.Random( 10000 ) );
		}