示例#1
0
        protected override void OnChangeData(IItemData itemData, string itemType)
        {
            _model = itemData as GameUnitModel;
            if (_model == null)
            {
                gameObject.SetActive(false);
                return;
            }
            gameObject.SetActive(true);
            if (GameNameLabel != null)
            {
                GameNameLabel.Text(_model.GameName);
            }
            if (Background != null)
            {
                var gm    = GameListModel.Instance;
                var group = gm.GetGroup(gm.CurGroup);
                Background.spriteName = string.Format("{0}{1}", BackgroundNamePrefix, group.Type);
            }
            name = _model.GameKey;
            if (_itemView != null)
            {
                Destroy(_itemView.gameObject);
            }
            var assetname = string.Format("gamelist_{0}", name);

            if (!string.IsNullOrEmpty(itemType))
            {
                assetname = string.Format("{0}_{1}", assetname, itemType);
            }
            var bundlePrefix = string.Format("{0}_{1}", App.Skin.GameInfo, name);
            var bundleName   = string.Format("{0}/{1}", bundlePrefix, assetname);
            var go           = ResourceManager.LoadAsset(App.Skin.GameInfo, bundleName, assetname);//App.HallName

            if (go == null)
            {
                return;
            }
            go = Instantiate(go);
            var ts      = go.transform;
            var lcScale = ts.localScale;
            var lcPos   = ts.localPosition;
            var lcRot   = ts.localRotation;

            ts.parent        = transform;
            ts.localPosition = lcPos;
            ts.localRotation = lcRot;
            ts.localScale    = lcScale;
            _itemView        = go.GetComponent <GameListItemView>();
            if (_itemView != null)
            {
                _itemView.FreshBtnClickBound(_btn, DefaultBoxWidget, _model.GameState == GameState.Developing);
            }
            else
            {
                YxDebug.LogError("没有GameListItemView", "GameListItem");
            }
        }
示例#2
0
        protected override void OnChangeData(IItemData itemData)
        {
            _model = itemData as GameUnitModel;
            if (_model == null)
            {
                gameObject.SetActive(false);
                return;
            }
            gameObject.SetActive(true);
            if (GameNameLabel != null)
            {
                GameNameLabel.text = _model.GameName;
            }
            if (Background != null)
            {
                var gm    = GameListModel.Instance;
                var group = gm.GetGroup(gm.CurGroup);
                Background.spriteName = string.Format("{0}{1}", BackgroundNamePrefix, group.Type);
            }
            name = _model.GameKey;
            var namePrefix = string.Format("{0}_{1}", App.GameListPath, name);

            if (_itemView != null)
            {
                Destroy(_itemView.gameObject);
            }
            var go = ResourceManager.LoadAsset(App.GameListPath, namePrefix, namePrefix);//App.HallName

            if (go == null)
            {
                return;
            }
            go = Instantiate(go);
            var ts      = go.transform;
            var lcScale = ts.localScale;
            var lcPos   = ts.localPosition;
            var lcRot   = ts.localRotation;

            ts.parent        = transform;
            ts.localPosition = lcPos;
            ts.localRotation = lcRot;
            ts.localScale    = lcScale;
            _itemView        = go.GetComponent <GameListItemView>();
            _itemView.FreshBtnClickBound(_btn, _model.GameState == GameState.Developing);
        }