Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 7
0
 public static void Show(ValuablesCollection rewards)
 {
     if (rewards != null)
     {
         PanelManager.Instance.Push(Instance, rewards);
     }
 }
Exemplo n.º 8
0
 public void AddValuables(ValuablesCollection valuables)
 {
     if (valuables != null)
     {
         Inventory.Instance.Add(valuables.CollectibleCounts);
         Wallet.Instance.Add(valuables.CurrencyCounts);
     }
 }
Exemplo n.º 9
0
        public IEnumerable <CollectibleSet> GetCollectibleSets(ValuablesCollection valuables)
        {
            if (valuables == null || valuables.CollectibleCounts == null)
            {
                return(new CollectibleSet[0]);
            }

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

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

            RemoveValuables(inputs);
            AddValuables(outputs);

            return(true);
        }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 16
0
 public RewardEventArgs(ValuablesCollection valuables)
 {
     this.Valuables = valuables;
 }