Example #1
0
        public void SetMenuClick(string menuItem, EventCallback1 c)
        {
            EventCallback1 call;

            if (calls.TryGetValue(menuItem, out call))
            {
                calls[menuItem] = c;
            }
            else
            {
                calls.Add(menuItem, c);
            }
            var item = View.GetChildInGroup(menu, menuItem);

            item.onClick.Add(OnItemClick);
        }
Example #2
0
    // Use this for initialization
    void Start()
    {
        battleComponent   = GetComponent <UIPanel>().ui;
        boxButton         = battleComponent.GetChild("boxButton").asButton;
        boxButton.visible = false;

        boxButton.onClick.Add(() => {
            boxWindow = new BoxWindow(box);
            boxWindow.Show();
        });

        // 坦克将碰撞到的盒子传递过来,通过判断盒子是否为空表示远离或接近
        Box.boxDelegate += (Box box) => {
            boxButton.visible = box == null ? false : true;
            // 远离盒子时关闭窗口
            if (!boxButton.visible && boxWindow != null)
            {
                boxWindow.Hide();
                boxWindow.Dispose();
                boxWindow          = null;
                boxButton.selected = false;
            }
            this.box = box;
        };

        Tank.goodsDelegate += (List <Goods> goodsList) => {
            // 清除旧窗口
            if (goodsWindow != null)
            {
                goodsWindow.Hide();
                goodsWindow.Dispose();
                goodsWindow = null;
            }
            // 新建新窗口
            createGoodsWindow(goodsList);
        };

        // 注册拖拽事件
        GGroup footer = battleComponent.GetChild("footer").asGroup;

        mulGoodsList = battleComponent.GetChildInGroup(footer, "buttleList").asList;
        sinGoodsList = battleComponent.GetChildInGroup(footer, "goodsList").asList;
        GObject[] mulGoodsButtons = mulGoodsList.GetChildren();
        GObject[] sinGoodsButtons = sinGoodsList.GetChildren();
        getGoodsDelegate += getGoods;

        dragIcon = battleComponent.GetChild("dragIcon").asLoader;
        touchID  = -1;

        bulletEmptyList   = new List <GButton>();
        medecineEmptyList = new List <GButton>();

        for (int i = 0; i < mulGoodsButtons.Length; i++)
        {
            GButton btn = (GButton)mulGoodsButtons[i];
            btn.visible = false;
            addDragAndDrop(btn);

            bulletEmptyList.Add(btn);
        }
        for (int i = 0; i < sinGoodsButtons.Length; i++)
        {
            GButton btn = (GButton)sinGoodsButtons[i];
            btn.visible = false;
            addDragAndDrop(btn);

            // 包含药品、道具
            medecineEmptyList.Add(btn);
        }

        coldDownTable        = new Hashtable();
        bulletColdDownTime   = 0;
        medecineColdDownTime = 0;
    }