Example #1
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  Initialize()
        //------------------------------------------------------------------------------------------------------------------------
        public void Initialize()
        {
            //Set up the model and controller
            shopModel = new ShopModel();


            shopController = new ShopController(shopModel);


            //get view from children
            shopView = GetComponentInChildren <ShopView>();


            Debug.Assert(shopView != null);

            //get mesageview from children
            shopMessageView = GetComponentInChildren <ShopMessageView>();
            Debug.Assert(shopMessageView != null);

            //setup model and controller

            //link them
            shopView.Initialize(shopModel, shopController); //view1
            shopMessageView.Initialize(shopModel);          //view2

            shopView.Subscribe(shopModel);
        }
Example #2
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  Initialize()
        //------------------------------------------------------------------------------------------------------------------------
        public void Initialize()
        {
            var itemGenerator = new Generator(new NormalItemFactory());

            //Set up the model and controller
            _shopModel      = new ShopModel(itemGenerator.CreateRandomItems(Globals.ItemsPerShop));
            _shopController = new ShopController(_shopModel);

            //get view from children
            _shopView = GetComponentInChildren <ShopView>();
            _shopView.Subscribe(_shopModel);
            Debug.Assert(_shopView != null);

            //get mesageview from children
            _shopMessageView = GetComponentInChildren <ShopMessageView>();
            _shopMessageView.Subscribe(_shopModel);
            Debug.Assert(_shopMessageView != null);

            //get itemInfoView from children
            _shopItemInfoView = GetComponentInChildren <ShopItemInfoView>();
            _shopItemInfoView.Subscribe(_shopModel);

            //setup model and controller

            //link them


            _shopView.Initialize(_shopController, Game.PlayerHumanoid); //view1
            _shopMessageView.Initialize(_shopModel);                    //view2
        }