Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="session"></param>
        /// <param name="canvas"></param>
        /// <param name="config"></param>
        public IEnumerator Run(
            Client client,
            GameSession session,
            Dictionary <string, string> config
            )
        {
            _client  = client;
            _session = session;
            _config  = config;

            void OnGetInventoryModel(
                string inventoryName,
                EzInventoryModel inventoryModel,
                List <EzItemModel> itemModels
                )
            {
                _inventoryModel = inventoryModel;
                _itemModels     = itemModels;
            }

            _goldSetting.onGetInventoryModel.AddListener(OnGetInventoryModel);

            yield return(InventoryController.GetInventoryModel(
                             client,
                             _goldSetting.inventoryNamespaceName,
                             _goldSetting.inventoryModelName,
                             _goldSetting.onGetInventoryModel,
                             _goldSetting.onError
                             ));

            _goldSetting.onGetInventoryModel.RemoveListener(OnGetInventoryModel);

            StartCoroutine(
                _inventoryWatcher.Run(
                    client,
                    session,
                    _goldSetting.inventoryNamespaceName,
                    _inventoryModel,
                    _itemModels,
                    _goldSetting.onGetInventory,
                    _goldSetting.onAcquire,
                    _goldSetting.onConsume,
                    _goldSetting.onError
                    )
                );

            goldWidget.Initialize(
                _inventoryWatcher
                );
            goldWidget.gameObject.SetActive(true);

            if (debugGoldControlWidget != null)
            {
                debugGoldControlWidget.Initialize();
                debugGoldControlWidget.onClickAcquireButton.AddListener(OnClickAcquireButton);
                debugGoldControlWidget.onClickConsumeButton.AddListener(OnClickConsumeButton);
                debugGoldControlWidget.gameObject.SetActive(true);
            }
        }
Пример #2
0
 public EzGetInventoryModelResult(
     GetInventoryModelResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzInventoryModel(result.item);
     }
 }
Пример #3
0
        public IEnumerator Run(
            Client client,
            GameSession session,
            string inventoryNamespaceName,
            EzInventoryModel inventoryModel,
            List <EzItemModel> itemModels,
            GetInventoryEvent onGetInventory,
            AcquireEvent onAcquire,
            ConsumeEvent onConsume,
            ErrorEvent onError
            )
        {
            if (_watching)
            {
                throw new InvalidOperationException("already started");
            }

            _watching = true;

            _client  = client;
            _session = session;

            _inventoryNamespaceName = inventoryNamespaceName;
            _inventoryModel         = inventoryModel;
            _itemModels             = itemModels;

            _onGetInventory = onGetInventory;
            _onAcquire      = onAcquire;
            _onConsume      = onConsume;
            _onError        = onError;

            onAcquire.AddListener(AcquireAction);
            onConsume.AddListener(ConsumeAction);

            yield return(Refresh());
        }