private IEnumerator TimeForBattle() //Battle Logic { if (actionStarted) { yield break; } actionStarted = true; //Sets actionStarted boolean to true to signify an action has begun Vector2 targetPosition = new Vector2(targetToAttack.transform.position.x + 1.5f, targetToAttack.transform.position.y); //Animates player character towards the enemy while (MoveTowardEnemy(targetPosition)) //Animates the Player Character towards the Enemy { yield return(null); } //Wait A Bit yield return(new WaitForSeconds(0.5f)); //Wait for the animation to complete //Do Damage string typeOfAttack = bsm.GetHeroChoice().typeOfAttack; PerformDamage(typeOfAttack); //Animate back to startPosition Vector2 firstPosition = startPosition; //Sets this local variable for the original position of the character to the coordinates of the original position while (MoveTowardStart(firstPosition)) //Resets the Player Character to it's original position { yield return(null); } bsm.performList.RemoveAt(0); //Removes the current performer from the Performers List if (bsm.battleState != BattleStateMachine.PerformAction.WIN && bsm.battleState != BattleStateMachine.PerformAction.LOSE) { bsm.battleState = BattleStateMachine.PerformAction.WAIT; curTime = 0f; //resets time gauge currentState = TurnState.PROCESSING; //Sets the Current State of the Player Character back to PROCESSING } else { currentState = TurnState.WAITING; } actionStarted = false; //resets the actionStarted boolean back to false because no action is being performed }