コード例 #1
0
        /// <summary>
        /// 设置背包界面道具信息
        /// </summary>
        /// <param name="model"></param>
        private void SetupKnapsackItemData(KnapsackModel model)
        {
            // 是否打开了商店
            if (GameEntry.UI.HasUIForm(UIFormId.ShopForm))
            {
                if (model.CanSell())
                {
                    m_FuncButton1.gameObject.SetActive(false);
                    m_FuncButton2.gameObject.SetActive(true);
                    m_FuncButton2.GetComponentInChildren <Text>().text = "出售";
                }
                else
                {
                    m_FuncButton1.gameObject.SetActive(false);
                    m_FuncButton2.gameObject.SetActive(false);
                }
            }
            else
            {
                if (model.CanUse())
                {
                    m_FuncButton1.gameObject.SetActive(true);
                    m_FuncButton1.GetComponentInChildren <Text>().text = "使用";
                }
                else if (model.CanEquip())
                {
                    m_FuncButton1.gameObject.SetActive(true);
                    m_FuncButton1.GetComponentInChildren <Text>().text = "装备";
                }

                if (model.CanDiscard())
                {
                    m_FuncButton2.gameObject.SetActive(true);
                    m_FuncButton2.GetComponentInChildren <Text>().text = "丢弃";
                }
                else
                {
                    m_FuncButton2.gameObject.SetActive(false);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 按钮2 出售、丢弃
        /// </summary>
        private void OnFuncButton2ClickOfKnapsack()
        {
            if (GameEntry.UI.HasUIForm(UIFormId.ShopForm))
            {
                if (m_KnapsackModel.CanSell())
                {
                    if (m_KnapsackModel.CurrentStackCount > 1)
                    {
                        GameEntry.DataNode.SetData <VarInt>(Constant.NodeKey.InputCountType, 1);
                        GameEntry.UI.OpenUIForm(UIFormId.InputCountForm, m_KnapsackModel);
                    }
                    else
                    {
                        // 出售一个
                        GameEntry.Controller.Knapsack.SellItem(m_KnapsackModel);
                    }
                }
            }
            else
            {
                if (m_KnapsackModel.CanDiscard())
                {
                    if (m_KnapsackModel.CurrentStackCount > 1)
                    {
                        GameEntry.DataNode.SetData <VarInt>(Constant.NodeKey.InputCountType, 3);
                        GameEntry.UI.OpenUIForm(UIFormId.InputCountForm, m_KnapsackModel);
                    }
                    else
                    {
                        // 丢弃一个
                        GameEntry.Controller.Knapsack.DiscardItem(m_KnapsackModel);
                    }
                }
            }

            OnCloseButtonClick();
        }