public static IEnumerator Consume( Client client, GameSession session, string inventoryNamespaceName, string inventoryModelName, string itemModelName, int consumeValue, ConsumeEvent onConsume, ErrorEvent onError, string itemSetName = null ) { AsyncResult <EzConsumeResult> result = null; yield return(client.Inventory.Consume( r => { result = r; }, session, inventoryNamespaceName, inventoryModelName, itemModelName, consumeValue, itemSetName )); if (result.Error != null) { onError.Invoke( result.Error ); yield break; } var inventory = result.Result.Inventory; var itemSets = result.Result.Items; onConsume.Invoke(inventory, itemSets, consumeValue); }
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()); }