//spawns units for the gridworld set up
    void SpawnUnitsGridworld(List <PlayerUnit> puList, int boardXLength, int boardYLength)
    {
        Transform playerHolder = new GameObject("PlayerHolder").transform;
        //PlayerManager.Instance.SetLocalTeamId(NameAll.TEAM_ID_GREEN);
        //Transform markerHolder = new GameObject("MarkerHolder").transform;
        GameObject playerUnitObject;
        int        currentIndex = 0;

        foreach (PlayerUnit playerUnit in puList)
        {
            playerUnit.TurnOrder = currentIndex;
            currentIndex++;
            //initialize the physical representation of the player unit
            string puoString = NameAll.GetPUOString(playerUnit.ClassId);             //Debug.Log("asdf " + puoString);
            playerUnitObject = Instantiate(Resources.Load(puoString)) as GameObject; //Debug.Log("is puo active" + playerUnitObject.GetActive());

            //randomize unit starting spot
            while (true)
            {
                int x = UnityEngine.Random.Range(0, boardXLength);
                int y = UnityEngine.Random.Range(0, boardYLength);
                //check that starting spot is empty
                if (!board.IsCrystalOnTile(x, y))
                {
                    //tile is empty, place unit
                    Tile startTile = board.GetTile(x, y);
                    playerUnit.SetUnitTile(startTile, true);
                    //tells the tiles that someone is on them
                    board.GetTile(playerUnit).UnitId = playerUnit.TurnOrder;
                    Vector3 vecTemp = startTile.transform.position;
                    vecTemp.y = vecTemp.y * 2.0f;
                    playerUnitObject.transform.position = vecTemp;
                    //MapTileManager.Instance.MoveMarker(playerUnit.TurnOrder, startTile);
                    break;
                }
            }


            PlayerManager.Instance.AddPlayerUnit(playerUnit);
            PlayerUnitObject puo = playerUnitObject.GetComponent <PlayerUnitObject>();
            puo.UnitId = playerUnit.TurnOrder;
            PlayerManager.Instance.AddPlayerObject(playerUnitObject);
            playerUnitObject.transform.SetParent(playerHolder);
            PlayerManager.Instance.SetInitialFacingDirection(playerUnit.TurnOrder);
        }
    }
    void SpawnUnits(List <PlayerUnit> green, List <PlayerUnit> red, List <SerializableVector3> spawnList)
    {
        List <PlayerUnit> temp = new List <PlayerUnit>();
        PlayerUnit        pu;
        Transform         playerHolder = new GameObject("PlayerHolder").transform;

        PlayerManager.Instance.SetLocalTeamId(NameAll.TEAM_ID_GREEN);
        Transform  markerHolder = new GameObject("MarkerHolder").transform;
        GameObject playerUnitObject;

        int zBreak            = 0;                     //temp
        int turn              = NameAll.TEAM_ID_GREEN; //green goes first, then snake draft
        int unitsToAdd        = 1;                     //first time only adds one unit, then 2 (snake draft)
        int currentIndex      = 0;
        int greenLearnedIndex = 0;                     //have to change the list in SpellManager based on the new turn order. old number is stored by order in the list

        //set up turn order for PlayerUnits
        while (green.Count > 0 || red.Count > 0)
        {
            if (turn == NameAll.TEAM_ID_GREEN)
            {
                turn = NameAll.TEAM_ID_RED;
                if (green.Count > 0)
                {
                    while (unitsToAdd > 0 && green.Count > 0)
                    {
                        //for some modes need to only let player cast learned abilities. abilities loaded but have to modify the uniqueId with the turnOrder
                        //so change the oldTurnOrder with the newly assigned turnOrder (the old turn order is a place holder set when the spells are added to the spellmanager)
                        if (SpellManager.Instance.spellLearnedType == NameAll.SPELL_LEARNED_TYPE_PLAYER_1)
                        {
                            SpellManager.Instance.AlterSpellLearnedList(currentIndex, green[0].TurnOrder);
                        }

                        unitsToAdd -= 1;
                        pu          = new PlayerUnit(green[0]);
                        green.RemoveAt(0);
                        pu.TurnOrder = currentIndex;          // SetTurn_order(currentIndex);
                        pu.TeamId    = NameAll.TEAM_ID_GREEN; // SetTeam_id(NameAll.TEAM_ID_GREEN);
                        temp.Add(pu);
                        temp[currentIndex] = pu;              //redundant
                        currentIndex      += 1;
                    }
                }
                else
                {
                    continue;
                }
            }
            else
            {
                turn = NameAll.TEAM_ID_GREEN;
                if (red.Count > 0)
                {
                    while (unitsToAdd > 0 && red.Count > 0)
                    {
                        unitsToAdd -= 1;
                        pu          = new PlayerUnit(red[0]);
                        red.RemoveAt(0);
                        pu.TurnOrder = currentIndex;        // SetTurn_order(currentIndex);
                        pu.TeamId    = NameAll.TEAM_ID_RED; // SetTeam_id(NameAll.TEAM_ID_RED);
                        temp.Add(pu);
                        temp[currentIndex] = pu;
                        currentIndex      += 1;
                    }
                }
                else
                {
                    continue;
                }
            }
            unitsToAdd = 2;
            zBreak    += 1;
            if (zBreak > 100)
            {
                break;
            }
            //Debug.Log("in while loop " + green.Count + " " + red.Count);
        }

        //physically place the units on the map
        //spList is x, y, and teamId
        foreach (PlayerUnit playerUnit in temp)
        {
            GameObject marker;
            if (playerUnit.TeamId == NameAll.TEAM_ID_GREEN)
            {
                marker = Instantiate(markerTeam1Prefab) as GameObject;
            }
            else
            {
                marker = Instantiate(markerTeam2Prefab) as GameObject;
            }
            MapTileManager.Instance.AddMarker(marker); //Debug.Log("adding marker to list...");
            marker.transform.SetParent(markerHolder);

            string puoString = NameAll.GetPUOString(playerUnit.ClassId);             //Debug.Log("asdf " + puoString);
            playerUnitObject = Instantiate(Resources.Load(puoString)) as GameObject; //Debug.Log("is puo active" + playerUnitObject.GetActive());

            foreach (Vector3 vec in spawnList.ToList())
            {
                if (playerUnit.TeamId == (int)vec.z)
                {
                    Point p         = new Point((int)vec.x, (int)vec.y);
                    Tile  startTile = board.GetTile(p);
                    playerUnit.SetUnitTile(startTile, true);
                    //tells the tiles that someone is on them
                    board.GetTile(playerUnit).UnitId = playerUnit.TurnOrder;

                    spawnList.Remove(vec);
                    Vector3 vecTemp = startTile.transform.position;
                    vecTemp.y = vecTemp.y * 2.0f;
                    playerUnitObject.transform.position = vecTemp;
                    MapTileManager.Instance.MoveMarker(playerUnit.TurnOrder, startTile);
                    break;
                }
            }

            PlayerManager.Instance.AddPlayerUnit(playerUnit);
            PlayerUnitObject puo = playerUnitObject.GetComponent <PlayerUnitObject>();
            puo.UnitId = playerUnit.TurnOrder;
            puo.SetDriver(SetDrivers(playerUnit.TeamId));
            PlayerManager.Instance.AddPlayerObject(playerUnitObject);
            playerUnitObject.transform.SetParent(playerHolder);
            PlayerManager.Instance.SetInitialFacingDirection(playerUnit.TurnOrder);
            PlayerManager.Instance.AssignTeamIdToPlayerUnit(playerUnit.TurnOrder);
        }
        //sets the teams alliances
        PlayerManager.Instance.AssignAlliances();
        //sets the mime shit
        PlayerManager.Instance.SetMimeOnTeam();
        //adds the lasting statuses
        PlayerManager.Instance.SetLastingStatuses();
        //sets the twosword eligible flag, onmoveeffect flag
        PlayerManager.Instance.InitializePlayerUnits();
        //Debug.Log("" + MapTileMan);
    }