public void checkForPlayer() { //The npc only does something if it doesn't ignore the player if (action != playerAction.Ignore) { PlayerController player; //It then attempts to spot a player given it's direction, sightlength and spotlength //It calls EnviromentMap functions for this switch (directionFacing) { case direction.posotiveX: { player = EnviromentMap.findPlayerLookingPosotiveX(transform.position.x, transform.position.y, transform.position.z, sightLength, soundLength); break; } case direction.negativeX: { player = EnviromentMap.findPlayerLookingNegativeX(transform.position.x, transform.position.y, transform.position.z, sightLength, soundLength); break; } case direction.posotiveZ: { player = EnviromentMap.findPlayerLookingPosotiveZ(transform.position.x, transform.position.y, transform.position.z, sightLength, soundLength); break; } default: { player = EnviromentMap.findPlayerLookingNegativeZ(transform.position.x, transform.position.y, transform.position.z, sightLength, soundLength); break; } } //If a player was found we can then act if (player != null) { //If the kill action is present then we reset the level if (action == playerAction.Kill) { Application.LoadLevel(Application.loadedLevelName); } //If the teleport ation is present we display a times message and teleport the player else { LevelGUI.displayTimedMessage(this.name + " spotted you and teleported you."); //player.triggerWalkAwayDueToTeleport (); EnviromentMap.moveTo(teleX, teleY, teleZ, player); } } } }
/// <summary> /// Moves the position of the player. /// </summary> /// <param name="x">The number of the spaces to move in the x direction</param> /// <param name="y">The number of the spaces to move in the y direction</param> /// <param name="z">The number of the spaces to move in the z direction</param> private void movePosition(int x, int y, int z) { //Movements are only accepted if there are steps remaining if (levelStats.canStep()) { //The movement method is then called in the Enviroment Map, if it's successful the step counter is incremented if (EnviromentMap.moveTo(transform.position.x + x, transform.position.y + y, transform.position.z + z, this)) { levelStats.step(); } } else { //If there are no steps remaining a message is displayed displayStepLimitMessage(); } }
//Moves the mob in the z direction if possible protected virtual bool movePosotiveZ(int z) { return(EnviromentMap.moveTo(transform.position.x, transform.position.y, transform.position.z + z, this)); }