예제 #1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Square handle</param>
		/// <param name="evt">Event square handle</param>
		public ScriptedDialog(Square square, EventSquare evt)
		{
			if (square == null)
				throw new ArgumentNullException("Square is null");

			if (evt == null)
				throw new ArgumentNullException("EventSquare is null");

			Event = evt;
			Square = square;

			Picture = new Texture2D(Event.PictureName);

			if (Event.DisplayBorder)
			{
				Border = new Texture2D("border.png");
			}
			
			// HACK: Hard coded maximum button for ScriptDialog
			Choices = new ScriptChoice[MaxButtonCount];
			Buttons = new GUIScriptButton[MaxButtonCount];
			for (int i = 0 ; i < MaxButtonCount ; i++)
			{
				Buttons[i] = new GUIScriptButton();
				Buttons[i].Click +=new EventHandler(ButtonClick);
			}
		}
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="square">Square handle</param>
        /// <param name="evt">Event square handle</param>
        public ScriptedDialog(Square square, EventSquare evt)
        {
            if (square == null)
            {
                throw new ArgumentNullException("Square is null");
            }

            if (evt == null)
            {
                throw new ArgumentNullException("EventSquare is null");
            }

            Event  = evt;
            Square = square;

            Picture = new Texture2D(Event.PictureName);

            if (Event.DisplayBorder)
            {
                Border = new Texture2D("border.png");
            }

            // HACK: Hard coded maximum button for ScriptDialog
            Choices = new ScriptChoice[MaxButtonCount];
            Buttons = new GUIScriptButton[MaxButtonCount];
            for (int i = 0; i < MaxButtonCount; i++)
            {
                Buttons[i]        = new GUIScriptButton();
                Buttons[i].Click += new EventHandler(ButtonClick);
            }
        }
예제 #3
0
		/// <summary>
		/// Loads square definition
		/// </summary>
		/// <param name="xml">XmlNode handle</param>
		/// <returns></returns>
		public bool Load(XmlNode xml)
		{
			if (xml == null || xml.Name != Tag)
				return false;

			// A little speedup
			string[] cardinalnames = Enum.GetNames(typeof(CardinalPoint));


			// Attributes of the square
			InFog = xml.Attributes["infog"] != null;
			NoMonster = xml.Attributes["nomonster"] != null;
			NoGhost = xml.Attributes["noghost"] != null;

			if (xml.Attributes["type"] != null)
			{
				SquareType tmptype;
				Enum.TryParse<SquareType>(xml.Attributes["type"].Value, out tmptype);
				Type = tmptype;
			}
			else
				Type = SquareType.Ground;

			foreach (XmlNode node in xml)
			{
				if (node.NodeType == XmlNodeType.Comment)
					continue;



				switch (node.Name.ToLower())
				{
					case "monster":
					{
						Monster monster = new Monster();
						monster.Load(node);
						monster.Teleport(this, (SquarePosition)Enum.Parse(typeof(SquarePosition), node.Attributes["position"].Value));
					}
					break;

					case "item":
					{
						SquarePosition loc = (SquarePosition)Enum.Parse(typeof(SquarePosition), node.Attributes["location"].Value);
						Item item = ResourceManager.CreateAsset<Item>(node.Attributes["name"].Value);
						if (item != null)
							Items[(int)loc].Add(item);
					}
					break;

					case "decoration":
					{
						Decorations[0] = int.Parse(node.Attributes[cardinalnames[0]].Value);
						Decorations[1] = int.Parse(node.Attributes[cardinalnames[1]].Value);
						Decorations[2] = int.Parse(node.Attributes[cardinalnames[2]].Value);
						Decorations[3] = int.Parse(node.Attributes[cardinalnames[3]].Value);
					}
					break;

					case WallSwitch.Tag:
					{
						Actor = new WallSwitch(this);
						Actor.Load(node);
					}
					break;

					case Door.Tag:
					{
						Actor = new Door(this);
						Actor.Load(node);
					}
					break;

					case Teleporter.Tag:
					{
						Actor = new Teleporter(this);
						Actor.Load(node);
					}
					break;

					case PressurePlate.Tag:
					{
						Actor = new PressurePlate(this);
						Actor.Load(node);
					}
					break;

					case Pit.Tag:
					{
						Actor = new Pit(this);
						Actor.Load(node);
					}
					break;

					case ForceField.Tag:
					{
						Actor = new ForceField(this);
						Actor.Load(node);
					}
					break;

					case Stair.Tag:
					{
						Actor = new Stair(this);
						Actor.Load(node);
					}
					break;

					case EventSquare.Tag:
					{
						Actor = new EventSquare(this);
						Actor.Load(node);
					}
					break;

					case AlcoveActor.Tag:
					{
						Actor = new AlcoveActor(this);
						Actor.Load(node);
					}
					break;

					default:
					{
					//	Trace.WriteLine("[Square] Load() : Unknown node \"{0}\"", node.Name);
					}
					break;
				}
			}



			return true;
		}
예제 #4
0
        /// <summary>
        /// Loads square definition
        /// </summary>
        /// <param name="xml">XmlNode handle</param>
        /// <returns></returns>
        public bool Load(XmlNode xml)
        {
            if (xml == null || xml.Name != Tag)
            {
                return(false);
            }

            // A little speedup
            string[] cardinalnames = Enum.GetNames(typeof(CardinalPoint));


            // Attributes of the square
            InFog     = xml.Attributes["infog"] != null;
            NoMonster = xml.Attributes["nomonster"] != null;
            NoGhost   = xml.Attributes["noghost"] != null;

            if (xml.Attributes["type"] != null)
            {
                SquareType tmptype;
                Enum.TryParse <SquareType>(xml.Attributes["type"].Value, out tmptype);
                Type = tmptype;
            }
            else
            {
                Type = SquareType.Ground;
            }

            foreach (XmlNode node in xml)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }



                switch (node.Name.ToLower())
                {
                case "monster":
                {
                    Monster monster = new Monster();
                    monster.Load(node);
                    monster.Teleport(this, (SquarePosition)Enum.Parse(typeof(SquarePosition), node.Attributes["position"].Value));
                }
                break;

                case "item":
                {
                    SquarePosition loc  = (SquarePosition)Enum.Parse(typeof(SquarePosition), node.Attributes["location"].Value);
                    Item           item = ResourceManager.CreateAsset <Item>(node.Attributes["name"].Value);
                    if (item != null)
                    {
                        Items[(int)loc].Add(item);
                    }
                }
                break;

                case "decoration":
                {
                    Decorations[0] = int.Parse(node.Attributes[cardinalnames[0]].Value);
                    Decorations[1] = int.Parse(node.Attributes[cardinalnames[1]].Value);
                    Decorations[2] = int.Parse(node.Attributes[cardinalnames[2]].Value);
                    Decorations[3] = int.Parse(node.Attributes[cardinalnames[3]].Value);
                }
                break;

                case WallSwitch.Tag:
                {
                    Actor = new WallSwitch(this);
                    Actor.Load(node);
                }
                break;

                case Door.Tag:
                {
                    Actor = new Door(this);
                    Actor.Load(node);
                }
                break;

                case Teleporter.Tag:
                {
                    Actor = new Teleporter(this);
                    Actor.Load(node);
                }
                break;

                case PressurePlate.Tag:
                {
                    Actor = new PressurePlate(this);
                    Actor.Load(node);
                }
                break;

                case Pit.Tag:
                {
                    Actor = new Pit(this);
                    Actor.Load(node);
                }
                break;

                case ForceField.Tag:
                {
                    Actor = new ForceField(this);
                    Actor.Load(node);
                }
                break;

                case Stair.Tag:
                {
                    Actor = new Stair(this);
                    Actor.Load(node);
                }
                break;

                case EventSquare.Tag:
                {
                    Actor = new EventSquare(this);
                    Actor.Load(node);
                }
                break;

                case AlcoveActor.Tag:
                {
                    Actor = new AlcoveActor(this);
                    Actor.Load(node);
                }
                break;

                default:
                {
                    //	Trace.WriteLine("[Square] Load() : Unknown node \"{0}\"", node.Name);
                }
                break;
                }
            }



            return(true);
        }