Ejemplo n.º 1
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;
		}
Ejemplo n.º 2
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;
		}
Ejemplo n.º 3
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;
		}
Ejemplo n.º 4
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;
		}
Ejemplo n.º 5
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;
		}