Example #1
0
        protected virtual void PopulateRewardItemTable(Table table, ValuablesCollection valuables)
        {
            if (!table)
            {
                return;
            }

            table.Clear();

            if (valuables != null)
            {
                if (valuables.CollectibleCounts != null)
                {
                    foreach (var cc in valuables.CollectibleCounts)
                    {
                        AddRewardCollectible(table, cc);
                    }
                }

                if (valuables.CurrencyCounts != null)
                {
                    foreach (var cc in valuables.CurrencyCounts)
                    {
                        AddRewardCurrency(table, cc);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Rewards the valuables.
        /// </summary>
        /// <param name="valuables">Valuables.</param>
        /// <param name="onReward">Callback after the valuables have been rewarded to the player.</param>
        public void RewardValuables(ValuablesCollection valuables, Action onReward = null)
        {
            Action doReward = () =>
            {
                if (onReward != null)
                {
                    onReward();
                }

                if (RewardAdded != null)
                {
                    RewardAdded(this, new RewardEventArgs(valuables));
                }

                TransactionManager.Instance.AddValuables(valuables);
            };

            if (Delegate != null)
            {
                Delegate.ProcessReward(valuables, doReward);
            }
            else
            {
                doReward();
            }
        }
Example #3
0
        public void ProcessReward(ValuablesCollection valuables, Action onReward)
        {
            // If there's a reward panel, add the valuables to the inventory after
            // the player confirms.
            if (RewardPanel)
            {
                if (ApplyRewardOnPanelClose)
                {
                    RewardPanel.Push(valuables, onReward);
                }
                else
                {
                    RewardPanel.Push(valuables);

                    if (onReward != null)
                    {
                        onReward();
                    }
                }
            }
            else
            {
                if (onReward != null)
                {
                    onReward();
                }
            }
        }
Example #4
0
        protected virtual void PopulateGiveActionItemTable(Table table, ValuablesCollection valuables)
        {
            var task = Driver.Task;

            if (table)
            {
                table.Clear();

                if (valuables != null)
                {
                    if (valuables.CollectibleCounts != null)
                    {
                        foreach (var cc in valuables.CollectibleCounts)
                        {
                            AddGiveCollectible(table, cc);
                        }
                    }

                    if (valuables.CurrencyCounts != null)
                    {
                        foreach (var cc in valuables.CurrencyCounts)
                        {
                            AddGiveCurrency(table, cc);
                        }
                    }
                }
            }
        }
        public bool HasValuables(ValuablesCollection valuables)
        {
            if (valuables == null)
            {
                return(true);
            }

            if (valuables.CollectibleCounts != null)
            {
                foreach (var cc in valuables.CollectibleCounts)
                {
                    var ct = Inventory.Instance.GetCount(cc.CollectibleId);

                    if (ct < cc.Count)
                    {
                        return(false);
                    }
                }
            }

            if (valuables.CurrencyCounts != null)
            {
                foreach (var cc in valuables.CurrencyCounts)
                {
                    var ct = Wallet.Instance.GetCount(cc.Currency);

                    if (ct < cc.Count)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public override void Populate(ValuablesCollection data)
        {
            base.Populate(data);

            m_toStart        = CollectiblesTable.GetItems <FadeDestroyInventoryTableItem>().ToList();
            m_sinceLastSpawn = float.MaxValue;
        }
 public static void Show(ValuablesCollection rewards)
 {
     if (rewards != null)
     {
         PanelManager.Instance.Push(Instance, rewards);
     }
 }
 public void AddValuables(ValuablesCollection valuables)
 {
     if (valuables != null)
     {
         Inventory.Instance.Add(valuables.CollectibleCounts);
         Wallet.Instance.Add(valuables.CurrencyCounts);
     }
 }
        public IEnumerable <CollectibleSet> GetCollectibleSets(ValuablesCollection valuables)
        {
            if (valuables == null || valuables.CollectibleCounts == null)
            {
                return(new CollectibleSet[0]);
            }

            return(GetCollectibleSets(valuables.CollectibleCounts));
        }
        public Collectible GetFirstCollectible(ValuablesCollection valuables)
        {
            if (valuables == null || valuables.CollectibleCounts == null || valuables.CollectibleCounts.Length == 0)
            {
                return(null);
            }

            return(GetItem(valuables.CollectibleCounts[0].CollectibleId));
        }
        public bool Exchange(ValuablesCollection inputs, ValuablesCollection outputs, bool allowDebt = false)
        {
            if (!HasValuables(inputs) && !allowDebt)
            {
                return(false);
            }

            RemoveValuables(inputs);
            AddValuables(outputs);

            return(true);
        }
Example #12
0
 /// <summary>
 /// Show the rewards screen without actually awarding the valuables.
 /// </summary>
 /// <param name="valuables"></param>
 public void ShowRewards(ValuablesCollection valuables, Action onClose = null)
 {
     if (Delegate != null)
     {
         Delegate.ProcessReward(valuables, onClose);
     }
     else
     {
         if (onClose != null)
         {
             onClose();
         }
     }
 }
Example #13
0
        protected virtual void PopulateTakeActionItemTable(Table table, ValuablesCollection valuables)
        {
            var task = Driver.Task;

            if (table)
            {
                table.Clear();

                if (valuables != null && valuables.CollectibleCounts != null)
                {
                    foreach (var cc in valuables.CollectibleCounts)
                    {
                        if (cc.Collectible == null)
                        {
                            continue;
                        }

                        var collectible = cc.Collectible;
                        // todo..
                        var prefab = GetTakeCollectiblePrefab(collectible);

                        var aiObj = table.AddItem(prefab);

                        var invCount = Inventory.Instance.GetCount(cc.CollectibleId);
                        aiObj.ItemName.text = collectible.Title;
                        aiObj.Count.text    = string.Format("{0}", cc.Count);
                        aiObj.Id            = collectible.Id;

                        if (collectible.ImageUrl != null)
                        {
                            ImageLoader.LoadImageOnThread(collectible.ImageUrl, aiObj.Image);
                        }

                        if (aiObj.SatisfiedObject)
                        {
                            aiObj.SatisfiedObject.SetActive(invCount >= cc.Count);
                        }
                    }
                }


                if (valuables != null && valuables.CurrencyCounts != null)
                {
                    foreach (var cc in valuables.CurrencyCounts)
                    {
                        AddTakeCurrency(table, cc);
                    }
                }
            }
        }
Example #14
0
        public void SpawnItem(LocationSpawnItemDriverEventArgs <LocationValuablesCollection> e, ILocationCollectionMechanic m)
        {
            var  arMechanic     = m as ARLocationCollectionMechanic;
            bool showAnnotation = arMechanic != null && arMechanic.ShowMapAnnotation;

            var collectible = ValuablesCollection.GetFirstCollectible(e.Results.SpawnItem.ValuablesCollection);

            var options = GetOptions(e.Results.SpawnItem, m as ARLocationCollectionMechanic);

            if (collectible != null)
            {
                ThreadHelper.Instance.CallOnMainThread(() =>
                {
                    LocationARWorldObject worldObj = null;

                    if (collectible.AssetInstance != null &&
                        collectible.AssetInstance.Asset != null)
                    {
                        worldObj = ARWorld.Instance.AddLocationARAsset(
                            e.Results.SourceLocation,
                            0,
                            collectible.AssetInstance,
                            options);
                    }

                    if (worldObj == null)
                    {
                        worldObj = ARWorld.Instance.
                                   AddLocationARImage(e.Results.SourceLocation, 0, collectible.ImageUrl, options);
                    }

                    worldObj.Clicked += (sender, args) =>
                    {
                        RewardManager.Instance.ShowRewards(e.Results.SpawnItem.ValuablesCollection);

                        WorldValuablesManager.Instance.Collect(e);
                    };

                    m_worldObjects[e.Results.SourceLocation.Id] = worldObj;
                });

                if (showAnnotation && MapLocationCollectionDriver)
                {
                    MapLocationCollectionDriver.AddARCollectAnnotation(e);
                }
            }
        }
        public AnnotationGameObject CreateAnnotationObject(LocationValuablesCollection lvc)
        {
            if (AnnotationPrefab)
            {
                var obj = Instantiate(AnnotationPrefab);

                var customImageAnn = obj as CustomImageAnnotation;

                if (customImageAnn)
                {
                    var collectible = ValuablesCollection.GetFirstCollectible(lvc.ValuablesCollection);

                    if (collectible != null)
                    {
                        customImageAnn.LoadImage(collectible.ImageUrl);
                    }
                }

                return(obj);
            }

            return(null);
        }
Example #16
0
 public RewardEventArgs(ValuablesCollection valuables)
 {
     this.Valuables = valuables;
 }