public override void Setup(object data = null) { base.Setup(data); StoryCollectionData storyCollectionData = data as StoryCollectionData; cachedData = storyCollectionData; if (storyCollectionData == null) { throw new ArgumentException($"{GetType().Name}: must have setup argument {typeof(StoryCollectionData).Name}"); } for (int i = 0; i < storyCollectableViews.Length; i++) { if (i < storyCollectionData.collectables.Count) { StoryCollectableData collectableData = resourceService.GetStoryCollectable(storyCollectionData.collectables[i]); storyCollectableViews[i].Setup(collectableData); } } StoryChargerData storyChargerData = resourceService.GetStoryCharger(storyCollectionData.chargerId); chargerView.Setup(storyChargerData); SetupChargeButton(storyCollectionData); SetupCollectionIcon(storyCollectionData); closeBigButton.SetListener(() => Close(), engine.GetService <IAudioService>()); buyChargerView.Setup(storyCollectionData); }
public bool IsStoryCollectionReadyToCharge(StoryCollectionData collection) { bool hasCollectables = true; RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); foreach (string collectableId in collection.collectables) { StoryCollectableData collectableData = resourceService.GetStoryCollectable(collectableId); int playerCount = playerService.GetItemCount(collectableData); if (playerCount <= 0) { hasCollectables = false; break; } } bool hasCharger = true; StoryChargerData chargerData = resourceService.GetStoryCharger(collection.chargerId); int playerChargerCount = playerService.GetItemCount(chargerData); if (playerChargerCount <= 0) { hasCharger = false; } return(hasCollectables && hasCharger); }
public void Setup(StoryCollectableData data) { int playerCount = playerService.GetItemCount(data); iconImage.color = (playerCount > 0) ? Color.white : emptyColor; iconImage.overrideSprite = resourceService.GetSprite(data); nameText.text = resourceService.GetString(data.nameId); }