public static void IvTeamSupport() { // Iv uses their first ability if (IvCombatScript.ivCondition1[0] && IvCombatScript.ivCondition1[1]) { print("Iv blocks the next attack"); // Make Iv block in game if (firstAttack != 0) { hasRunSimulation = false; if (secondAttack == 0) { if (firstAttack != 7) { secondAttack = 7; } else { print("Can't choose the same move twice"); } } } else { firstAttack = 7; } IvCombatScript.ResetIvVariables(); } // Iv uses their second ability if (IvCombatScript.ivCondition2[0] && IvCombatScript.ivCondition2[1] && IvCombatScript.ivCondition2[2] && IvCombatScript.ivCondition2[3]) { print("Iv heals the weakest party"); // Make Iv heal in game if (firstAttack != 0) { hasRunSimulation = false; if (secondAttack == 0) { if (firstAttack != 8) { secondAttack = 8; } else { print("Can't choose the same move twice"); } } } else { firstAttack = 8; } IvCombatScript.ResetIvVariables(); } // Iv uses their third ability if (IvCombatScript.ivCondition3[0] && IvCombatScript.ivCondition3[1]) { print("Iv empowers both teams"); // Make Iv empower in game if (firstAttack != 0) { hasRunSimulation = false; if (secondAttack == 0) { if (firstAttack != 9) { target2Location = IvCombatScript.targetLocation; secondAttack = 9; } else { print("Can't choose the same move twice"); } } } else { target1Location = IvCombatScript.targetLocation; firstAttack = 9; } IvCombatScript.ResetIvVariables(); } // Iv moves if (IvCombatScript.ivCondition4[0]) { // If Iv moves to the left if (IvCombatScript.ivCondition4[1]) { print("Iv moves to the left"); // Make Iv move in game if (firstAttack != 0) { hasRunSimulation = false; if (secondAttack == 0) { secondAttack = 14; } } else { firstAttack = 14; } IvCombatScript.ResetIvVariables(); } // If Iv moves to the right if (IvCombatScript.ivCondition4[2]) { print("Iv moves to the right"); // Make Iv move in game if (firstAttack != 0) { hasRunSimulation = false; if (secondAttack == 0) { secondAttack = 15; } } else { firstAttack = 15; } IvCombatScript.ResetIvVariables(); } } }
// Update is called once per frame void Update() { CharactersAlive(); EndOfCombat(); if (hasWon) { win = false; } if (hasLost) { lose = false; } if (win) { hasWon = true; } if (lose) { hasLost = true; } if (win) { // TODO: Play won-battle animation GameManagerScript.NextScene(false); print("You won!...that battle"); win = false; } else { if (lose) { // TODO: Play lost-battle animation GameManagerScript.NextScene(false); print("You Lose"); lose = false; } } // If the Netrixi marker is visible if (MarkerManagerScript.netrixiMarker) { if (isNetrixi) { if (netrixiAlive) { netrixiAttacks = true; folkvarAttacks = false; ivAttacks = false; isNetrixi = false; print("Netrixi will attack with a spell"); } } } else { isNetrixi = true; } // If the Folkvar marker is visible if (MarkerManagerScript.folkvarMarker) { if (isFolkvar) { if (folkvarAlive) { folkvarAttacks = true; netrixiAttacks = false; ivAttacks = false; isFolkvar = false; print("Folkvar will attack with his mighty weapons"); } } } else { isFolkvar = true; } // If the Iv marker is visible if (MarkerManagerScript.ivMarker) { if (isIv) { if (ivAlive) { ivAttacks = true; netrixiAttacks = false; folkvarAttacks = false; isIv = false; print("Iv will block with her force powers"); } } } else { isIv = true; } // Reset player attacks and move onto next round if player locks in their choices if (secondAttack != 0) { if (MarkerManagerScript.goMarker) { if (Input.GetKeyDown(KeyCode.V)) { if (!NetrixiCombatScript.netrixiCondition4[0] || !FolkvarCombatScript.folkvarCondition4[0] || !IvCombatScript.ivCondition4[0]) { if (!hasRunSimulation) { // Run combat simulation var go = new GameObject("runner"); var runner = go.AddComponent <CombatSimulationScript>(); runner.StartCoroutine(runner.RunSimulation(firstAttack, secondAttack, EnemyManagerScript.firstAttack, EnemyManagerScript.secondAttack, go)); hasRunSimulation = true; } } } } } // Determine whether the player has chosen a combat move if (netrixiAttacks) { if (CombatManagerScript.netrixiAlive) { NetrixiCombatScript.NetrixiAttack(); } } if (folkvarAttacks) { if (CombatManagerScript.folkvarAlive) { FolkvarCombatScript.FolkvarAttack(); } } if (ivAttacks) { if (CombatManagerScript.ivAlive) { IvCombatScript.IvAction(); } } // Undo a chosen move or attack if (MarkerManagerScript.undoMarker) { if (Input.GetKeyDown(KeyCode.U)) { // Determine what the player's first attack is if (firstAttack != 0) { // Determine what the player's second attack is if (secondAttack == 0) { // Reset attack CharacterManagerScript.UndoMove(); firstAttack = 0; } else { // Reset attack CharacterManagerScript.UndoMove(); secondAttack = 0; } } } } }
// Start is called before the first frame update void Start() { MarkerManagerScript.S.Reset(); CharacterManagerScript.StartCombat(); firstAttack = 0; secondAttack = 0; netrixiAttacks = false; folkvarAttacks = false; ivAttacks = false; NetrixiCombatScript.ResetNetrixiVariables(); FolkvarCombatScript.ResetFolkvarVariables(); IvCombatScript.ResetIvVariables(); isNetrixi = true; isFolkvar = true; isIv = true; roundNumber = 1; // Determine which characters are in the scene netrixiAlive = true; if (GameManagerScript.folkvarInParty) { folkvarAlive = true; } else { folkvarAlive = false; } if (GameManagerScript.ivInParty) { ivAlive = true; } else { ivAlive = false; } // Determine which enemies are in the scene enemy1Alive = true; if (EnemyManagerScript.enemy2 == "null") { enemy2Alive = false; canEnemy2Attack = false; } else { enemy2Alive = true; } if (EnemyManagerScript.enemy3 == "null") { enemy3Alive = false; canEnemy3Attack = false; } else { enemy3Alive = true; } playerAttacking1 = false; playerAttacking2 = false; enemyAttacking1 = false; enemyAttacking2 = false; // Reset any transformed enemies if (!canEnemy1Attack) { NetrixiAttackScript.enemy1Transformed = false; } if (!canEnemy2Attack) { NetrixiAttackScript.enemy2Transformed = false; } if (!canEnemy3Attack) { NetrixiAttackScript.enemy3Transformed = false; } canEnemy1Attack = true; canEnemy2Attack = true; canEnemy3Attack = true; // If only Netrixi is present in the scene //if (netrixiAlive && !folkvarAlive && !ivAlive) netrixiAttacks = true; win = false; lose = false; hasWon = false; hasLost = false; enemy1StartingHP = enemy1HP; enemy2StartingHP = enemy2HP; enemy3StartingHP = enemy3HP; }
public IEnumerator RunSimulation(int playerFirstAttack, int playerSecondAttack, string enemyFirstAttack, string enemySecondAttack, GameObject runner) { CombatManagerScript.netrixiAttacks = false; CombatManagerScript.folkvarAttacks = false; CombatManagerScript.ivAttacks = false; // FIRST ATTACK yield return(new WaitForSecondsRealtime(moveDelay)); // Check to see if any Main Characters move for their first attack CheckForPlayerMovement(playerFirstAttack, 1); // If any Main Characters did move for their first attack if (didPlayerMove1) { yield return(new WaitForSecondsRealtime(moveDelay)); } // Check to see if any Enemy Characters move for their first attack CheckForEnemyMovement(enemyFirstAttack, 1); // If any Enemy Characters did move for their first attack if (didEnemyMove1) { yield return(new WaitForSecondsRealtime(moveDelay)); } // Check to see what the player's first attack is if (!didPlayerMove1) { AttackScript.PlayerAttack(playerFirstAttack, 1); CombatManagerScript.playerAttacking1 = true; AttackScript.enemyAttack = !AttackScript.enemyAttack; // Wait for attack animation to play yield return(new WaitForSecondsRealtime(attack1Delay)); } // Check to see what the enemy's first attack is if (!didEnemyMove1) { AttackScript.EnemyAttack(enemyFirstAttack, 1, enemyAttacker1); CombatManagerScript.enemyAttacking1 = true; AttackScript.playerAttack = !AttackScript.playerAttack; // Wait for attack animation to play yield return(new WaitForSecondsRealtime(attack1Delay)); } // SECOND ATTACK // Check to see if any Main Characters move for their second attack CheckForPlayerMovement(playerSecondAttack, 2); // If any Main Characters did move for their second attack if (didPlayerMove2) { yield return(new WaitForSecondsRealtime(moveDelay)); } // Check to see if any Enemy Characters move for their second attack CheckForEnemyMovement(enemySecondAttack, 2); // If any Enemy Characters did move for their second attack if (didEnemyMove2) { yield return(new WaitForSecondsRealtime(moveDelay)); } // Check to see what the player's second attack is if (!didPlayerMove2) { AttackScript.PlayerAttack(playerSecondAttack, 2); CombatManagerScript.playerAttacking2 = true; AttackScript.enemyAttack = !AttackScript.enemyAttack; // Wait for attack animation to play yield return(new WaitForSecondsRealtime(attack2Delay)); } // Check to see what the enemy's second attack is if (!didEnemyMove2) { AttackScript.EnemyAttack(enemySecondAttack, 2, enemyAttacker2); CombatManagerScript.enemyAttacking2 = true; AttackScript.playerAttack = !AttackScript.playerAttack; // Wait for attack animation to play yield return(new WaitForSecondsRealtime(attack2Delay)); } // Reset variables once simulation is finished CombatManagerScript.firstAttack = 0; CombatManagerScript.secondAttack = 0; NetrixiCombatScript.ResetNetrixiVariables(); FolkvarCombatScript.ResetFolkvarVariables(); IvCombatScript.ResetIvVariables(); CombatManagerScript.roundNumber += 1; CombatManagerScript.playerAttacking1 = false; CombatManagerScript.playerAttacking2 = false; CombatManagerScript.enemyAttacking1 = false; CombatManagerScript.enemyAttacking2 = false; CombatManagerScript.target1Location = 0; CombatManagerScript.target2Location = 0; CharacterManagerScript.ResetVariables(); EnemyManagerScript.ClearMoves(); didPlayerMove1 = false; didPlayerMove2 = false; didEnemyMove1 = false; didEnemyMove2 = false; // If only one character is alive //if (CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.netrixiAttacks = true; //if (!CombatManagerScript.netrixiAlive && CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.folkvarAttacks = true; //if (!CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && CombatManagerScript.ivAlive) CombatManagerScript.ivAttacks = true; Destroy(runner); }