public override ISimplePlacement GetPlacement(IPurchasable purchasable, IResourceContainer resources)
        {
            var placement = new StructurePlacement(() => resources.HasEnough(purchasable.Cost) ? null : "Not enough resources");

            placement.OnPlaced += OnPlaced;
            return(placement);
        }
Пример #2
0
        public void Handle(IContentCachedPrefab prefab)
        {
            GameObject         go          = prefab.GetCache();
            IPurchasable       purchasable = go.GetComponent <IPurchasable>();
            IResourceContainer resources   = GetComponent <IResourceContainer>();

            if (resources.HasEnough(purchasable.Cost))
            {
                GameObject instance = prefab.Instantiate();
                ReflectionUtils.DynamicBroadcastInvoke(instance, "OnInstantiated", true); // Definitively hacky, but better than immidiate alternative.
                instance.SetActive(true);

                ISimplePlacement placement = GetPlacement(purchasable, resources);
                placement.Pickup(instance);

                placement.OnPlaced += (obj) => resources.TrySpend(purchasable.Cost);
                PlacementController.Instance.TakePlacement(placement);
            }
        }
Пример #3
0
 protected virtual bool IsInteractable()
 {
     return(_resourceContainer.HasEnough(_purchasable.Cost));
 }
Пример #4
0
        private void UpdateAvailableCount()
        {
            int amount = Controller.GetAvailable().Where(x => _resourceContainer.HasEnough(x.ResourceCost)).Count();

            AvailableOptionsCount.text = $"{amount} available research option(s)";
        }