示例#1
0
    // ---------- Toggle Unit Selection Panel ----------
    public void ShowUnitSelectionPanel(IClickableUnit unit)
    {
        unitSelectionPanel.gameObject.SetActive(true);
        UpdateSelectedUnitDataPanel(unit);
        if (unit is PlayerUnit)
        {
            moveUnitButton.gameObject.SetActive(true);
            sellUnitButton.gameObject.SetActive(true);
        }
        else
        {
            moveUnitButton.gameObject.SetActive(false);
            sellUnitButton.gameObject.SetActive(false);
        }

        closeUnitSelectionPanelButton.gameObject.SetActive(true);
    }
示例#2
0
    // ---------- Unit selection panel data ----------

    /*
     * Calls the unit object's GetDisplayUnitData() function, which returns a list of strings.
     * These strings get mapped to the textSlot game objects.
     */
    public void UpdateSelectedUnitDataPanel(IClickableUnit unit)
    {
        List <string> unitData = unit.GetDisplayUnitData();

        textSlot1.text = "";
        textSlot2.text = "";
        textSlot3.text = "";
        textSlot4.text = "";
        textSlot5.text = "";
        textSlot6.text = "";
        textSlot7.text = "";

        if (unitData.Count > 0)
        {
            textSlot1.text = unitData[0];
        }
        if (unitData.Count > 1)
        {
            textSlot2.text = unitData[1];
        }
        if (unitData.Count > 2)
        {
            textSlot3.text = unitData[2];
        }
        if (unitData.Count > 3)
        {
            textSlot4.text = unitData[3];
        }
        if (unitData.Count > 4)
        {
            textSlot5.text = unitData[4];
        }
        if (unitData.Count > 5)
        {
            textSlot6.text = unitData[5];
        }
        if (unitData.Count > 6)
        {
            textSlot7.text = unitData[6];
        }
    }