Пример #1
0
		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);
			}
		}
Пример #2
0
        static public void walkCharacterPlusX(int characterGroup, int characterIndex)
        {
            Vector3D current_position = getCharacterPosition(characterGroup, characterIndex);

            // throw an exception if the you can't exit the character's current tile to the positive x direction
            if (MapSystem.currentMap.tileArray [current_position.y] [current_position.x].exit_to_positive_x == false)
            {
                throw new MoveToNewPositionIsBlockedException("Character (" + characterGroup + "," + characterIndex + ") cannot exit the position " + current_position.ToString() + " in the +x direction.");
            }

            Vector3D new_position = current_position + new Vector3D(1, 0, 0);

            // if the new position is not walkable, throw an error

            // if an index out of range exception is thrown, there is no tile in the positive x direction
            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);
            }

            // set the new height to the new tile's height
            new_position.z = MapSystem.currentMap.tileArray [new_position.y] [new_position.x].height;

            // move the character to the new position
            moveCharacterWithoutMovementCheck(characterGroup, characterIndex, new_position);
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
		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);
		}
Пример #6
0
		override public void onMove (Vector3D tile_postion) {
			Console.Out.WriteLine ("A character moved to " + tile_postion.ToString ());
		}