Пример #1
0
    // -----------
    void UpdateGuiGadgetBar <T>(GuiGadget <T> guiGadet, float timer, float maxTimer, int count, int origCount, bool showTimer)
    {
        float   scale = 1;
        Vector3 pos   = guiGadet.m_BarBck.transform.localPosition;
        float   width = guiGadet.m_BarBck.GetWidth();

        bool showDiv2     = false;
        bool showDiv3     = false;
        bool showProgress = false;

        if (guiGadet.m_Parent.IsVisible())
        {
            showProgress = origCount > 0;
            if (showTimer)
            {
                scale        = timer / maxTimer;
                showProgress = true;
            }
            else if (origCount == 3)
            {
                showDiv3 = true;
                scale    = count / 3f;
            }
            else if (origCount == 2)
            {
                showDiv2 = true;
                scale    = count / 2f;
            }
            if (!Mathf.Approximately(guiGadet.m_PrevScale, scale))
            {
                pos.x -= width * (1 - scale) * 0.5f;
                guiGadet.m_Progress.transform.localScale    = new Vector3(scale, 1, 1);
                guiGadet.m_Progress.transform.localPosition = pos;
                guiGadet.m_Progress.SetModify();
                guiGadet.m_PrevScale = scale;
            }
        }

        if (guiGadet.m_Div2.IsVisible() != showDiv2)
        {
            guiGadet.m_Div2.Show(showDiv2, true);
        }
        if (guiGadet.m_Div3.IsVisible() != showDiv3)
        {
            guiGadet.m_Div3.Show(showDiv3, true);
        }
        if (guiGadet.m_Progress.IsVisible() != showProgress)
        {
            guiGadet.m_Progress.Show(showProgress, true);
        }
        if (guiGadet.m_BarBck.IsVisible() != showProgress)
        {
            guiGadet.m_BarBck.Show(showProgress, true);
        }
    }
Пример #2
0
    // -----------
    //create gadgets buttons
    public void CreateGadgetInventory(PlayerPersistantInfo ppi)
    {
        ResetGadgetsList();

        // ----------
        foreach (PPIItemData d in ppi.EquipList.Items)
        {
            if (d.ID == E_ItemID.None)
            {
                continue;
            }

            Gadgets[d.EquipSlotIdx] = d.ID;
        }

        for (int i = 0; i < m_GuiGadgets.Length; i++)
        {
            m_GuiGadgets[i] = new GuiGadget <ItemSettings>();
            GUIBase_Widget parent = PrepareWidget(m_LayoutMain, "Gadget_" + (i + 1));
            m_GuiGadgets[i].m_Parent     = parent;
            m_GuiGadgets[i].m_Button     = GuiBaseUtils.GetButton(m_LayoutMain, s_GadgetsBtnNames[i]);
            m_GuiGadgets[i].m_GadgetIcon = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon").Widget;
            m_GuiGadgets[i].m_BarBck     = GuiBaseUtils.GetChildSprite(parent, "Meter_Back").Widget;
            m_GuiGadgets[i].m_Progress   = GuiBaseUtils.GetChildSprite(parent, "Meter_BAR").Widget;
            m_GuiGadgets[i].m_Div2       = GuiBaseUtils.GetChildSprite(parent, "Meter_Div2").Widget;
            m_GuiGadgets[i].m_Div3       = GuiBaseUtils.GetChildSprite(parent, "Meter_Div3").Widget;
            m_GuiGadgets[i].m_PrevScale  = -1;

            if (i >= Gadgets.Count || Gadgets[i] == E_ItemID.None)
            {
                m_GuiGadgets[i].m_Parent.Show(false, true);
                continue;
            }

            m_GuiGadgets[i].m_Settings = ItemSettingsManager.Instance.Get(Gadgets[i]);
            GuiBaseUtils.RegisterButtonDelegate(m_LayoutMain, s_GadgetsBtnNames[i], s_GadgetsBtnDelegates[i], null);
            GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(parent, "GadgetIcon");
            s.Widget.CopyMaterialSettings(m_GuiGadgets[i].m_Settings.HudWidget);
            m_GuiGadgets[i].m_Parent.Show(true, true);
            m_GuiGadgets[i].SetAllTransparent(false);

            Item gadget = LocalPlayer.Owner.GadgetsComponent.GetGadget(Gadgets[i]);
            UpdateGuiGadgetBar(m_GuiGadgets[i], gadget.Timer, m_GuiGadgets[i].m_Settings.Timer, gadget.Count, gadget.OrigCount, false);
        }

        // ----------
        m_Perk              = new GuiGadget <PerkSettings>();
        m_Perk.m_Parent     = PrepareWidget(m_LayoutMain, "Perk");
        m_Perk.m_Button     = GuiBaseUtils.GetButton(m_LayoutMain, "GButton");
        m_Perk.m_GadgetIcon = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon").Widget;
        m_Perk.m_BarBck     = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Back").Widget;
        m_Perk.m_Progress   = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_BAR").Widget;
        m_Perk.m_Div2       = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div2").Widget;
        m_Perk.m_Div3       = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "Meter_Div3").Widget;
        m_Perk.m_PrevScale  = -1;

        PerkInfo perk = LocalPlayer.Owner.GadgetsComponent.Perk;

        m_Perk.m_Settings = PerkSettingsManager.Instance.Get(ppi.EquipList.Perk);
        if (!perk.IsEmpty())
        {
            GUIBase_Sprite s = GuiBaseUtils.GetChildSprite(m_Perk.m_Parent, "GadgetIcon");
            s.Widget.CopyMaterialSettings(m_Perk.m_Settings.HudWidget);
            m_Perk.m_Parent.Show(true, true);
            UpdateGuiGadgetBar(m_Perk, perk.Timer, m_Perk.m_Settings.Timer, 0, 0, perk.IsSprint());
        }
        else
        {
            m_Perk.m_Parent.Show(false, true);
        }
        //m_Perk.SetAllTransparent(false);

        m_SelIndex        = SelectFirst();
        m_SelectionWidget = m_LayoutMain.GetWidget("GadgetSelection_Sprite", true);
        ShowSelection(true);

        m_Initialised = true;
        UpdateControlsPosition();

        RegisterFloatingFireInteractions();
    }