public void toggleIsInMovementMode() {// (wip) will toggle weather this character is in movement mode or in action mode Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement(); if (isInMovementMode) { if (numOfAvailibleActions > 0) { isInMovementMode = false; Grid_Character_Movement.resetAreaOfMovement(); print("Is in action mode"); } } else { if (remainingMovement > 0) { isInMovementMode = true; Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: remainingMovement); print("Is in movement mode"); } } }
// ------------------ turn management --------------------------- public void startTurn() {//(wip) will reset all of a creatures stats at start of turn, will be called at start of turn remainingMovement = maxMovement; numOfAvailibleActions = numOfMaxActions; numOfAvailibleBonusActions = numOfMaxBonusActions; isInMovementMode = true; Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement(); // will pull up area of movement for that creature Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: maxMovement); isTurn = true; }
public void doAction(string actionType = "Wait") {//(wip) this script will be called when a creature inputs an action command if (isTurn) { if (numOfAvailibleActions > 0) { ActionDatabase actData = new ActionDatabase(); Action act = actData.callUpAction(actionType); if (selectionChecker(act)) {// wait for selection currentAct = act; requestSelection = true; Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement(); Grid_Character_Movement.resetAreaOfMovement(); Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: act.range); print("target selection is needed"); } else {// run without selection Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement(); Grid_Character_Movement.resetAreaOfMovement(); Grid_Character_Movement.findAreaOfMovement(currentX: Creature_Stats.currentX, currentY: Creature_Stats.currentY, currentZ: Creature_Stats.currentZ, numOfSteps: act.range); outgoingActionProcessing(act: act, creaturePos: new int[] { Creature_Stats.currentX, Creature_Stats.currentY, Creature_Stats.currentZ }, targetPos: new int[, ] { { Creature_Stats.currentX, Creature_Stats.currentY, Creature_Stats.currentZ } }); } print("this creature did something"); } else { print("this creature has no more actions left"); } } else { print("It is not this creatures turn"); } }
// ------------------- action processing ----------------------------- public void outgoingActionProcessing(int[] creaturePos, int[,] targetPos, Action act = null) {//(wip) this script will find the creature to do the action to and will send the needed data to that given creature if (isTurn) { if (numOfAvailibleActions > 0) { Grid_Character_Movement Grid_Character_Movement = new Grid_Character_Movement(); if (currentAct != null) { act = currentAct; } if (act == null) { print("this creature needs an action selected first"); } else { print("processing the action " + act.name); Grid_Character_Movement.resetAreaOfMovement(); Grid_Character_Movement.findAreaOfMovement(currentX: creaturePos[0], currentY: creaturePos[1], currentZ: creaturePos[2], numOfSteps: act.range); GameObject[] creatures = GameObject.FindGameObjectsWithTag("creature"); for (int i = 0; i < targetPos.GetLength(0); i++) { int x = targetPos[i, 0]; int y = targetPos[i, 1]; int z = targetPos[i, 2]; foreach (GameObject creature in creatures) { int creatureX = creature.GetComponent <Creature_Stats>().currentX; int creatureY = creature.GetComponent <Creature_Stats>().currentY; int creatureZ = creature.GetComponent <Creature_Stats>().currentZ; if (creatureX == x && creatureY == y && creatureZ == z && !Grid_Character_Movement.gridUnitChecker(Grid_Character_Movement.findGridUnitByCordinate(x, y, z))) { print("a target has been found"); foundTarget = true; creature.GetComponent <Grid_Character_Turn_Manager>().incomingActionProcessing(act); } } } //run polish here-------------- if (act.animationName != null) { if (act.animationAccessType == "trigger") { Grid_Character_Model_Movement.preformAnimationTrigger(act.animationAccessID); } if (act.animationAccessType == "bool") { Grid_Character_Model_Movement.preformAnimationBool(act.animationAccessID); } } //---------------------------- numOfAvailibleActions--; Grid_Character_Movement.resetAreaOfMovement(); } } else { print("this creature has no more actions avalible"); } } else { print("it is not this creatures turn"); } }