/// <summary> /// Moves the movile enviroment to the given coordinate. Coordinates are in space form not in map reference form. /// </summary> /// <param name="x">The x coordinate. The new x coordinate of the mobile enviromet</param> /// <param name="y">The y coordinate. The new y coordinate of the mobile enviromet</param> /// <param name="z">The z coordinate. The new z coordinate of the mobile enviromet</param> /// <param name="mobile">Mobile. The mobile enviroment to be moved.</param> public static bool moveTo(float x, float y, float z, MobileEnviroment mobile) { //The enviroment that the mobile will move into Enviroment enviroment = getEnviromentFromCords(x, y, z); //The enviroment bellow the enviroment that the mobile will move into Enviroment floorEnviroment = getEnviromentFromCords(x, y - 1, z); //We first check if the enviroment can be moved into if (canWalkTo(enviroment, mobile)) { //If we can we then check if the floor enviroment can be walked ontop of. if (canWalkOnTopOf(floorEnviroment)) { //If the attempt works we then attempt to walk ontop of the floor enviroment if (walkOnTopOf(floorEnviroment)) { //We then move the mobile into the new location mobile.updateMovement(x - mobile.transform.position.x, y - mobile.transform.position.y, z - mobile.transform.position.z, enviroment); return(true); } } } return(false); }
//The key is added to the player public override void postWalk(MobileEnviroment enviroment) { if (!isCollected) { isCollected = true; PlayerController.addKey(hackablePart.getKeyID()); } }
/// <summary> /// Checks if the mobile can walk into the enviroment /// </summary> /// <returns><c>true</c>, if the mobile can walk to it <c>false</c> otherwise.</returns> /// <param name="enviroment">Enviroment.</param> private static bool canWalkTo(Enviroment enviroment, MobileEnviroment mobile) { if (enviroment == null) { //If there is nothing there then you can walk to it return(true); } else { return(enviroment.canWalkTo(mobile)); } }
public override void preWalk(MobileEnviroment enviroment) { //If it isn't locked then the door needs to be opened first onces it is then the mob can move through it if (hackablePart.locked) { hackablePart.unlock(); } if (!hackablePart.isDoorClosing()) { hackablePart.open(); } }
//The walk to function public override void postWalk(MobileEnviroment enviroment) { //Resets the turn counter and marks the button as stood on turnCounter = 0; isStoodOn = true; //If the button isn't already depressed then it's variables and images is updated if (!isDown) { isDown = true; setLookToDown(); //Trigger function is called trigger.triggerOn(); } }
public override void preWalk(MobileEnviroment enviroment) { //When you walk to the goal the main menu is loaded Application.LoadLevel("MainMenu"); }
//Goal defaults is that it can be walked to but can't be walked on top of public override bool canWalkTo(MobileEnviroment enviroment) { return(true); }
public virtual void postWalk(MobileEnviroment mobile) { }
//Abstract methods needed form mobiles using the Enviroment Map public abstract bool canWalkTo(MobileEnviroment enviroment);
public override bool canWalkTo(MobileEnviroment enviroment) { //Mobs can only walk to the object if it isn't locked return(!hackablePart.locked || ((enviroment is PlayerController) && (PlayerController.hasKey(hackablePart.key)))); }
//They disapear when walked on public override void preWalk(MobileEnviroment enviroment) { gameObject.SetActive(false); }