// Use this for initialization void Start() { won = false; xpNotCounted = true; enemiesGameObjects.Clear(); enemiesScripts.Clear(); playerTurn = true; enemiesAmount = Enemies.Length; GameObject player = Instantiate(PlayerPrefab, PlayerTransform); playerObject = player; playerScript = player.GetComponent <PlayerBattleScript>(); switch (enemiesAmount) { case 1: case 3: enemyTransforms = EnemiesTransforms3; break; case 2: enemyTransforms = EnemiesTransforms2; break; default: throw new Exception("EnemiesAmount invalid"); } for (int i = 0; i < enemiesAmount; i++) { GameObject enemy; if (Enemies[i].MageType == MageType.Prince) { enemy = Instantiate(PrincePrefab, enemyTransforms[i]); } else { enemy = Instantiate(MagePrefab, enemyTransforms[i]); } EnemyBattleScript enemyScript = enemy.GetComponent <EnemyBattleScript>(); enemiesGameObjects.Add(enemy); enemiesScripts.Add(enemyScript); } for (int i = 0; i < enemiesAmount; i++) { GameObject enemy = enemiesGameObjects[i]; EnemyBattleScript enemyScript = enemy.GetComponent <EnemyBattleScript>(); Canvas canvas = enemyTransforms[i].gameObject.GetComponentInChildren <Canvas>(); SlidingBar slidingBar = enemyTransforms[i].gameObject.GetComponentInChildren <SlidingBar>(); enemyScript.Init(Enemies[i].Level, Enemies[i].MageType, enemiesGameObjects.ToArray(), slidingBar, canvas); } alive = new bool[enemiesAmount]; for (int i = 0; i < alive.Length; i++) { alive[i] = true; } playerScript.SetEnemiesGameObjects(enemiesGameObjects.ToArray()); battleUIScript = battleUIObject.GetComponent <BattleUIController> (); battleUIScript.SetBattleScript(playerScript); battleUIScript.SetEnemiesGameObjects(enemiesGameObjects.ToArray()); healthBar.SetMaxValue(playerEntity.Stats.MaxHealth); }