Esempio n. 1
0
    void UpdateBagGridItem(UIGridItem item)
    {
        if (item == null || item.mScripts == null || item.oData == null)
        {
            return;
        }
        Item info = item.oData as Item;

        item.onClick = OnClickItem;
        UISprite  color    = item.mScripts[0] as UISprite;
        UITexture itemIcon = item.mScripts[1] as UITexture;
        UILabel   Name     = item.mScripts[2] as UILabel;
        UILabel   num      = item.mScripts[3] as UILabel;
        UISprite  gou      = item.mScripts[4] as UISprite;
        UISprite  sprite   = item.mScripts[5] as UISprite;

        sprite.gameObject.SetActive(false);
        Name.gameObject.SetActive(info.itemID != string.Empty);
        num.gameObject.SetActive(info.itemID != string.Empty);
        if (info.itemID != string.Empty)
        {
            gou.gameObject.SetActive(batchSell);
            color.gameObject.SetActive(true);
            Name.gameObject.SetActive(true);
            num.gameObject.SetActive(true);
            itemIcon.gameObject.SetActive(true);
            ItemInfo data    = ItemManager.GetItemInfo(info.itemID);
            int      m_color = data.color;
            if (currentType == ItemType.Equip)
            {
                EquipItemInfo equip = EquipConfig.GetEquipDataByUUID(info.uuid);
                if (equip != null)
                {
                    m_color = equip.star;
                }
            }
            color.spriteName = UtilTools.StringBuilder("color", m_color);
            Name.text        = TextManager.GetItemString(info.itemID);
            num.text         = info.amount.ToString();
            LoadSprite.LoaderItem(itemIcon, info.itemID);
        }
        else
        {
            gou.gameObject.SetActive(false);
            color.gameObject.SetActive(false);
            Name.gameObject.SetActive(false);
            num.gameObject.SetActive(false);
            itemIcon.gameObject.SetActive(false);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 界面显示时调用
    /// </summary>
    protected override void OnShow(INotification notification)
    {
        if (panelType == PanelType.Info || panelType == PanelType.Sell || panelType == PanelType.Use)
        {
            m_Panel.CloseBtn.transform.localPosition = new Vector3(323, 244, 0);
            m_Panel.itemInfo.gameObject.SetActive(true);
            itemIcon  = m_Panel.transform.FindChild("itemInfo/itemIcon").GetComponent <UITexture>();
            itemcolor = m_Panel.transform.FindChild("itemInfo/itemcolor").GetComponent <UISprite>();
            itemName  = m_Panel.transform.FindChild("itemInfo/itemName").GetComponent <UILabel>();
            ShowItemInfo showItemInfo = (notification.Body as List <object>)[0] as ShowItemInfo;
            itemID = (notification.Body as List <object>)[1] as string;
            string uuid = (notification.Body as List <object>)[2] as string;
            item = ItemManager.GetItemInfo(itemID);
            EquipItemInfo equip = EquipConfig.GetEquipDataByUUID(uuid);
            if (equip != null)
            {
                itemcolor.spriteName = UtilTools.StringBuilder("color", equip.star);
            }
            else
            {
                itemcolor.spriteName = UtilTools.StringBuilder("color", item.color);
            }
            itemName.text = TextManager.GetItemString(item.itemID);
            LoadSprite.LoaderItem(itemIcon, itemID, false);
            if (panelType == PanelType.Info)
            {
                m_Panel.SellOne.gameObject.SetActive(false);
                m_Panel.Info.gameObject.SetActive(true);
                sellBtn    = m_Panel.transform.FindChild("itemInfo/Info/sellBtn").GetComponent <UIButton>();
                useItemBtn = m_Panel.transform.FindChild("itemInfo/Info/useItemBtn").GetComponent <UIButton>();
                itemDesc   = m_Panel.transform.FindChild("itemInfo/Info/itemDesc").GetComponent <UILabel>();
                itemPrice  = m_Panel.transform.FindChild("itemInfo/Info/itemPrice").GetComponent <UILabel>();
                itemNum    = m_Panel.transform.FindChild("itemInfo/Info/itemNum").GetComponent <UILabel>();
                UIEventListener.Get(sellBtn.gameObject).onClick    = OnClick;
                UIEventListener.Get(useItemBtn.gameObject).onClick = OnClick;
                if (item == null)
                {
                    return;
                }
                itemDesc.text  = TextManager.GetPropsString("description_" + item.itemID);
                itemPrice.text = item.itemPrice.ToString();
                itemNum.text   = ItemManager.GetBagItemCount(itemID.ToString()).ToString();
                sellItem       = showItemInfo.sellItem;
                useItem        = showItemInfo.useItem;
                if (sellItem == null && useItem == null)
                {
                    sellBtn.gameObject.SetActive(false);
                    useItemBtn.gameObject.SetActive(false);
                }
                else
                {
                    sellBtn.gameObject.SetActive(true);
                    useItemBtn.gameObject.SetActive(true);
                    sellItem = showItemInfo.sellItem;
                    useItem  = showItemInfo.useItem;
                }
            }
            else if (panelType == PanelType.Sell)
            {
                m_Panel.Info.gameObject.SetActive(false);
                m_Panel.SellOne.gameObject.SetActive(true);
                minBtn           = m_Panel.transform.FindChild("itemInfo/SellOne/minBtn").GetComponent <UIButton>();
                maxBtn           = m_Panel.transform.FindChild("itemInfo/SellOne/maxBtn").GetComponent <UIButton>();
                addBtn           = m_Panel.transform.FindChild("itemInfo/SellOne/addBtn").GetComponent <UIButton>();
                subtractBtn      = m_Panel.transform.FindChild("itemInfo/SellOne/subtractBtn").GetComponent <UIButton>();
                cancelOneSellBtn = m_Panel.transform.FindChild("itemInfo/SellOne/cancelOneSellBtn").GetComponent <UIButton>();
                okOneSellBtn     = m_Panel.transform.FindChild("itemInfo/SellOne/okOneSellBtn").GetComponent <UIButton>();
                haveNum          = m_Panel.transform.FindChild("itemInfo/SellOne/haveNum").GetComponent <UILabel>();
                changeNum        = m_Panel.transform.FindChild("itemInfo/SellOne/changeNum").GetComponent <UILabel>();
                sellPrcie        = m_Panel.transform.FindChild("itemInfo/SellOne/sellPrcie").GetComponent <UILabel>();
                UIEventListener.Get(cancelOneSellBtn.gameObject).onClick = OnClick;
                LongClickEvent.Get(subtractBtn.gameObject).onPress       = OnPress;
                LongClickEvent.Get(subtractBtn.gameObject).duration      = 3;
                LongClickEvent.Get(addBtn.gameObject).onPress            = OnPress;
                LongClickEvent.Get(addBtn.gameObject).duration           = 3;
                UIEventListener.Get(minBtn.gameObject).onClick           = OnClick;
                UIEventListener.Get(maxBtn.gameObject).onClick           = OnClick;
                UIEventListener.Get(okOneSellBtn.gameObject).onClick     = OnClick;
                subtractBtn.gameObject.SetActive(info.amount > 1);
                addBtn.gameObject.SetActive(info.amount > 1);
                maxBtn.gameObject.SetActive(info.amount > 1);
                minBtn.gameObject.SetActive(info.amount > 1);
                changeNum.gameObject.SetActive(info.amount > 1);
                changeNum.text = "1";
                sellPrcie.text = item.itemPrice.ToString();
                haveNum.text   = info.amount.ToString();
                SellOne        = showItemInfo.sellOne;
            }
            else if (panelType == PanelType.Use)
            {
                sellBtn    = m_Panel.transform.FindChild("itemInfo/Info/sellBtn").GetComponent <UIButton>();
                useItemBtn = m_Panel.transform.FindChild("itemInfo/Info/useItemBtn").GetComponent <UIButton>();
                itemDesc   = m_Panel.transform.FindChild("itemInfo/Info/itemDesc").GetComponent <UILabel>();
                itemPrice  = m_Panel.transform.FindChild("itemInfo/Info/itemPrice").GetComponent <UILabel>();
                itemNum    = m_Panel.transform.FindChild("itemInfo/Info/itemNum").GetComponent <UILabel>();
                sellBtn.gameObject.SetActive(false);
                useItemBtn.gameObject.SetActive(false);
                m_Panel.Info.gameObject.SetActive(true);
                m_Panel.use.gameObject.SetActive(true);
                if (item == null)
                {
                    return;
                }
                itemDesc.text  = TextManager.GetPropsString("description_" + item.itemID);
                itemPrice.text = item.itemPrice.ToString();
                itemNum.text   = info.amount.ToString();
                okuse          = m_Panel.transform.FindChild("itemInfo/use/okuse").GetComponent <UIButton>();
                cancelUse      = m_Panel.transform.FindChild("itemInfo/use/cancelUse").GetComponent <UIButton>();
                UIEventListener.Get(okuse.gameObject).onClick     = OnClick;
                UIEventListener.Get(cancelUse.gameObject).onClick = OnClick;
                UseOne = showItemInfo.useOne;
            }
        }
        else if (panelType == PanelType.Reward)
        {
            rewardIndex = 0;
            m_Panel.Mask.GetComponent <BoxCollider>().enabled    = false;
            UIEventListener.Get(m_Panel.Mask.gameObject).onClick = OnClick;
            m_Panel.CloseBtn.gameObject.SetActive(false);
            GameObject cell = m_Panel.RewardItem.gameObject;
            PoolManager.CreatePrefabPools(PoolManager.PoolKey.Prefab_RewardItem, cell, false);
            m_Panel.getReward.gameObject.SetActive(true);
            rewardList = notification.Body as List <object>;
            TimerManager.Destroy("rewardIndex");
            TimerManager.AddTimer("rewardIndex", 0.02f, CreateRewardItem);
            //getRewardBtn = m_Panel.transform.FindChild("getReward/getRewardBtn").GetComponent<UIButton>();
            //UIEventListener.Get(getRewardBtn.gameObject).onClick = OnClick;
        }
        else if (panelType == PanelType.ChooseFriend)
        {
            if (FriendMediator.friendList.Count < 1)
            {
                GUIManager.SetPromptInfo(TextManager.GetUIString("UI2048"), null);
                ClosePanel(null);
                return;
            }
            m_Panel.CloseBtn.transform.localPosition = new Vector3(374, 229, 0);
            m_Panel.chooseFriend.gameObject.SetActive(true);

            FriendGrid         = UtilTools.GetChild <UIGrid>(m_Panel.transform, "chooseFriend/ScrollView/FriendGrid");
            FriendGrid.enabled = true;
            FriendGrid.BindCustomCallBack(UpdateFriendGrid);
            FriendGrid.StartCustom();
        }
        else if (panelType == PanelType.UpMentality)
        {
            m_Panel.CloseBtn.transform.localPosition = new Vector3(316, 277, 0);
            UPMentality    = UtilTools.GetChilds <UIToggle>(m_Panel.transform, "ballerUpMentality/group");
            mentalityDesc  = UtilTools.GetChilds <UILabel>(m_Panel.transform, "ballerUpMentality/group");
            UPMentalityBtn = m_Panel.transform.FindChild("ballerUpMentality/UPMentalityBtn").GetComponent <UISprite>();
            UIEventListener.Get(UPMentalityBtn.gameObject).onClick = OnClick;
            m_Panel.ballerUpMentality.gameObject.SetActive(true);
        }
        else if (panelType == PanelType.SwitchInherit)
        {
            m_Panel.CloseBtn.transform.localPosition = new Vector3(378, 243, 0);
            m_Panel.switchballer.gameObject.SetActive(true);
            List <object> list = notification.Body as List <object>;
            ChooseGrid         = UtilTools.GetChild <UIGrid>(m_Panel.transform, "switchballer/ScrollView/ChooseGrid");
            ChooseGrid.enabled = true;
            ChooseGrid.BindCustomCallBack(UpdateInheriter);
            ChooseGrid.StartCustom();
            ChooseGrid.AddCustomDataList(list);
        }
    }