private void toggleDoorMethod(Unit exe) //Created by Nick Lee 18-9-14, modified 26-9-14 { Movement = Game.MoveType.Forward; moving = (Vector2)game.moveTransform[Movement][0]; //gets the object from the dictionary and converts to a vector2 moving = game.facingDirection[exe.facing] * moving; moving = exe.position + moving; //gets final position if (game.gameMap.hasDoor(moving)) { if (game.gameMap.isDoorOpen(moving)) { game.gameMap.setDoorState(moving, false); //sets door state to closed } else { game.gameMap.setDoorState(moving, true); //sets door stat to open } } else { Debug.Log("no door in front of unit, actionManager, toggledoor"); } //error catching and message update(Game.ActionType.ToggleDoor, exe); postAction(); }
private void toggleDoorMethod(Unit exe)//Created by Nick Lee 18-9-14, modified 26-9-14 { Movement = Game.MoveType.Forward; moving = (Vector2)game.moveTransform[Movement][0]; //gets the object from the dictionary and converts to a vector2 moving = game.facingDirection[exe.facing] * moving; moving = exe.position + moving; //gets final position if (game.gameMap.hasDoor (moving)) { if (game.gameMap.isDoorOpen (moving)) game.gameMap.setDoorState (moving, false); //sets door state to closed else game.gameMap.setDoorState (moving, true); //sets door stat to open } else Debug.Log ("no door in front of unit, actionManager, toggledoor"); //error catching and message update(Game.ActionType.ToggleDoor, exe); postAction (); }
private void moveMethod(Unit mover) //Created by Nick Lee 16-9-14, modified 5-11-14 { Path currentPath; //makes a path variable if (!attackMove) { currentPath = path; //if it isnt a movement caused by a melee attack } else { currentPath = customPath; attackMove = false; //else sets attackmove to false and gets the path made by the attack } //sets the path to iterate through if (currentPath.path.Count == 0) { moving = mover.position; compassFacing = mover.facing; sittingStill = true; update(Game.ActionType.Move, mover); } else { for (int i = 0; i < currentPath.path.Count; i++) //iterates through all movements in the path { if (!movementStopped) //if the unit wasn't killed by overwatch { Movement = currentPath.path [i]; removeAP(mover, UnitData.getMoveSet(mover.unitType) [Movement]); //removes required AP from unit moving = (Vector2)game.moveTransform [Movement] [0]; //gets the object from the dictionary and converts to a vector2 moving = game.facingDirection [mover.facing] * moving; moving = mover.position + moving; //gets final position Quaternion direction = game.facingDirection [mover.facing] * ((Quaternion)game.moveTransform [Movement] [1]); //gets the quaternion from the current facing and the required movement if (Mathf.Abs(direction.eulerAngles.z - 0) < 0.1f) { compassFacing = Game.Facing.North; //changes facing to north } else if (Mathf.Abs(direction.eulerAngles.z - 270) < 0.1f) { compassFacing = Game.Facing.East; //changes facing to east } else if (Mathf.Abs(direction.eulerAngles.z - 180) < 0.1f) { compassFacing = Game.Facing.South; //changes facing to south } else if (Mathf.Abs(direction.eulerAngles.z - 90) < 0.1f) { compassFacing = Game.Facing.West; //changes facing to west } else { Debug.Log("Invalid unit facing: ActionManager, move method"); } //error catching and message if (mover.position.x < 0f) { if (game.gameMap.otherAreas.Length > -1 - (int)mover.position.x) { moving = game.gameMap.otherAreas [-1 - (int)mover.position.x].adjacentPosition; compassFacing = game.gameMap.otherAreas [-1 - (int)mover.position.x].relativePosition; } } game.gameMap.shiftUnit(mover.position, moving, compassFacing); update(Game.ActionType.Move, mover); //update method for move; //moves the unit } else { movementStopped = false; break; } //if the unit was killed in the middle of a movement causes movements to stop } } postAction(); //post action method }
private void moveMethod(Unit mover)//Created by Nick Lee 16-9-14, modified 5-11-14 { Path currentPath; //makes a path variable if (!attackMove) { currentPath = path; //if it isnt a movement caused by a melee attack } else { currentPath = customPath; attackMove = false; //else sets attackmove to false and gets the path made by the attack } //sets the path to iterate through if (currentPath.path.Count == 0) { moving = mover.position; compassFacing = mover.facing; sittingStill = true; update (Game.ActionType.Move, mover); } else { for (int i = 0; i < currentPath.path.Count; i++) { //iterates through all movements in the path if (!movementStopped) { //if the unit wasn't killed by overwatch Movement = currentPath.path [i]; removeAP (mover, UnitData.getMoveSet (mover.unitType) [Movement]);//removes required AP from unit moving = (Vector2)game.moveTransform [Movement] [0]; //gets the object from the dictionary and converts to a vector2 moving = game.facingDirection [mover.facing] * moving; moving = mover.position + moving; //gets final position Quaternion direction = game.facingDirection [mover.facing] * ((Quaternion)game.moveTransform [Movement] [1]); //gets the quaternion from the current facing and the required movement if (Mathf.Abs (direction.eulerAngles.z - 0) < 0.1f) { compassFacing = Game.Facing.North; //changes facing to north } else if (Mathf.Abs (direction.eulerAngles.z - 270) < 0.1f) { compassFacing = Game.Facing.East; //changes facing to east } else if (Mathf.Abs (direction.eulerAngles.z - 180) < 0.1f) { compassFacing = Game.Facing.South; //changes facing to south } else if (Mathf.Abs (direction.eulerAngles.z - 90) < 0.1f) { compassFacing = Game.Facing.West; //changes facing to west } else Debug.Log ("Invalid unit facing: ActionManager, move method"); //error catching and message if (mover.position.x < 0f) { if (game.gameMap.otherAreas.Length > -1 - (int)mover.position.x) { moving = game.gameMap.otherAreas [-1 - (int)mover.position.x].adjacentPosition; compassFacing = game.gameMap.otherAreas [-1 - (int)mover.position.x].relativePosition; } } game.gameMap.shiftUnit (mover.position, moving, compassFacing); update (Game.ActionType.Move, mover); //update method for move; //moves the unit } else { movementStopped = false; break; } //if the unit was killed in the middle of a movement causes movements to stop } } postAction (); //post action method }