Esempio n. 1
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="maze">Parent maze handle</param>
		public Square(Maze maze)
		{
			Maze = maze;
			Type = SquareType.Wall;
			Monsters = new Monster[4];
			InFog = true;

			Decorations = new int[] { -1, -1, -1, -1 };

			Items = new List<Item>[]
			{
				new List<Item>(),
				new List<Item>(),
				new List<Item>(),
				new List<Item>()
			};

		}
Esempio n. 2
0
		/// <summary>
		/// On monster enter action
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <returns>True on monster teleported</returns>
		public override bool OnMonsterEnter(Monster monster)
		{
			if (!TeleportMonsters || monster == null || Target == null)
				return false;

			monster.Teleport(Target);

			return true;
		}
Esempio n. 3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="monster"></param>
		public override bool OnMonsterLeave(Monster monster)
		{
			RunScript(PressurcePlateCondition.OnMonsterLeave);
			return false;
		}
Esempio n. 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;
		}
Esempio n. 5
0
		/// <summary>
		/// Adds a monster to the square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <returns>True on success</returns>
		public bool AddMonster(Monster monster)
		{
			return false;

			if (monster == null)
				return false;

			// Find the first free slot
			for (int i = 0; i < 4; i++)
				if (Monsters[i] == null)
				{
					Monsters[i] = monster;
					monster.Teleport(this);
					monster.OnSpawn();
					return true;
				}


			return false;
		}
Esempio n. 6
0
		/// <summary>
		/// Adds a monster to the square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <param name="position">Square position</param>
		/// <returns>True on success</returns>
		public bool AddMonster(Monster monster, SquarePosition position)
		{
			return false;

			if (position == SquarePosition.Center || GetMonster(position) != null || monster == null)
				return false;

			Monsters[(int)position] = monster;

			return true;
		}
Esempio n. 7
0
		/// <summary>
		/// A monster enters on the block
		/// </summary>
		/// <param name="monster">Monster handle</param>
		public void OnMonsterEnter(Monster monster)
		{
			if (monster == null)
				return;

			if (Actor != null)
				Actor.OnMonsterEnter(monster);
		}
Esempio n. 8
0
		/// <summary>
		/// Monster leaves the block
		/// </summary>
		/// <param name="monster">Monster handle</param>
		public void OnMonsterLeave(Monster monster)
		{
			if (monster == null)
				return;

			if (Actor != null)
				Actor.OnMonsterLeave(monster);
		}
Esempio n. 9
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="monster"></param>
		/// <returns></returns>
		public override bool OnMonsterEnter(Monster monster)
		{
			if (monster == null)
				return false;

			monster.Teleport(Target);
			monster.Location.Direction = Target.Direction;

			return true;
		}
Esempio n. 10
0
		/// <summary>
		/// Monster stand on the block
		/// </summary>
		/// <param name="monster"></param>
		public void OnMonsterStand(Monster monster)
		{
			if (monster == null)
				return;

			if (Actor != null)
				Actor.OnMonsterStand(monster);
		}
Esempio n. 11
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="monster"></param>
		/// <returns></returns>
		public override bool OnMonsterEnter(Monster monster)
		{
			if (!AffectMonsters || monster == null)
				return false;

			switch (Type)
			{
				case ForceFieldType.Spin:
				{
					monster.Location.Direction = Compass.Rotate(monster.Location.Direction, Spin);
				}
				break;

				case ForceFieldType.Move:
				{

					switch (Direction)
					{
						case CardinalPoint.North:
						monster.Location.Coordinate.Offset(0, -1);
						break;
						case CardinalPoint.South:
						monster.Location.Coordinate.Offset(0, 1);
						break;
						case CardinalPoint.West:
						monster.Location.Coordinate.Offset(-1, 0);
						break;
						case CardinalPoint.East:
						monster.Location.Coordinate.Offset(1, 0);
						break;
					}
				}
				break;
			
				
				case ForceFieldType.FaceTo:
				{
					monster.Location.Direction = Direction;
				}
				break;
			}

			return true;
		}
Esempio n. 12
0
		/// <summary>
		/// Fired when a monster stands on a square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <returns>True if event handled</returns>
		public virtual bool OnMonsterStand(Monster monster)
		{
			return false;
		}
Esempio n. 13
0
		/// <summary>
		/// Fired when a monster leaves the square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <returns>True if event handled</returns>
		public virtual bool OnMonsterLeave(Monster monster)
		{
			return false;
		}
Esempio n. 14
0
		/// <summary>
		/// Fired when a monster enters the square
		/// </summary>
		/// <param name="monster">Monster handle</param>
		/// <returns>True if event handled</returns>
		public virtual bool OnMonsterEnter(Monster monster)
		{
			return false;
		}
Esempio n. 15
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="monster"></param>
		/// <returns></returns>
		public override bool OnMonsterEnter(Monster monster)
		{
			if (monster == null || IsActivated)
				return false;

			if (Target == null)
				return false;

			monster.Teleport(Target);
			monster.Damage(Damage, SavingThrowType.Reflex, Difficulty);

			return true;
		}