Exemplo n.º 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);
			}
		}
Exemplo n.º 2
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Parent square handle</param>
		public WallSwitch(Square square)
			: base(square)
		{
			ActivatedDecoration = -1;
			DeactivatedDecoration = -1;
			Scripts = new List<WallSwitchScript>();
			Reusable = true;
			WasUsed = false;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Square handle</param>
		public PressurePlate(Square square) : base(square)
		{
			Scripts = new List<PressurePlateScript>();
			AcceptItems = true;
			CanPassThrough = true;
			IsBlocking = false;
			Reusable = true;
			WasUsed = false;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public Pit(Square block) : base(block)
		{
			if (block == null)
				throw new ArgumentNullException("block");

			Damage = new Dice();
			AcceptItems = true;
			CanPassThrough = true;
			IsBlocking = false;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="block"></param>
		public Stair(Square block) : base(block)
		{
			if (block == null)
				throw new ArgumentNullException("block");

			block.Type = SquareType.Ground;
			AcceptItems = false;
			CanPassThrough = false;
			IsBlocking = false;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Cosntructor
		/// </summary>
		/// <param name="square">Parent square handle</param>
		public AlcoveActor(Square square) : base(square)
		{
			Alcoves = new Alcove[4]
			{
				new Alcove(),
				new Alcove(),
				new Alcove(),
				new Alcove(),
			};
			IsBlocking = true;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Constructor
		/// </summary>
		public ForceField(Square square) : base(square)
		{
			Type = ForceFieldType.Spin;
			Spin = CompassRotation.Rotate180;
			Direction = CardinalPoint.North;

			AffectTeam = true;
			AffectMonsters = true;
			AffectItems = true;

			AcceptItems = true;
			CanPassThrough = true;
			IsBlocking = false;
		}
Exemplo n.º 8
0
		/// <summary>
		/// Constructor
		/// </summary>
		public Teleporter(Square block) : base(block)
		{
			if (block == null)
				throw new ArgumentNullException("block");

			AcceptItems = true;
			CanPassThrough = true;
			IsBlocking = false;

			TeleportTeam = true;
			TeleportMonsters = true;
			TeleportItems = true;
			IsVisible = true;


			Anim = ResourceManager.CreateAsset<Animation>("Teleporter");
			Anim.Play();
		}
Exemplo n.º 9
0
		/// <summary>
		/// Initializes doors
		/// </summary>
		/// <param name="square">Parent square handle</param>
		public Door(Square square) : base(square)
		{
			// Zone of the button to open/close the door
			Button = new Rectangle(252, 90, 20, 28);

			Count = new SwitchCount();

			// Sounds
			OpenSound = ResourceManager.LockSharedAsset<AudioSample>("door open");
			CloseSound = ResourceManager.LockSharedAsset<AudioSample>("door close");


			AcceptItems = false;
			Speed = TimeSpan.FromSeconds(1);

			if (Square != null || Square.Maze != null)
				Type = Square.Maze.DefaultDoorType;

			//IsActivated = IsOpen;
		}
Exemplo n.º 10
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Square handle</param>
		public SquareActor(Square square)
		{
			Square = square;
			IsEnabled = true;
		}
Exemplo n.º 11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="square">Square handle</param>
 public EventSquare(Square square) : base(square)
 {
     Choices      = new List <ScriptChoice>();
     MessageColor = Color.White;
     Remaining    = 1;
 }
Exemplo n.º 12
0
		/// <summary>
		/// Constructor
		/// </summary>
		public SetTo()
		{
			Name = Tag;
			Square = new Square(null);
		}
Exemplo n.º 13
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Parent square handle</param>
		public Launcher(Square square) : base(square)
		{

		}
Exemplo n.º 14
0
		/// <summary>
		/// Defines a square at a given location
		/// </summary>
		/// <param name="target">Location in the dungeon</param>
		/// <param name="square">Square handle</param>
		/// <returns>True on success</returns>
		public bool SetSquare(DungeonLocation target, Square square)
		{
			if (target == null || square == null)
				return false;

			Maze maze = GetMaze(target.Maze);
			if (maze == null)
				return false;

			return maze.SetSquare(target.Coordinate, square);
		}
Exemplo n.º 15
0
        /// <summary>
        /// Update the flying item
        /// </summary>
        /// <param name="time">Game time</param>
        /// <param name="maze">Maze where the flying item is</param>
        /// <returns>True if the blocked or false if nothing happened</rereturns>
        public bool Update(GameTime time, Maze maze)
        {
            // Item can't move any more
            if (Distance == 0)
            {
                return(true);
            }

            LastUpdate += time.ElapsedGameTime;

            if (LastUpdate > Speed)
            {
                LastUpdate -= Speed;

                // Find the next block according to the direction
                Point dst = Point.Empty;
                switch (Location.Direction)
                {
                case CardinalPoint.North:
                    dst = new Point(Location.Coordinate.X, Location.Coordinate.Y - 1);
                    break;

                case CardinalPoint.East:
                    dst = new Point(Location.Coordinate.X + 1, Location.Coordinate.Y);
                    break;

                case CardinalPoint.South:
                    dst = new Point(Location.Coordinate.X, Location.Coordinate.Y + 1);
                    break;

                case CardinalPoint.West:
                    dst = new Point(Location.Coordinate.X - 1, Location.Coordinate.Y);
                    break;
                }


                // Blocked by a wall, fall before the block
                Square square = maze.GetSquare(dst);


                // Can item pass through a door ?
                if (square.Actor != null && square.Actor is Door)
                {
                    Door door = square.Actor as Door;
                    if (!door.CanItemsPassThrough(Item))
                    {
                        Distance = 0;
                    }
                }


                // Wall is blocking
                else if (square.IsBlocking)
                {
                    Distance = 0;
                }


                // Blocked by an obstacle, but fall on the block
                if ((square.Actor != null && square.Actor.CanPassThrough) || square.MonsterCount > 0)
                {
                    Location.Coordinate = dst;

                    SquarePosition gp = Location.Position;
                    switch (Location.Direction)
                    {
                    case CardinalPoint.North:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.South:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        break;

                    case CardinalPoint.West:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        break;

                    case CardinalPoint.East:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;
                    }


                    // Get monster and hit it
                    if (square.MonsterCount > 0)
                    {
                        Monster[] monsters = maze.GetSquare(Location.Coordinate).Monsters;
                        foreach (Monster monster in monsters)
                        {
                            if (monster != null)
                            {
                                Attack attack = new Attack(Caster, monster, Item);
                                if (attack.IsAHit)
                                {
                                    Distance = 0;
                                }
                            }
                        }
                    }
                    return(true);
                }



                // Drop the item at good ground position
                if (Distance == 0)
                {
                    SquarePosition gp = Location.Position;
                    switch (Location.Direction)
                    {
                    case CardinalPoint.North:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        break;

                    case CardinalPoint.South:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.SouthEast)
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.West:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthWest;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthWest;
                        }
                        break;

                    case CardinalPoint.East:
                        if (gp == SquarePosition.NorthEast || gp == SquarePosition.NorthWest)
                        {
                            Location.Position = SquarePosition.NorthEast;
                        }
                        else
                        {
                            Location.Position = SquarePosition.SouthEast;
                        }
                        break;
                    }

                    return(true);
                }
                else
                {
                    Distance--;
                    Location.Coordinate = dst;
                }
            }

            return(false);
        }
Exemplo n.º 16
0
		/// <summary>
		/// Teleport the monster to a given location
		/// </summary>
		/// <param name="square">Destination square</param>
		/// <returns>True on success</returns>
		public bool Teleport(Square square)
		{
			if (!Teleport(square, SquarePosition.NorthWest))
				if (!Teleport(square, SquarePosition.NorthEast))
					if (!Teleport(square, SquarePosition.SouthEast))
						if (!Teleport(square, SquarePosition.SouthWest))
							return false;

			return true;
		}
Exemplo n.º 17
0
		/// <summary>
		/// Teleport the monster to a given location
		/// </summary>
		/// <param name="target">Destination square</param>
		/// <param name="pos">Square position</param>
		public bool Teleport(Square square, SquarePosition pos)
		{
			if (square == null)
				return false;

			// Move to another square
			if (Square != square)
			{
				// Remove from previous location
				if (Square != null)
					Square.Monsters[(int)position] = null;

				Square = square;

				// Add the monster to the new square
				position = pos;
				Square.Monsters[(int)pos] = this;
			}

			// Move to a subsquare
			else
			{
				// Remove from previous position
				if (Square == null || Square.GetMonster(pos) != null)
					return false;

				Square.Monsters[(int)position] = null;

				// Move to the new position
				if (square != null)
					square.Monsters[(int)pos] = this;

				position = pos;
			}

			return true;
		}
Exemplo n.º 18
0
		/// <summary>
		/// Default constructor
		/// </summary>
		/// <param name="square">Square location</param>
		public ThrownItem(Square square)
		{
			if (square != null)
				Location = new DungeonLocation(square.Maze.Name, square.Location);

		}
Exemplo n.º 19
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Parent square handle</param>
		public Generator(Square square) : base(square)
		{

		}
Exemplo n.º 20
0
		/// <summary>
		/// Sets a square at a given location
		/// </summary>
		/// <param name="location">Location in the maze</param>
		/// <param name="square">Square handle</param>
		/// <returns>True on success</returns>
		public bool SetSquare(Point location, Square square)
		{
			if (square == null || !Rectangle.Contains(location))
				return false;

			Squares[location.Y][location.X] = square;
			square.Location = location;
			square.Maze = this;

			return true;
		}
Exemplo n.º 21
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="maze">Maze handle</param>
		/// <param name="location">View's location</param>
		public ViewField(Maze maze, DungeonLocation location)
		{
			Maze = maze;
			Blocks = new Square[16];


			// Cone of vision : 15 blocks + 1 block for the Point of View
			//
			//    ABCDE
			//    FGHIJ
			//     KLM
			//     N^O
			//
			// ^ => Point of view
			switch (location.Direction)
			{
				#region North
				case CardinalPoint.North:
				{
					Blocks[0] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y - 3));
					Blocks[1] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y - 3));
					Blocks[2] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y - 3));
					Blocks[3] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y - 3));
					Blocks[4] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y - 3));

					Blocks[5] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y - 2));
					Blocks[6] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y - 2));
					Blocks[7] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y - 2));
					Blocks[8] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y - 2));
					Blocks[9] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y - 2));

					Blocks[10] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y - 1));
					Blocks[11] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y - 1));
					Blocks[12] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y - 1));

					Blocks[13] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y));
					Blocks[15] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y));

				}
				break;
				#endregion

				#region South
				case CardinalPoint.South:
				{
					Blocks[0] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y + 3));
					Blocks[1] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y + 3));
					Blocks[2] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y + 3));
					Blocks[3] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y + 3));
					Blocks[4] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y + 3));

					Blocks[5] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y + 2));
					Blocks[6] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y + 2));
					Blocks[7] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y + 2));
					Blocks[8] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y + 2));
					Blocks[9] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y + 2));

					Blocks[10] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y + 1));
					Blocks[11] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y + 1));
					Blocks[12] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y + 1));

					Blocks[13] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y));
					Blocks[15] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y));
				}
				break;
				#endregion

				#region East
				case CardinalPoint.East:
				{
					Blocks[0] = maze.GetSquare(new Point(location.Coordinate.X + 3, location.Coordinate.Y - 2));
					Blocks[1] = maze.GetSquare(new Point(location.Coordinate.X + 3, location.Coordinate.Y - 1));
					Blocks[2] = maze.GetSquare(new Point(location.Coordinate.X + 3, location.Coordinate.Y));
					Blocks[3] = maze.GetSquare(new Point(location.Coordinate.X + 3, location.Coordinate.Y + 1));
					Blocks[4] = maze.GetSquare(new Point(location.Coordinate.X + 3, location.Coordinate.Y + 2));

					Blocks[5] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y - 2));
					Blocks[6] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y - 1));
					Blocks[7] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y));
					Blocks[8] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y + 1));
					Blocks[9] = maze.GetSquare(new Point(location.Coordinate.X + 2, location.Coordinate.Y + 2));

					Blocks[10] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y - 1));
					Blocks[11] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y));
					Blocks[12] = maze.GetSquare(new Point(location.Coordinate.X + 1, location.Coordinate.Y + 1));

					Blocks[13] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y - 1));
					Blocks[15] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y + 1));
				}
				break;
				#endregion

				#region West
				case CardinalPoint.West:
				{
					Blocks[0] = maze.GetSquare(new Point(location.Coordinate.X - 3, location.Coordinate.Y + 2));
					Blocks[1] = maze.GetSquare(new Point(location.Coordinate.X - 3, location.Coordinate.Y + 1));
					Blocks[2] = maze.GetSquare(new Point(location.Coordinate.X - 3, location.Coordinate.Y));
					Blocks[3] = maze.GetSquare(new Point(location.Coordinate.X - 3, location.Coordinate.Y - 1));
					Blocks[4] = maze.GetSquare(new Point(location.Coordinate.X - 3, location.Coordinate.Y - 2));

					Blocks[5] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y + 2));
					Blocks[6] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y + 1));
					Blocks[7] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y));
					Blocks[8] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y - 1));
					Blocks[9] = maze.GetSquare(new Point(location.Coordinate.X - 2, location.Coordinate.Y - 2));

					Blocks[10] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y + 1));
					Blocks[11] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y));
					Blocks[12] = maze.GetSquare(new Point(location.Coordinate.X - 1, location.Coordinate.Y - 1));

					Blocks[13] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y + 1));
					Blocks[15] = maze.GetSquare(new Point(location.Coordinate.X, location.Coordinate.Y - 1));
				}
				break;
				#endregion
			}

			// Team's position
			Blocks[14] = maze.GetSquare(location.Coordinate);
		}
Exemplo n.º 22
0
		/// <summary>
		/// Loads the maze definition
		/// </summary>
		/// <param name="xml">XmlNode handle</param>
		/// <returns>True on success</returns>
		public bool Load(XmlNode xml)
		{
			if (xml == null || xml.Name != Tag)
				return false;

			Name = xml.Attributes["name"].Value;

			Square block = null;

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


				switch (node.Name.ToLower())
				{
					case "tileset":
					{
						WallTilesetName = node.Attributes["wall"].Value;
						DecorationName = node.Attributes["decoration"].Value;
					}
					break;

					case "description":
					{
						Description = node.InnerText;
					}
					break;

					case "flyingitems":
					{
						foreach (XmlNode subnode in node)
						{
							ThrownItem item = new ThrownItem(null);
							item.Load(subnode);
							ThrownItems.Add(item);
						}
					}
					break;

					case MazeZone.Tag:
					{
						MazeZone zone = new MazeZone();
						zone.Load(node);
						Zones.Add(zone);
					}
					break;

					case "decorations":
					{
						FloorPitDeco = int.Parse(node.Attributes["floorpit"].Value);
						CeilingPitDeco = int.Parse(node.Attributes["ceilingpit"].Value);
						DoorDeco = int.Parse(node.Attributes["door"].Value);
					}
					break;

					case "doors":
					{
						DefaultDoorType = (DoorType)Enum.Parse(typeof(DoorType), node.Attributes["type"].Value);
					}
					break;


					#region Squares

					case "squares":
					{
						// Resize maze
						Size = new Size(int.Parse(node.Attributes["width"].Value), int.Parse(node.Attributes["height"].Value));
						Point location = new Point();

						foreach (XmlNode subnode in node)
						{
							switch (subnode.Name.ToLower())
							{
								// Add a row
								case Square.Tag:
								{
									block = new Square(this);
									block.Location = location;
									block.Load(subnode);

									Squares[location.Y][location.X] = block;
								}
								break;
							}

							// Next location
							location.X++;
							if (location.X == Size.Width)
							{
								location.Y++;
								location.X = 0;
							}
						}

					}
					break;

					#endregion


					default:
					{
					}
					break;
				}
			}



			return true;
		}
Exemplo n.º 23
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="square">Square handle</param>
		public EventSquare(Square square) : base(square)
		{
			Choices = new List<ScriptChoice>();
			MessageColor = Color.White;
			Remaining = 1;
		}
Exemplo n.º 24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="square">Parent square handle</param>
 public Generator(Square square) : base(square)
 {
 }