static private void moveCharacterWithoutMovementCheck(int characterGroup, int characterIndex, Vector3D new_position) {
			if (new_position == null)
				throw new NoPositionPassedException ();

			// check that the position exists on the map
			// if the position does not exist, then throw
			// a PositionNotOnMapException
			// do this by checking that the x value is within the range of the jagged tileArray
			// if this throws an IndexOutOfRangeException,
			// then the positition is also not on the map
			try {
				if ((new_position.x < 0) || (new_position.x >= MapSystem.currentMap.tileArray[new_position.y].Length))
					throw new PositionNotOnMapException ("The position " + new_position.ToString() + " is not on the map.", null);
			}
			catch (IndexOutOfRangeException e) {
				throw new PositionNotOnMapException ("The position " + new_position.ToString() + " is not on the map.", e);
			}

			// assign the character's position
			try {
				_characterPositions [characterGroup] [characterIndex] = new_position;
			}
			catch (IndexOutOfRangeException e) {
				throw new NoSuchCharacterException ("No character exists in group " + characterGroup + " at index " + characterIndex, e);
			}
		}
		// check that the positions exist on the map, and place the characters there
		static public void placeCharacters(Vector3D[][] characterPositions) {
			if (characterPositions == null)
				throw new NoPositionPassedException ();

			foreach (Vector3D[] group in characterPositions) {
				foreach (Vector3D position in group) {
					try {
						if ((position.x < 0) || (position.x >= MapSystem.currentMap.tileArray [position.y].Length))
							throw new PositionNotOnMapException ("The position " + position.ToString () + " is not on the map.", null);
					} catch (IndexOutOfRangeException e) {
						throw new PositionNotOnMapException ("The position " + position.ToString () + " is not on the map.", e);
					}
				}
			}

			_characterPositions = characterPositions;
		}
		static void Main (string[] args) {
			MapSystem.generateTestMap();
			//MapSystem.loadMap (AppDomain.CurrentDomain.BaseDirectory + "../../MapXMLs/Map1.xml");

			Vector3D[] startPositionsForPlayers = new Vector3D[numPlayers];
			for (int index = 0; index < startPositionsForPlayers.Length; index++) {
				startPositionsForPlayers [index] = Vector3D.NewZero ();
			}



			PositionSystem.placeCharacters (new Vector3D[1][] {startPositionsForPlayers});
			MapSystem.currentMap.events.onEnter ();

			do {
				displayTextMap ();
				displayPlayerLocations ();
			} while (doMenu ());
				
			MapSystem.currentMap.events.onExit ();

			MapSystem.currentMap.serialize (AppDomain.CurrentDomain.BaseDirectory + "../../MapXMLs/Map1.xml");
		}
		static public void teleportCharacterToWalkableLocation(int characterGroup, int characterIndex, Vector3D new_position) {
			// check that the new position can be walked on
			// if an index out of range exception is thrown, the tile is not on the map

			try {
				if (MapSystem.currentMap.tileArray [new_position.y] [new_position.x].walkable == false)
					throw new MoveToNewPositionIsBlockedException ("The position " + new_position.ToString() + " cannot be walked on.");
			}
			catch (IndexOutOfRangeException e) {
				throw new PositionNotOnMapException ("The position " + new_position.ToString() + " is not on the map.", e);
			}

			// move the character to the new position
			moveCharacterWithoutMovementCheck (characterGroup, characterIndex, new_position);
		}
Exemple #5
0
		public float DotProduct (Vector3D other)
		{
			return x * other.x + y * other.y + z * other.z;
		}
Exemple #6
0
		public Vector3D (Vector3D v)
		{
			this.x = v.x;
			this.y = v.y;
			this.z = v.z;
		}
Exemple #7
0
		public Vector3D Add (Vector3D v)
		{
			x += v.x;
			y += v.y;
			z += v.z;
			return this;
		}
Exemple #8
0
		public static Vector3D CrossProduct (Vector3D a, Vector3D b)
		{
			return new Vector3D (a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
		}
Exemple #9
0
		override public void onMove (Vector3D tile_postion) {
			Console.Out.WriteLine ("A character moved to " + tile_postion.ToString ());
		}