Ejemplo n.º 1
0
    //
    //Useful methods
    //

    //Adds Units to players
    public void SpawnPlayerUnits()
    {
        for (int i = 0; i < NumberOfPlayers; i++)
        {
            //get list
            ChildrenList list = _players[i].GetComponent <ChildrenList>();

            //add units at spawnpoints for respective players\
            //players are indexed like 1,2 by GetPlayerSpawns
            Vector3[] spawns = levelSel.GetPlayerSpawns(i + 1);
            int       j      = 0;
            foreach (UnitController unit in Units[i])
            {
                list.CreatePrefabAsChild(unit, spawns[j++], Quaternion.identity);
            }

            //Sets player's current unit to whoever was added first
            _players[i].GetComponent <PlayerController>().InitializeUnitController();
        }
    }