public void CancelAction() { tCursors.ClearTargets(); CM.combatQueue [CM.currentCharacter].action = "None"; CM.combatQueue [CM.currentCharacter].actionType = "None"; CM.currentPhase = CombatManager.PHASE.ACTION; }
// This function is used to check if there are still conflicts in the queue and set current phase to the correct phase void Conflict() { tCursor.ClearTargets(); // Check if there is a conflict in the queue conflictInQueue = -1; for (int i = 4; i > -1; i--) { if (combatQueue[i].action == "None" && combatQueue [i].tag == "Player" && combatQueue [i + 1].tag == "Player" && combatQueue [i].Stamina == combatQueue [i + 1].Stamina) { conflictInQueue = i; } } // Disable all enemy buttons foreach (Button B in enemySelect) { B.enabled = false; } // Get the position of the first player without an action int firstAction = -1; for (int i = 5; i > -1; i--) { if (combatQueue [i].action == "None" && !combatQueue[i].dead) { firstAction = i; } } // If the character is stunned have them do nothing if (firstAction != -1 && combatQueue[firstAction].findStatus(Character.STATUS.STUN) != -1) { combatQueue[firstAction].action = "Wait"; combatQueue [firstAction].actionType = "None"; combatQueue [firstAction - 1].CallTell(); return; } // If there is a conflict in the queue but someone else has priority if (conflictInQueue != -1 && firstAction >= conflictInQueue) { currentPhase = PHASE.SELECT; } else { // If there is a character without an action if (firstAction != -1) { if (!combatQueue[firstAction].dead) { if (combatQueue [firstAction].tag == "Player") { //currentPhase = PHASE.ACTION; currentPhase = PHASE.SELECT; } else if (combatQueue[firstAction].tag == "Enemy") { // This allows the player to control enemy actions for now currentPhase = PHASE.ACTION; // This bool is used for debugging in the inspector if (enemyControl) { //AI.FullRandomAI (combatQueue [firstAction]); EnemyTurn(combatQueue[firstAction]); } combatQueue [firstAction].CallTell(); } } else { // All downed character are given the rest action for (int i = firstAction; i < 6; i++) { combatQueue [i].action = "Rest"; combatQueue [i].actionType = "Utility"; for (int j = 0; j < combatQueue[i].Target.Length; j++) { combatQueue [i].Target[j] = combatQueue [i]; } } } } } // If there are no characters without actions if (firstAction == -1) { // This is a brute force way to make sure the last character's tell is shown, even if they aren't last in the queue foreach (Character C in combatQueue) { C.CallTell(); } currentPhase = PHASE.EXECUTE; Execute(); } if (firstAction != -1) { currentCharacter = firstAction; if (firstAction > 0) { combatQueue [firstAction - 1].CallTell(); } } }
// This function is used to check if there are still conflicts in the queue and set current phase to the correct phase void Conflict() { tCursor.ClearTargets(); // Check if there is a conflict in the queue conflictInQueue = -1; for (int i = 4; i > -1; i--) { if (combatQueue[i].action == "None" && combatQueue [i].tag == "Player" && combatQueue [i + 1].tag == "Player" && combatQueue [i].Stamina == combatQueue [i + 1].Stamina) { conflictInQueue = i; } } // Disable all enemy buttons foreach (Button B in enemySelect) { B.enabled = false; } // Get the position of the first player without an action int firstAction = -1; for (int i = 5; i > -1; i--) { if (combatQueue [i].action == "None" && !combatQueue[i].dead) { firstAction = i; } } // This block will run when findstatus can work properly if (firstAction != -1 && combatQueue[firstAction].findStatus("stun") != -1) { combatQueue[firstAction].action = "Wait"; combatQueue [firstAction].actionType = "None"; combatQueue [firstAction - 1].CallTell(); return; } // If there is a conflict in the queue but someone else has priority if (conflictInQueue != -1 && firstAction >= conflictInQueue) { currentPhase = PHASE.SELECT; } else { // If there is a character without an action if (firstAction != -1) { if (!combatQueue[firstAction].dead) { if (combatQueue [firstAction].tag == "Player") { currentPhase = PHASE.ACTION; } else { // This allows the player to control enemy actions for now currentPhase = PHASE.ACTION; //EnemyTurn (firstAction); } } else { // All downed character are given the rest action for (int i = firstAction; i < 6; i++) { combatQueue [i].action = "Rest"; combatQueue [i].actionType = "Utility"; for (int j = 0; j < combatQueue[i].Target.Length; j++) { combatQueue [i].Target[j] = combatQueue [i]; } } } } } // If there are no characters without actions if (firstAction == -1) { // This block does a stable sort to move the players who are catching to the front of the queue int j = 0; for (int i = 0; i < 6; i++) { int k = 0; if (combatQueue[i].action == "Catch") { Character temp = combatQueue [i]; while (i - k > j) { combatQueue [i - k] = combatQueue [i - k - 1]; k++; } combatQueue [j] = temp; j++; } } // This is a brute force way to make sure the last character's tell is shown, even if they aren't last in the queue foreach (Character C in combatQueue) { C.CallTell(); } currentPhase = PHASE.EXECUTE; Execute(); } if (firstAction != -1) { currentCharacter = firstAction; if (firstAction > 0) { combatQueue [firstAction - 1].CallTell(); } } }