/*This function controls the player attack*/ public void playerAttack() { if (playerTurn) //see if it is the player's turn { playerFire.shootProjectile(); //fire the designated player projectile playerTurn = false; //player turn over enemyTurn = true; //now enemy turn } }
/* This function timest the enemy attack so that there is a pause before * and after to allow the animations to complete before it becomes the player's turn*/ IEnumerator TimedAttack() { attackbutton.interactable = false; //disable attack button for player yield return(new WaitForSecondsRealtime(3)); //wait 3 seconds if (!enemy.gameObject.GetComponent <EntityHealth>().dead) //only complete the attack if the enemy is not dead { animator.SetTrigger("robotTrigger"); //call the enemy attack animation yield return(new WaitForSecondsRealtime(1)); //wait 1 second enemyFire.shootProjectile(); //call the projectile } //enemy attack yield return(new WaitForSecondsRealtime(3)); //wait 3 seconds attackbutton.interactable = true; //enable attack button for player }