Beispiel #1
0
        private void SetPlayer1ConsumableItem([NotNull] object[] objects)
        {
            if (objects == null)
            {
                throw new ArgumentNullException(nameof(objects));
            }
            List <ConsumableData> value = (List <ConsumableData>)objects[0];

            ConsumableDatas = value;
            _list.SetVirtualAndLoop();
            _list.itemRenderer = RenderListItem;
            _list.numItems     = 1;
            _list.scrollPane.onScroll.Add(DoSpecialEffect);
            DoSpecialEffect();
            scrollPane            = _list.scrollPane;
            scrollPane.scrollStep = 93f;

            if (value.Count < 1)
            {
                _list.numItems = 1;
                _list.RefreshVirtualList();
            }
            else
            {
                _list.numItems = value.Count;
            }

            {
                ConsumableData consumableData;
                ListExtend.TryGet <ConsumableData>(value,
                                                   (int)((_list.GetFirstChildInView() + 1) % _list.numItems), out consumableData);
                _list.RefreshVirtualList();
            }
        }
Beispiel #2
0
 //数据转换为playerList或string
 private void MessageHandler(byte[] data, int length)
 {
     try
     {
         using (MemoryStream ms = new MemoryStream())
         {
             BinaryFormatter bf = new BinaryFormatter();
             ms.Write(data, 0, length);
             ms.Flush();
             ms.Position = 0;
             List <Player> pl = bf.Deserialize(ms) as List <Player>;
             MainUI.currentRoom.currentPlayer = pl;
             playerList.RefreshVirtualList();
             roomInfoComponent.GetChild("playerNumTextField").asTextField.text = MainUI.currentRoom.currentPlayer.Count + "/" + MainUI.currentRoom.limitNum;
             Debug.Log("接收到玩家列表,更新!");
             if (MainUI.player.isHost)
             {
                 changeRoomDelegate(MainUI.currentRoom);
             }
         }
     }
     catch (System.Exception)
     {
         string msg = Encoding.UTF8.GetString(data, 0, length);
         message.Add(msg);
         if (message.Count > 50)
         {
             message.RemoveRange(0, message.Count - 50);
         }
         messageList.RefreshVirtualList();
     }
 }
Beispiel #3
0
    private void RenderListItem(int index, GObject obj)
    {
        GButton btn = obj.asButton;

        btn.title = "";
        btn.icon  = "";
        if (index >= this.goodsList.Count)
        {
            return;
        }
        Goods goods = this.goodsList[index];

        obj.onClick.Clear();
        obj.onClick.Add(() => {
            // 判断包满
            if (!GoodsUI.getGoodsDelegate(goods))
            {
                return;
            }
            // 移除物品
            goodsList.RemoveAt(index);
            // 通过名字查找实体,调用方法将实体从世界移除
            GameObject.Find(goods.name).GetComponent <Goods>().destroy();
            // 重置虚拟列表显示数量
            goodsGList.numItems = goodsList.Count;
            if (goodsGList.numItems == 0)
            {
                Hide();
            }
            // 刷新列表,物品将向前位移
            goodsGList.RefreshVirtualList();
        });
        btn.title = goods.type;
        // 判断icon是否为具体路径
        string url = goods.icon;

        if (!url.StartsWith("ui"))
        {
            url = UIPackage.GetItemURL("BattleCity8102", "goods-" + goods.icon);
        }
        btn.icon = url;
        // 背景#EFC324表示重要物资,#FFFFFF为普通物资
        //btn.GetChild("rightBg").asGraph.color = new Color();
        //btn.GetChild("leftBg").asGraph.color = new Color();
        btn.GetChild("nameTextField").asTextField.text        = goods.goodsName;
        btn.GetChild("descriptionTextField").asTextField.text = goods.description;
        btn.GetChild("countTextField").asTextField.text       = goods.count + "";
        btn.GetChild("coldDownTextField").asTextField.text    = goods.coldDownTime + "";
    }
Beispiel #4
0
    private void RenderListItem(int index, GObject obj)
    {
        GButton btn = obj.asButton;

        btn.title = "";
        btn.icon  = "";
        if (index >= box.goodsList.Count)
        {
            return;
        }
        Goods goods = box.goodsList[index];

        btn.title = goods.type;
        // 判断icon是否为具体路径
        string url = goods.icon;

        if (!url.StartsWith("ui"))
        {
            url = UIPackage.GetItemURL("BattleCity8102", "goods-" + goods.icon);
        }
        btn.icon = url;
        // 背景#EFC324表示重要物资,#FFFFFF为普通物资
        //btn.GetChild("rightBg").asGraph.color = new Color();
        //btn.GetChild("leftBg").asGraph.color = new Color();
        btn.GetChild("nameTextField").asTextField.text        = goods.goodsName;
        btn.GetChild("countTextField").asTextField.text       = goods.count + "";
        btn.GetChild("descriptionTextField").asTextField.text = goods.description;
        btn.GetChild("coldDownTextField").asTextField.text    = goods.coldDownTime + "";

        //点击物品拾取,清除上次监听
        obj.onClick.Clear();
        obj.onClick.Add(() => {
            // 判断包满
            if (!GoodsUI.getGoodsDelegate(goods))
            {
                return;
            }
            box.goodsList.RemoveAt(index);
            boxList.numItems = box.goodsList.Count;
            boxList.RefreshVirtualList();
        });
    }