void MoveAttempt(char input) //Called whenever there is input from Update() //Effect: Moves selected object to a new tile based on input & checks to make sure it is okay to move first. { int x = 0; int y = 0; //Sets x and y to move by based on direction if (input == 'w') { x = 0; y = 1; } else if (input == 's') { x = 0; y = -1; } else if (input == 'a') { x = -1; y = 0; } else if (input == 'd') { x = 1; y = 0; } //Check if the selected object can move to new tile bool canMove = true; //Becomes false if any of the objects that will be moved can't move to that space if (!selectedObject.FreeMoveCheck(x, y)) { canMove = false; } //Check free tile for all objects associated with the Selected Object if (selectedObject.associatedObjects.Count != 0) { for (int i = 0; i < selectedObject.associatedObjects.Count; i++) { //If you can't move the object into that spot if (!selectedObject.associatedObjects[i].FreeMoveCheck(x, y)) { canMove = false; } } } //If all objects can move to their new tiles, move them if (canMove) { selectedObject.MoveObject(x, y); //If there are associated objects, move them if (selectedObject.associatedObjects.Count != 0) { for (int i = 0; i < selectedObject.associatedObjects.Count; i++) { selectedObject.associatedObjects[i].MoveObject(x, y); } } for (int i = 0; i < tables.Count; i++) { tables[i].GetComponent <MoveableObject>().Occupy(); } } }