Exemplo n.º 1
0
    void SwitchToTeam(int team)
    {
        InitializeIfNeeded();

        this.currentDisplayedTeam = team;

        // Set buttons with units in selected team
        int currentButtonIndex = 0;

        foreach (UnitDataObject unitDataObject in tcScript.unitDataObjectsList)
        {
            if (unitDataObject.assignedTeam == team && currentButtonIndex < selectedUnitButtonList.Count)
            {
                GameObject         buttonGO = selectedUnitButtonList [currentButtonIndex];
                SelectedUnitButton button   = buttonGO.GetComponent <SelectedUnitButton> ();
                button.SetUnitDataObject(unitDataObject);
                button.HideCloseButton();
                currentButtonIndex++;
            }
        }

        // Clear buttons without a team
        for (int i = currentButtonIndex; i < selectedUnitButtonList.Count; i++)
        {
            GameObject         buttonGO = selectedUnitButtonList [currentButtonIndex];
            SelectedUnitButton button   = buttonGO.GetComponent <SelectedUnitButton> ();
            button.ClearButton();
            currentButtonIndex++;
        }
    }
Exemplo n.º 2
0
    void SwitchToTeam(int team)
    {
        InitializeIfNeeded();

        tcScript.selectedTeam     = team;
        this.currentDisplayedTeam = team;

        // Show all team tabs
        team1Tab.SetActive(true);
        team2Tab.SetActive(true);
        team3Tab.SetActive(true);

        // Hide the appropriate team tab
        switch (team)
        {
        case 0:
            // Show nothing
            break;

        case 1:
            team1Tab.SetActive(false);
            break;

        case 2:
            team2Tab.SetActive(false);
            break;

        case 3:
            team3Tab.SetActive(false);
            break;
        }

        // Set buttons with units in selected team
        int currentButtonIndex = 0;

        foreach (UnitDataObject unitDataObject in tcScript.unitDataObjectsList)
        {
            if (unitDataObject.assignedTeam == team && currentButtonIndex < selectedUnitButtonList.Count)
            {
                GameObject         buttonGO = selectedUnitButtonList [currentButtonIndex];
                SelectedUnitButton button   = buttonGO.GetComponent <SelectedUnitButton> ();
                button.SetUnitDataObject(unitDataObject);
                //button.HideCloseButton ();
                currentButtonIndex++;
            }
        }

        // Clear buttons without a team
        for (int i = currentButtonIndex; i < selectedUnitButtonList.Count; i++)
        {
            GameObject         buttonGO = selectedUnitButtonList [i];
            SelectedUnitButton button   = buttonGO.GetComponent <SelectedUnitButton> ();
            button.ClearButton();
        }
    }