Example #1
0
    /// <summary>
    /// 部件加载时
    /// </summary>
    protected override void OnViewPartLoaded()
    {
        m_Money1 = FindComponent <UIIconAndLabel>("Content/Coin1");
        m_Money2 = FindComponent <UIIconAndLabel>("Content/Coin2");

        UpdateMoneys();
    }
Example #2
0
    /// <summary>
    /// 部件加载时
    /// </summary>
    protected override void OnViewPartLoaded()
    {
        UIIconAndLabel iconAndLabel = FindComponent <UIIconAndLabel>("Content");

        if (iconAndLabel != null)
        {
            if (iconAndLabel.Icon)
            {
                uint iconID = (uint)State.Icon;
                if (iconID != 0)
                {
                    UIUtil.SetIconImage(iconAndLabel.Icon, (uint)State.Icon);
                }
                else
                {
                    iconAndLabel.Icon.sprite = null;
                }
            }

            if (iconAndLabel.Label)
            {
                iconAndLabel.Label.text = State.MainTitle;
            }

            if (iconAndLabel.Info)
            {
                iconAndLabel.Info.text = State.SecondaryTitle;
            }
        }
    }
Example #3
0
    /// <summary>
    /// 初始化消息动画
    /// </summary>
    private void InitializeMessageAnimation()
    {
        switch (m_CurrentMessage.type)
        {
        case NotificationName.MSG_MISSION_ACCEPT:
        case NotificationName.MSG_MISSION_FAIL:
            break;

        case NotificationName.MSG_MISSION_COMMIT:
        {
            UIIconAndLabel label = m_CurrentAnimationEvent.GetComponent <UIIconAndLabel>();
            if (label && label.Label)
            {
                label.Label.text = TableUtil.GetLanguageString("mission_title_1005");
            }
        }
        break;

        case NotificationName.MSG_MISSION_STATE_CHANGE:
        {
            UIIconAndLabel label = m_CurrentAnimationEvent.GetComponent <UIIconAndLabel>();
            if (label && label.Label)
            {
                label.Label.text = TableUtil.GetLanguageString("mission_title_1015");
            }
        }
        break;

        case NotificationName.MSG_PLAYER_LEVEL_UP:
        {
            UIIconAndLabel label = m_CurrentAnimationEvent.GetComponent <UIIconAndLabel>();
            if (label && label.Label)
            {
                label.Label.text = m_CurrentMessage.argument != null ? "Lv." + m_CurrentMessage.argument.ToString() : string.Empty;
            }
        }
        break;

        case NotificationName.MSG_PLAYER_SHIP_LEVEL_UP:
        {
            MsgShipLevelUp msg       = (MsgShipLevelUp)m_CurrentMessage.argument;
            UIIconAndLabel shipLabel = m_CurrentAnimationEvent.GetComponent <UIIconAndLabel>();
            if (shipLabel && shipLabel.Label)
            {
                shipLabel.Label.text = m_CurrentMessage.argument != null ? "Lv." + msg.m_level : string.Empty;
            }
            if (shipLabel && shipLabel.Icon)
            {
                UIUtil.SetIconImage(shipLabel.Icon, TableUtil.GetItemIconTid(msg.m_Tid));
            }
            if (shipLabel && shipLabel.Info)
            {
                string name = TableUtil.GetItemName(msg.m_Tid);
                shipLabel.Info.text = string.Format(TableUtil.GetLanguageString("hud_text_id_1036"), name);
            }
        }
        break;
        }
    }
Example #4
0
    /// <summary>
    /// 页面标签改变时
    /// </summary>
    /// <param name="index">页索引</param>
    /// <param name="text">文本</param>
    private void OnPageLabelChanged(int index, string text)
    {
        Transform ButtonBox = FindComponent <Transform>("Content/ButtonBox");

        if (index < ButtonBox.childCount)
        {
            Transform child = ButtonBox.GetChild(index);

            //更新显示
            UIIconAndLabel buttonInfo = child.GetComponent <UIIconAndLabel>();
            if (buttonInfo && buttonInfo.Info)
            {
                buttonInfo.Info.text = text;
            }
        }
    }
Example #5
0
 /// <summary>
 /// 部件卸载时
 /// </summary>
 protected override void OnViewPartUnload()
 {
     m_Money1 = null;
     m_Money2 = null;
 }
Example #6
0
    /// <summary>
    /// 更新所有分类
    /// </summary>
    private void UpdateList()
    {
        Transform ButtonBox = FindComponent <Transform>("Content/ButtonBox");
        Transform template  = FindComponent <Transform>("Content/ButtonBox/Button");

        if (!ButtonBox || !template)
        {
            return;
        }

        UIViewCategory[] categorys = State.GetPage().Categorys;

        int index = 0;
        int count = categorys != null ? categorys.Length : 0;

        for (index = 0; index < count; index++)
        {
            Transform child = null;
            if (index < ButtonBox.childCount)
            {
                child = ButtonBox.GetChild(index);
            }
            else
            {
                child = UnityEngine.Object.Instantiate(template, ButtonBox);
            }

            child.gameObject.SetActive(true);

            //更新显示
            UIIconAndLabel buttonInfo = child.GetComponent <UIIconAndLabel>();
            if (buttonInfo)
            {
                if (buttonInfo.Label)
                {
                    buttonInfo.Label.text = categorys[index].Label;
                }

                if (buttonInfo.Icon)
                {
                    buttonInfo.Icon.sprite = null;
                }
            }

            //绑定事件
            Toggle button = child.GetComponent <Toggle>();
            if (button)
            {
                int id = index;
                button.navigation = new Navigation()
                {
                    mode = Navigation.Mode.None
                };
                button.onValueChanged.RemoveAllListeners();
                button.onValueChanged.AddListener((selected) =>
                {
                    if (button.animator != null)
                    {
                        button.animator.SetBool("IsOn", selected);
                        button.animator.SetTrigger("Normal");
                    }

                    if (selected)
                    {
                        if (OwnerView != null)
                        {
                            ChangeFilterIndex(id);
                        }
                    }
                });
            }

            //音效处理
            ClickSoundListener handler = child.GetComponent <ClickSoundListener>();
            if (!handler)
            {
                handler = child.GetOrAddComponent <ClickSoundListener>();
            }
        }

        //关闭多余的按钮
        for (; index < ButtonBox.childCount; index++)
        {
            Transform child = ButtonBox.GetChild(index);
            child.gameObject.SetActive(false);

            Toggle button = child.GetComponent <Toggle>();
            if (button)
            {
                button.onValueChanged.RemoveAllListeners();
                button.isOn = false;
            }
        }
    }
Example #7
0
    /// <summary>
    /// 更新列表
    /// </summary>
    private void UpdateList()
    {
        ClearList();

        Transform ButtonBox = FindComponent <Transform>("Content/ButtonBox");
        Transform template  = FindComponent <Transform>("Content/ButtonBox/Button");

        if (ButtonBox && template)
        {
            CfgEternityProxy cfg = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;

            int index = 0;
            int count = GetPageCount();

            for (index = 0; index < count; index++)
            {
                //数据
                UiLabelConfig?pageCfg = cfg.GetUIPage((uint)Config.Value.LabelId(index));

                //视图
                Transform child = null;
                if (index < ButtonBox.childCount)
                {
                    child = ButtonBox.GetChild(index);
                }
                else
                {
                    child = Object.Instantiate(template, ButtonBox);
                }

                //更新显示
                child.gameObject.SetActive(OwnerView.State.GetPageVisible(index));

                UIIconAndLabel buttonInfo = child.GetComponent <UIIconAndLabel>();
                if (buttonInfo)
                {
                    if (buttonInfo.Icon)
                    {
                        if (pageCfg.HasValue && pageCfg.Value.Icon != 0)
                        {
                            UIUtil.SetIconImage(buttonInfo.Icon, (uint)pageCfg.Value.Icon);
                        }
                        else
                        {
                            buttonInfo.Icon.sprite = null;
                        }
                    }

                    if (buttonInfo.Label)
                    {
                        buttonInfo.Label.text = pageCfg.HasValue ? GetLocalization(pageCfg.Value.Name) : string.Empty;
                    }

                    if (buttonInfo.Info)
                    {
                        buttonInfo.Info.text = OwnerView.State.GetPageLabel(index);
                    }
                }

                //绑定事件
                Toggle button = child.GetComponent <Toggle>();
                if (button)
                {
                    int id = index;
                    button.navigation = new Navigation()
                    {
                        mode = Navigation.Mode.None
                    };
                    button.onValueChanged.RemoveAllListeners();
                    button.onValueChanged.AddListener((selected) =>
                    {
                        if (button.animator != null)
                        {
                            button.animator.SetBool("IsOn", selected);
                            button.animator.SetTrigger("Normal");
                        }

                        if (selected && !m_SkipEventListener)
                        {
                            if (OwnerView != null)
                            {
                                ChangePageIndex(id);
                            }
                        }
                    });
                }

                //音效处理
                ClickSoundListener handler = child.GetComponent <ClickSoundListener>();
                if (!handler)
                {
                    handler = child.GetOrAddComponent <ClickSoundListener>();
                }
            }

            //关闭多余的按钮
            for (; index < ButtonBox.childCount; index++)
            {
                Transform child = ButtonBox.GetChild(index);
                child.gameObject.SetActive(false);

                Toggle button = child.GetComponent <Toggle>();
                if (button)
                {
                    button.onValueChanged.RemoveAllListeners();
                    button.isOn = false;
                }
            }
        }
    }