private void Start() { CurrPartySlot = ePartySlot.NONE; /// Priority enemy BattleProfile priorityEnemy = Enemies[0]; // Enemy in first slot influences visuals and audio of whole battle Debug.Assert(priorityEnemy, "BATTLEMANAGER::No enemies set!"); // Set enemy background ReferenceManager.Instance.enemyBG.sprite = priorityEnemy.BattleBackground; // Add enemy audio to main system and secondary systems ReferenceManager.Instance.mainAudio.AudioFiles.AddRange(priorityEnemy.BattleSFX); ReferenceManager.Instance.secondaryAudio.AudioFiles.AddRange(priorityEnemy.BattleSFX); // Start battle music, playing intro first if there is one AudioClip introClip = ReferenceManager.Instance.mainAudio.HasClip("INTRO"); if (introClip) { // Play intro and then play main loop after it ReferenceManager.Instance.mainAudio.SetLooping(false); ReferenceManager.Instance.mainAudio.PlayClip("{\"alias\":\"INTRO\",\"volume\":1}"); ReferenceManager.Instance.secondaryAudio.SetLooping(true); ReferenceManager.Instance.secondaryAudio.PlayClipWithDelay("{\"alias\":\"LOOP\",\"volume\":1}", introClip.length, true); } else if (ReferenceManager.Instance.mainAudio.HasClip("LOOP")) { ReferenceManager.Instance.mainAudio.SetLooping(true); ReferenceManager.Instance.mainAudio.PlayClip("{\"alias\":\"LOOP\",\"volume\":1}"); } /// Enemies for (int i = 0; i < Enemies.Length; ++i) { GameObject eObj = Instantiate(EnemyBlueprint); EnemyEntity eEe = eObj.GetComponent <EnemyEntity>(); // Set to relevant slot eEe.enemySlot = (eEnemySlot)i; // Set type eEe.EntityType = eEntityType.ENEMY; // Assign battle profile eEe.BattleProfile = Enemies[i]; // Keep track of enemy entity EnemyEntities.Add(eEe); eObj.transform.SetParent(ReferenceManager.Instance.enemyPanel.transform); } /// Party members for (int i = 0; i < PartyMembers.Length; ++i) { GameObject pmObj = Instantiate(PartyBlueprint); PartyEntity pmPe = pmObj.GetComponentInChildren <PartyEntity>(); // Assign battle profile pmPe.BattleProfile = PartyMembers[i]; // Set type pmPe.EntityType = eEntityType.PARTY; // Set to relevant slot pmPe.partySlot = (ePartySlot)i; // Keep track of party entity PartyEntities.Add(pmPe); pmObj.transform.SetParent(ReferenceManager.Instance.partyPanel.transform); } }