public void Setup(CollectionData collectionData, ChargerData data) { this.data = data; this.collectionData = collectionData; iconImage.overrideSprite = resourceService.GetSprite(data); var info = collectionData.GetChargeData(data.id); int playerCount = playerService.GetItemCount(data); countText.text = string.Format($"{playerCount}/{info.count}"); if (playerCount >= info.count) { countText.color = allowColor; iconImage.color = nonEmptyIconColor; } else { countText.color = notAllowColor; iconImage.color = emptyIconColor; } trigger.SetEventTriggerClick((eventData) => { Debug.Log($"Click on charger: {data.id}"); PointerEventData pointerData = eventData as PointerEventData; if (pointerData != null) { if (pointerData.GetPointerObjectName() == trigger.name) { viewService.ShowView(RavenhillViewType.collection_buy_charger_view, collectionData); } } }, engine.GetService <IAudioService>()); }
public bool IsCollectionReadyToCharge(CollectionData collection) { bool collectablesReady = true; RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); foreach (string collectableId in collection.collectableIds) { CollectableData data = resourceService.GetCollectable(collectableId); int playerCount = playerService.GetItemCount(data); if (playerCount <= 0) { collectablesReady = false; break; } } bool chargersReady = true; foreach (var info in collection.chargers) { ChargerData data = resourceService.GetCharger(info.id); int playerCount = playerService.GetItemCount(data); if (playerCount < info.count) { chargersReady = false; break; } } return(collectablesReady && chargersReady); }
public void Setup(ChargerData data, CollectionData collectionData) { this.data = data; this.collectionData = collectionData; nameText.text = resourceService.GetName(data); iconImage.overrideSprite = resourceService.GetSprite(data); int requiredCount = collectionData.GetChargerCount(data.id); int playerCount = playerService.GetItemCount(data); if (playerCount >= requiredCount) { buyButton.DeactivateSelf(); availableLabel.ActivateSelf(); } else { buyButton.ActivateSelf(); availableLabel.DeactivateSelf(); priceImage.overrideSprite = resourceService.GetPriceSprite(data.price); priceText.text = data.price.price.ToString(); buyButton.SetListener(() => { playerService.Buy(data); }, engine.GetService <IAudioService>()); } countText.text = $"You have {playerCount} from {requiredCount}"; wishlistUpdateTimer.Setup(.5f, UpdateWishlistButton); wishlistButton.SetListener(() => { if (!playerService.IsWishlistContains(data) && !playerService.IsWishlistFull) { playerService.AddToWishlist(data); Resetup(); } }, engine.GetService <IAudioService>()); }