public Path (Path copyPath) { this.APCost = copyPath.APCost; this.initialSquare = copyPath.initialSquare; this.initialFacing = copyPath.initialFacing; this.finalSquare = copyPath.finalSquare; this.finalFacing = copyPath.finalFacing; this.path = new List<Game.MoveType>(copyPath.path); }
public Path (Vector2 initialSquare, Game.Facing initialFacing) { APCost = 0; this.initialSquare = initialSquare; this.initialFacing = initialFacing; finalSquare = initialSquare; finalFacing = initialFacing; path = new List<Game.MoveType>(); }
public Path(Path copyPath) { this.APCost = copyPath.APCost; this.initialSquare = copyPath.initialSquare; this.initialFacing = copyPath.initialFacing; this.finalSquare = copyPath.finalSquare; this.finalFacing = copyPath.finalFacing; this.path = new List <Game.MoveType>(copyPath.path); }
public Path(Vector2 initialSquare, Game.Facing initialFacing) { APCost = 0; this.initialSquare = initialSquare; this.initialFacing = initialFacing; finalSquare = initialSquare; finalFacing = initialFacing; path = new List <Game.MoveType>(); }
public void place(Vector2 position, Game.Facing facing) { if (currentlyRevealing) { //Place the genestealer bool squareIsValid = false; //Check whether the square is in selectableSquares for (int i = 0; i < selectableSquares.Count; i++) { if (selectableSquares[i] == position) { squareIsValid = true; selectableSquares.RemoveAt(i); break; } } if (squareIsValid) { gameController.deploy(Game.EntityType.GS, position, facing); if (blipActed) { gameController.gameMap.getOccupant(position).AP = 0; } numberOfGSToPlace--; } } //If there are no genestealers left if (numberOfGSToPlace == 0) { //Finish the reveal, and continue the game currentlyRevealing = false; gameController.changeGameState(Game.GameState.Inactive); if (gameController.unitSelected) { gameController.selectUnit(gameController.selectedUnit.gameObject); } //Check for overwatch shots if (involuntary) { if (gameController.gameMap.isOccupied(centralPosition)) { actionManager.postInvolReveal(gameController.gameMap.getOccupant(centralPosition)); } } involuntary = false; //Unpause animations gameController.ioModule.continueActionSequence(); if (gameController.playerTurn != gameController.thisPlayer && !gameController.gameIsMultiplayer) { gameController.algorithm.continueAI(); } } }
//Once the facing selection has been done, creates an ActionManager to handle the movement public void orientationClicked(Game.Facing facing) { ActionManager actionManager = new ActionManager(gameController.selectedUnit, Game.ActionType.Move); actionManager.path = gameController.algorithm.getPath(gameController.selectedUnit.position, gameController.selectedUnit.facing, moveTargetSquare, facing, UnitData.getMoveSet(gameController.selectedUnit.unitType)); actionManager.performAction(); gameController.changeGameState(Game.GameState.Inactive); facingInProgress = false; }
//Removes the unit from the inital position, and places it at the final //position and facing. If placing the unit in a deployment area, the //y coordinate does not have any effect, and the unit is simply placed //as the last index in the set. The unit's position is set to be appropriate. //Logs an error if the requested inital position does not exist, there is no //unit at the position, the final position does not exist, or the final //position is already occupied. public void shiftUnit(Vector2 initialPosition, Vector2 finalPosition, Game.Facing finalFacing) { //Remove the unit from the initial square. Unit movingUnit = retrieveUnit(initialPosition, "shiftUnit"); if (movingUnit != null) { movingUnit.position = finalPosition; movingUnit.facing = finalFacing; placeUnit(movingUnit); } }
public Unit(string name, Game.EntityType unitType, Vector2 position, Game.Facing facing) { this.name = name; this.unitType = unitType; this.position = position; this.facing = facing; this.AP = 0; this.isOnOverwatch = false; this.hasSustainedFire = false; this.isJammed = false; this.sustainedFireTarget = null; this.currentLoS = new List <Vector2>(); this.noOfGS = 1; }
public Unit(string name, Game.EntityType unitType, Vector2 position, Game.Facing facing) { this.name = name; this.unitType = unitType; this.position = position; this.facing = facing; this.AP = 0; this.isOnOverwatch = false; this.hasSustainedFire = false; this.isJammed = false; this.sustainedFireTarget = null; this.currentLoS = new List<Vector2>(); this.noOfGS = 1; }
public void revealOrientationClicked(Game.Facing facing) { // === Remove Hologram = Alisdair == foreach (Transform ps in mapController.getSquare(revealPosition).model.transform) { ps.gameObject.GetComponent <ParticleSystem>().emissionRate = ioController.normalEmissionRate; ps.gameObject.GetComponent <ParticleSystem>().enableEmission = false; } ioController.activePartSys.Clear(); // =============================== hideSelectableRevealSquares(); mapController.getSquare(revealPosition).model.GetComponent <Renderer>().material.color = Color.white; revealManager.place(revealPosition, facing); allowRevealSelection = true; if (revealManager.currentlyRevealing) { showSelectableRevealSquares(); } }
private void makeActions(Game.ActionType actionMade, Unit exe) //Created by Nick Lee 23-9-14, modified 5-11-14 { executor = exe; actionType = actionMade; //gets action made finishLoS(); //gets the updated LoS for all marines APCost = UnitData.getAPCost(actionType); //gets the AP cost of the action if (overwatchShot) { APCost = 0; } if (actionType == Game.ActionType.Move) { executie = null; //no target unit for moving movePosition = moving; //position to move to set by moving moveFacing = compassFacing; //facing set by compass facing if (!sittingStill) { APCost = UnitData.getMoveSet(executor.unitType)[Movement]; //APCost depends on type of movement } else { APCost = 0; sittingStill = false; } unitJams = false; //cant jam voidSustainedFire(executor); voidOverwatch(executor); } else if (actionType == Game.ActionType.Attack) { voidOverwatch(executor); voidOverwatch(executie); movePosition = executor.position; //no position change moveFacing = executor.facing; //no facing change voidSustainedFire(executor); voidSustainedFire(executie); unitJams = false; } else if (actionType == Game.ActionType.Shoot) { movePosition = executor.position; //position unchanged moveFacing = executor.facing; //facing unchanged } else if (actionType == Game.ActionType.ToggleDoor) { voidSustainedFire(executor); voidOverwatch(executor); unitJams = false; } else if (actionType == Game.ActionType.Overwatch) { executie = null; //no target unit movePosition = executor.position; //no change movement moveFacing = executor.facing; //no change in facing unitJams = false; //no jamming } else { Debug.Log("Error with action type , ActionManager, makeActions"); } //error message and catching returnAction.actionType = actionType; returnAction.executor = executor; returnAction.target = executie; returnAction.movePosition = movePosition; returnAction.moveFacing = moveFacing; returnAction.APCost = APCost; returnAction.unitJams = unitJams; returnAction.destroyedUnits = destroyedUnits; returnAction.sustainedFireLost = sustainedFireLost; returnAction.completeLoS = completeLoS; returnAction.prevLoS = prevLoS; returnAction.sustainedFireChanged = sustainedFireChanged; returnAction.lostOverwatch = lostOverwatch; returnAction.diceRoll = dieRolled; actions.Add(returnAction); //creates a return Action and adds it to the list of actions resetVariables(); }
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 makeActions(Game.ActionType actionMade, Unit exe) //Created by Nick Lee 23-9-14, modified 5-11-14 { executor = exe; actionType = actionMade; //gets action made finishLoS (); //gets the updated LoS for all marines APCost = UnitData.getAPCost(actionType); //gets the AP cost of the action if (overwatchShot) APCost = 0; if (actionType == Game.ActionType.Move) { executie = null; //no target unit for moving movePosition = moving; //position to move to set by moving moveFacing = compassFacing; //facing set by compass facing if(!sittingStill) APCost = UnitData.getMoveSet(executor.unitType)[Movement]; //APCost depends on type of movement else { APCost = 0; sittingStill = false; } unitJams = false; //cant jam voidSustainedFire(executor); voidOverwatch(executor); } else if (actionType == Game.ActionType.Attack) { voidOverwatch(executor); voidOverwatch(executie); movePosition = executor.position; //no position change moveFacing = executor.facing; //no facing change voidSustainedFire(executor); voidSustainedFire(executie); unitJams = false; } else if (actionType == Game.ActionType.Shoot) { movePosition = executor.position; //position unchanged moveFacing = executor.facing; //facing unchanged } else if (actionType == Game.ActionType.ToggleDoor) { voidSustainedFire(executor); voidOverwatch(executor); unitJams = false; } else if (actionType == Game.ActionType.Overwatch) { executie = null; //no target unit movePosition = executor.position; //no change movement moveFacing = executor.facing; //no change in facing unitJams = false; //no jamming } else Debug.Log ("Error with action type , ActionManager, makeActions"); //error message and catching returnAction.actionType = actionType; returnAction.executor = executor; returnAction.target = executie; returnAction.movePosition = movePosition; returnAction.moveFacing = moveFacing; returnAction.APCost = APCost; returnAction.unitJams = unitJams; returnAction.destroyedUnits = destroyedUnits; returnAction.sustainedFireLost = sustainedFireLost; returnAction.completeLoS = completeLoS; returnAction.prevLoS = prevLoS; returnAction.sustainedFireChanged = sustainedFireChanged; returnAction.lostOverwatch = lostOverwatch; returnAction.diceRoll = dieRolled; actions.Add (returnAction); //creates a return Action and adds it to the list of actions resetVariables (); }
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 }