IEnumerator PlayerAttackTotalHP() { bool isTotalDead = enemyCarUnit.TakeDamageTotalHP(playerCarUnit.mainWeaponDamage); enemyHUD.SetTotalHP(enemyCarUnit); Instantiate(explosion, enemyInitialPosition); DisablePlayerActions(); DisablePlayerAttackActions(); yield return(new WaitForSeconds(1f)); if (isTotalDead) { state = BattleState.WON; winScreen.SetActive(true); //EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }
IEnumerator SetupBattle() { GameObject playerGO = Instantiate(playerPrefab, playerInitialPosition); playerCarUnit = playerGO.GetComponent <CarUnit>(); GameObject enemyGO = Instantiate(enemyLvl1Prefab, enemyInitialPosition); enemyCarUnit = enemyGO.GetComponent <CarUnit>(); playerHUD.SetTotalHP(playerCarUnit); DisablePlayerAttackActions(); DisablePlayerRepairActions(); yield return(new WaitForSeconds(1f)); state = BattleState.PLAYERTURN; }