// PRAGMA MARK - Public Interface public void SetupWithIdQuantity <TEntity>(IdQuantity <TEntity> idQuantity) where TEntity : DTEntity { IViewIdQuantity viewIdQuantity = new ViewIdQuantity <TEntity>(idQuantity); DTEntity entity = viewIdQuantity.Entity; DisplayComponent displayComponent = entity.GetComponent <DisplayComponent>(); if (displayComponent != null) { this._image.sprite = displayComponent.displaySprite; } if (viewIdQuantity.Quantity <= 0) { Debug.LogWarning("IdQuantityView - don't know how to show a quantity less than or equal to zero!"); } if (viewIdQuantity.Quantity > 1) { this._textContainer.SetActive(true); this._text.SetText(string.Format("x{0}", viewIdQuantity.Quantity)); } else { this._textContainer.SetActive(false); } }
// PRAGMA MARK - Public Interface public void SetupWithRequiredIdQuantity <TEntity>(IdQuantity <TEntity> requiredIdQuantity) where TEntity : DTEntity { IViewIdQuantity requiredViewIdQuantity = new ViewIdQuantity <TEntity>(requiredIdQuantity); this._requiredViewIdQuantity = requiredViewIdQuantity; this._requiredViewIdQuantity.OnUserInventoryUpdated += this.HandleInventoryUpdated; DTEntity entity = this._requiredViewIdQuantity.Entity; DisplayComponent displayComponent = entity.GetComponent <DisplayComponent>(); if (displayComponent != null) { this._requiredImage.sprite = displayComponent.displaySprite; } this.UpdateUserCount(); }