Beispiel #1
0
    // ------
    public void Init(GUIBase_Widget newParent, bool useUpgrades)
    {
        m_Base = GetComponent <GUIBase_Widget>();

        m_Price      = GuiBaseUtils.GetChildLabel(m_Base, "Price");
        m_ItemName   = GuiBaseUtils.GetChildLabel(m_Base, "Name");
        m_Image      = GuiBaseUtils.GetChildSprite(m_Base, "Image");
        m_Enabled    = GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "Enabled");
        m_Disabled   = GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "Disabled");
        m_Finished   = GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "Finished");
        m_Researched = GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "Researched");

        m_LockedByRank = new LockedByRank(GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "LockedByRank"),
                                          GuiBaseUtils.GetChild <GUIBase_Label>(m_Base, "LockedByRankText"));

        if (useUpgrades)
        {
            m_FullyUpgraded = GuiBaseUtils.GetChild <GUIBase_Sprite>(m_Base, "FullyUpgraded");
            m_UpgradeParent = GuiBaseUtils.GetChild <GUIBase_Widget>(m_Base, "Upgrades");
            for (int i = 0; i < ResearchItem.MAX_UPGRADES; i++)
            {
                m_Upgrades[i] = GuiBaseUtils.GetChild <GUIBase_Widget>(m_UpgradeParent, "Upgrade" + (i + 1));
                m_Stars[i]    = GuiBaseUtils.GetChild <GUIBase_Widget>(m_UpgradeParent, "Star" + (i + 1));
            }
            //m_FullyUpgraded = GuiBaseUtils.GetChild<GUIBase_Widget>(m_UpgradeParent, "FullyUpgraded");
        }
        else
        {
            m_FullyUpgraded = null;
        }
        m_Base.Relink(newParent);
    }
Beispiel #2
0
    void PrepareRows()
    {
        GUIBase_Widget template = Owner.Layout.GetWidget(TEMPLATE_WIDGET);

        while (m_Rows.Count > m_MaxRows)
        {
            int idx = m_Rows.Count - 1;
            Row row = m_Rows[idx];
            m_Rows.RemoveAt(idx);

            row.Destroy();
        }

        while (m_Rows.Count < m_MaxRows)
        {
            GUIBase_Widget root = GameObject.Instantiate(template) as GUIBase_Widget;

            root.Relink(m_RowsContainer);
            root.name = string.Format("Row{0}_Widget", m_Rows.Count.ToString("D2"));

            Row row = new Row();
            row.Initialize(root, OnRowButtonDelegate);
            m_Rows.Add(row);
        }
    }
Beispiel #3
0
    // ------
    public void Relink(GUIBase_Widget newParent, GUIBase_Widget imagesDummy = null)
    {
        Parent.Relink(newParent);
        float xScale = newParent.GetWidth() / Parent.GetWidth();
        float yScale = newParent.GetHeight() / Parent.GetHeight();

        if (imagesDummy != null)
        {
            float xScale2 = imagesDummy.GetWidth() / Images.Widget.GetWidth();
            float yScale2 = imagesDummy.GetHeight() / Images.Widget.GetHeight();
            Images.transform.localScale = new Vector3(1 / xScale * xScale2, 1 / yScale * yScale2, 1);
        }

        Parent.transform.localScale = new Vector3(xScale, yScale, 1);
        if (imagesDummy != null)
        {
            Images.transform.position = imagesDummy.transform.position;
        }
    }
Beispiel #4
0
    //------------------------------------------------------------------------------------------------------------------
    bool AttachMiniMap()
    {
        m_Def = GameObject.FindGameObjectWithTag("MapDefinition");

        if (m_Def == null)
        {
            Debug.LogWarning("Game object 'MapDefinition' not found!");
            return(false);
        }

        // insert mini-map to corresponing screen-layout...

        m_MapParent = m_Def.transform.GetChildComponent <GUIBase_Widget>("Map");

        if (m_MapParent == null)
        {
            Debug.LogWarning("Widget 'Map' not found in 'MapDefinition'!");
            return(false);
        }

        m_MapParent.Relink(Parent.Parent);

        return(true);
    }