Exemple #1
0
        /// <summary>
        /// View 的初始化依赖于 Presenter 和 Model,在 Project Setting 设置了三者运行的先后顺序
        /// </summary>
        private void Awake()
        {
            Instance = this;

            // 字段初始化
            foreach (var tab in BagModel.Instance.tabs)
            {
                GameObject content;
                BagPresenter.Instance.scrollViewContents.TryGetValue(tab.ToString(), out content);
                List <GameObject> list = new List <GameObject>();
                for (int i = 0; i < content.transform.childCount; ++i)
                {
                    list.Add(content.transform.GetChild(i).gameObject);
                }
                cardsView.Add(tab, list);
            }
        }
        public BagController()
        {
            //初始化五个格子
            m_initBagItemNum = 10;
            //最多10个格子
            m_maxBagItemNum = 10;
            //实例化view和model
            m_bagView    = new BagView();
            m_bagModel   = new BagModel();
            m_equipModel = new EquipModel();
            //m_equipView = new EquipView(m_bagView.m_bagList.transform.parent.GetChild(1));
            //初始化背包格子和数据
            InitBag(m_initBagItemNum, "Prefab/BagGrid");
            //初始化武器格子
            InitGunSlots(m_bagView.m_bag.transform);
            //添加事件监听
            LiteEventManager.Instance.Register(CollectKey.RemoveToBag, AddItemFromColect);

            UIEventManager.Get(m_bagView.closeBtn).OnClickCallBack += CloseView;
        }