October 2016
Beginner
506 pages
10h 1m
English
Now that the player has committed themselves into the fray, we can play through their selected action.
The attack phase will simply run for 1 second and then it will be the enemies' turn. To accomplish this, we use a simple coroutine to perform the attack itself. So, let's add the following function to the BattleManager script:
IEnumerator AttackTarget(){
attacking=true;
selectedTarget.EnemyProfile.health-=GetComponent<Attack>().hitAmount;
yield return new WaitForSeconds(1);
attacking=false;
GetComponent<Attack>().hitAmount=0;
battleStateManager.SetBool("PlayerReady", false);
}
The following is what the preceding code is doing:
Read now
Unlock full access