// Update is called once per frame void Update() { //Player selects their target if (gameState == 0) { selectTarget(); } //Player selects their attack else if (gameState == 1) { hideUI.SetActive(true); //If a button is clicked if (Input.GetButtonDown("Submit")) { hideUI.SetActive(false); gameState = 3; } } //Activates the minigame else if (gameState == 2) { //If a minigame is being played.... if (gameActive) { //...Display the timer if (timer > 0) { timerText.text = timer.ToString(); } //If the timer goes below zero, won't display negatives else { timerText.text = "0.0"; } //Minigames are played here, as long as the timer is going if (timer > 0) { //Tenderizer minigam if (whichGame == 1) { mg.Tenderizer(); } //Sause Toss minigame else if (whichGame == 2) { mg.SauceToss(); } //Orgeno Stun minigame else if (whichGame == 3) { mg.OregenoStun(); } //Emergency overflow catch else { Debug.Log("Minigame Selection Error"); } } //When the timer runs out... else { //Damages the enemy enemyList[playerSelect].takeDamage(mg.score); //Disables the minigame gameActive = false; timer = 3; gameState = 3; } } //Enemy Attacks the player else if (gameState == 4) { print("IM ATTACKING"); for (int i = 0; i < enemyList.Length; i++) { enemyList[i].attack(); } gameState = 0; } } }
// Update is called once per frame void Update() { //Player selects their target if (gameState == 0) { for (var i = 0; i < buttons.Length; i++) { buttons[i].interactable = false; } combatText.text = "Select a target!"; mg.score = 0; for (int i = 0; i < enemyList.Length; i++) { if (i == playerSelect) { enemyList[i].glow(); } else { enemyList[i].unglow(); } selectTarget(); } } //Player selects their attack else if (gameState == 1) { combatText.text = "Choose your spell!"; //hideUI.SetActive(true); for (var i = 0; i < buttons.Length; i++) { buttons[i].interactable = true; } //Assigns a button to the event system, if it doesn't have one if (es.currentSelectedGameObject != buttons[0].gameObject && !selectingAttack) { es.SetSelectedGameObject(buttons[0].gameObject); selectingAttack = true; } //If a button is clicked if (Input.GetButtonDown("Submit")) { //hideUI.SetActive(false); for (var i = 0; i < buttons.Length; i++) { buttons[i].interactable = false; } //gameState = 3; } } //Activates the minigame else if (gameState == 2) { selectingAttack = false; //If a minigame is being played.... if (gameActive) { scoreText.text = "Score: " + mg.score; //hideUI.SetActive(false); for (var i = 0; i < buttons.Length; i++) { buttons[i].interactable = false; } timer -= Time.deltaTime; //...Display the timer if (timer > 0) { timerText.text = timer.ToString(); } //If the timer goes below zero, won't display negatives else { timerText.text = "0.0"; } //Minigames are played here, as long as the timer is going if (timer > 0) { //Tenderizer minigam if (whichGame == 1) { mg.Tenderizer(); comboAttack[0] = true; combatText.text = "Mash the shoulder buttons!"; } //Sause Toss minigame else if (whichGame == 2) { mg.SauceToss(); comboAttack[1] = true; combatText.text = "Spin the analog stick!"; } //Orgeno Stun minigame else if (whichGame == 3) { mg.OregenoStun(); comboAttack[2] = true; combatText.text = "Press X on time!"; } //Emergency overflow catch else { Debug.Log("Minigame Selection Error"); } } //When the timer runs out... else { comboStateReached = true; for (int i = 0; i < comboAttack.Length; i++) { if (comboAttack[i] == false) { comboStateReached = false; break; } } //If the ulimate attack is successful, executes it here: if (comboStateReached) { combatText.text = "ULTIMATE MOVE! MEATBALLISTIC MISSILE!"; for (int j = 0; j < enemyList.Length; j++) { enemyList[j].takeDamage(30); } } else { //Damages the enemy enemyList[playerSelect].takeDamage(mg.score, whichGame); } //Disables the minigame mg.oreganoMinigame.gameObject.SetActive(false); gameActive = false; timer = 3; gameState = 3; } } } //Enemy Attacks the player else if (gameState == 3) { enemyList[index].attack(); //enemyList[index].callOut(); gameState = 4; index++; //ensures that we'll never go over the enemy list if (index > enemyList.Length - 1) { enemyTurn = false; } else { enemyTurn = true; pTimer = enemyDelay; } print("IM ATTACKING"); /*for (int i = 0; i < enemyList.Length; i++) * { * * enemyList[i].attack(); * * }*/ gameState = 4; } else if (gameState == 4) { pTimer -= Time.deltaTime; if (pTimer <= 0) { pTimer = turnDelay; if (!enemyTurn) { gameState = 0; index = 0; } else { gameState = 3; } } } }