/***
         * @params:
         *  iconsumperpage
         *  iconname
         *  materialdic
         *  iconrespath*
         *  iconprefabpath*
         * **/
        public void initComponents(params object[] paras)
        {
            //暂时用同一个size
            _iconSumPerPage = BackpackItemManager.Instance.GetSize(tabIndexToItemType[0]);
            string iconName = Convert.ToString(paras[0]);

            _uiType      = (UITypes)paras[1];
            _iconResPath = paras[2] == null ? _iconResPath : Convert.ToString(paras[2]);
            _materials   = new int[_iconSumPerPage];
            _iconbases   = new UIIcon[_iconSumPerPage];
            _buttons     = new GameObject[_iconSumPerPage];

            _bagBtnGrid = this.transform.Find("Grid");
            for (int i = 0; i < _iconSumPerPage; i++)
            {
                addItemIcon(i);
            }
            if (paras[3] != null)
            {
                _selectSprite = GameObject.Find(Convert.ToString(paras[3]));
                _selectSprite.SetActive(false);
            }
            GridLayoutGroup glg    = _bagBtnGrid.GetComponent <GridLayoutGroup>();
            float           height = (glg.cellSize.y + glg.spacing.y) * (_iconSumPerPage / 6);
            RectTransform   rtf    = _bagBtnGrid.GetComponent <RectTransform>();

            rtf.sizeDelta = new Vector2(rtf.sizeDelta.x, height);
            EventManager.RegisterEvent(UIEventMacro.CLICK_TAB, onClickTab);
            UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect);
            showIcon(0);
        }
    private void InitEvents()
    {
        UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, UITypes.MAIN_BAG.ToString(), onSelectFromBag);
        EventManager.RegisterEvent(EventMacro.ON_CHANGE_HANDCUBE, onChangeHandeCube);

        _bagBtn.GetComponent <Button>().onClick.AddListener(delegate()
        {
            openBag();
        });
    }
Beispiel #3
0
    protected override void InitEvents()
    {
        UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, UITypes.MAIN_BAG.ToString(), onSelectFromBag);
        EventManager.RegisterEvent(EventMacro.ON_CHANGE_HANDCUBE, onChangeHandeCube);
        EventManager.RegisterEvent(EventMacro.CLOSE_UI, (object[] paras) =>
        {
            if ((UITypes)paras[0] == UITypes.CROSS)
            {
                return;
            }
            if ((UITypes)paras[0] == UITypes.MAIN_BAG)
            {
                SetNormalBtnsActive(true);
            }
            else if ((UITypes)paras[0] != UITypes.MAIN_UI)
            {
                SetAllActive(true);
            }
        });

        EventManager.RegisterEvent(EventMacro.SHOW_UI, (object[] paras) =>
        {
            if ((UITypes)paras[0] == UITypes.CROSS)
            {
                return;
            }
            if ((UITypes)paras[0] == UITypes.MAIN_BAG)
            {
                SetNormalBtnsActive(false);
            }
            else if ((UITypes)paras[0] != UITypes.MAIN_UI && (UITypes)paras[0] != UITypes.TASK)
            {
                SetAllActive(false);
            }
        });
        _bagBtn.GetComponent <Button>().onClick.AddListener(delegate()
        {
            UIManager.Instance.showUI <MaterialBag>(UITypes.MAIN_BAG);
        });
        _systemBtn.GetComponent <Button>().onClick.AddListener(delegate()
        {
            OnClickSystemBtn();
        });
        EventTriggerListener.Get(_btnJump).onDown += On_JumpClickDown;
        EventTriggerListener.Get(_btnJump).onUp   += On_JumpClickUp;
    }
Beispiel #4
0
        public void initComponents(params object[] paras)
        {
            _uiType        = (UITypes)paras[0];
            _iconContainer = GameObject.Find("BagSelectContainer");
            UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect);
            _prefab = _prefab == null?Resources.Load(_iconPrefabPath) as GameObject : _prefab;

            GameObject    icon          = GameObject.Instantiate(_prefab) as GameObject;
            RectTransform rectTrans     = icon.GetComponent <RectTransform>();
            Vector3       localPosition = rectTrans.anchoredPosition3D;

            rectTrans.SetParent(_iconContainer.transform);
            rectTrans.anchoredPosition3D = localPosition;
            rectTrans.localScale         = Vector3.one;

            icon.AddComponent <UIIcon>();
            _iconBase = icon.GetComponent <UIIcon>();
            _iconBase.Init("0", _uiType, _iconResPath);
            _iconBase.setEnable(false);
        }
Beispiel #5
0
 public virtual void Register()
 {
     UIEventManager.RegisterEvent(UIEventManager.ET_UI_UPDATE, this.id, OnUpdate);
 }