// Use this for initialization
    void Start()
    {
        units                = new List <UnitStats> ();
        friendlyUnits        = new List <UnitStats>();
        enemyUnits           = new List <UnitStats>();
        ui                   = GameObject.Find("BattleControllers").GetComponent <BattleUIController>();
        party                = GameObject.Find("PlayerParty").GetComponent <PartyController>();
        enemyEncounterObject = Instantiate(SceneMgmt.toFight);
        enemyEncounterObject.transform.SetParent(GameObject.Find("BattleHolder").transform);
        enemies = enemyEncounterObject.GetComponent <EnemyPartyController>();
        ui.SetPartyAndEnemies(party, enemies);
        arenaPrefab = Instantiate(SceneMgmt.arena);
        arenaPrefab.transform.SetParent(GameObject.Find("BattleHolder").transform);
        int members = 0;

        for (int i = 0; i < party.playerParty.Length; i++)
        {
            if (party.playerParty[i] != null && members < 4 && party.playerParty[i].GetComponent <UnitStats>().available)
            {
                UnitStats member = party.playerParty[i].GetComponent <UnitStats>();
                if (!member.IsDead())
                {
                    units.Add(member);
                }
                friendlyUnits.Add(member);
                members++;
                ui.CreatePartyButton(i, members);
            }
        }
        for (int i = 0; i < enemies.enemyParty.Length; i++)
        {
            if (enemies.enemyParty[i] != null && i < 4)
            {
                UnitStats enemy = enemies.enemyParty[i].GetComponent <UnitStats>();
                units.Add(enemy);
                enemyUnits.Add(enemy);
                ui.CreateEnemyButton(i);
            }
        }
        StartCoroutine(WaitAndThenSort());
    }