Exemplo n.º 1
0
        public void LoadDestinationXml(XmlElement arrowNode, LocationDatabase locDb)
        {
            XmlElement  ele;
            Coordinates coords;

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("route")) != null)
            {
                try
                {
                    int index;
                    int.TryParse(ele.GetAttribute("routeIndex"), out index);
                    Route route = Route.FromXml(ele, locDb);
                    if (route.Count > 0)
                    {
                        this.Route      = route;
                        this.RouteIndex = index;
                        return;
                    }
                }
                catch (Exception ex) { Util.HandleException(ex); }
            }

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("object")) != null)
            {
                const System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
                int id, icon;
                if (int.TryParse(ele.GetAttribute("id"), hex, null, out id) &&
                    int.TryParse(ele.GetAttribute("icon"), hex, null, out icon) &&
                    Coordinates.TryParse(ele.GetAttribute("coords"), out coords))
                {
                    this.DestinationObject = new GameObject(id, ele.GetAttribute("name"), icon, Host.Actions, coords);
                    return;
                }
            }

            if ((ele = (XmlElement)arrowNode.SelectSingleNode("location")) != null)
            {
                int      locId;
                Location loc;
                if (int.TryParse(ele.GetAttribute("id"), out locId) && locDb.TryGet(locId, out loc))
                {
                    this.DestinationLocation = loc;
                    return;
                }
            }

            // No other methods succeeded
            if (Coordinates.TryParse(arrowNode.GetAttribute("coords"), out coords))
            {
                this.DestinationCoords = coords;
            }
        }
Exemplo n.º 2
0
		public void LoadDestinationXml(XmlElement arrowNode, LocationDatabase locDb)
		{
			XmlElement ele;
			Coordinates coords;
			if ((ele = (XmlElement)arrowNode.SelectSingleNode("route")) != null)
			{
				try
				{
					int index;
					int.TryParse(ele.GetAttribute("routeIndex"), out index);
					Route route = Route.FromXml(ele, locDb);
					if (route.Count > 0)
					{
						this.Route = route;
						this.RouteIndex = index;
						return;
					}
				}
				catch (Exception ex) { Util.HandleException(ex); }
			}

			if ((ele = (XmlElement)arrowNode.SelectSingleNode("object")) != null)
			{
				const System.Globalization.NumberStyles hex = System.Globalization.NumberStyles.HexNumber;
				int id, icon;
				if (int.TryParse(ele.GetAttribute("id"), hex, null, out id)
					&& int.TryParse(ele.GetAttribute("icon"), hex, null, out icon)
					&& Coordinates.TryParse(ele.GetAttribute("coords"), out coords))
				{
					this.DestinationObject = new GameObject(id, ele.GetAttribute("name"), icon, Host.Actions, coords);
					return;
				}
			}

			if ((ele = (XmlElement)arrowNode.SelectSingleNode("location")) != null)
			{
				int locId;
				Location loc;
				if (int.TryParse(ele.GetAttribute("id"), out locId) && locDb.TryGet(locId, out loc))
				{
					this.DestinationLocation = loc;
					return;
				}
			}

			// No other methods succeeded
			if (Coordinates.TryParse(arrowNode.GetAttribute("coords"), out coords))
			{
				this.DestinationCoords = coords;
			}
		}
Exemplo n.º 3
0
		public Location ToLocation(LocationDatabase locDb)
		{
			Location loc;
			if (locDb.TryGet(mId, out loc))
				return loc;

			loc = new Location(mId, Name, LocationType._StartPoint, Coords, "");
			loc.Icon = mIcon;
			return loc;
		}