Exemplo n.º 1
0
        /// <summary>
        /// Is called when the owner of this QuestLog receives or looses the given amount of Items
        /// </summary>
        /// <param name="item"></param>
        internal void OnItemAmountChanged(Item item, int delta)
        {
            for (int index1 = 0; index1 < this.m_RequireItemsQuests.Count; ++index1)
            {
                Quest requireItemsQuest = this.m_RequireItemsQuests[index1];
                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableItems.Length; ++index2)
                {
                    Asda2ItemStackDescription collectableItem = requireItemsQuest.Template.CollectableItems[index2];
                    if (collectableItem.ItemId == item.Template.ItemId)
                    {
                        int  collectedItem = requireItemsQuest.CollectedItems[index2];
                        int  num           = collectedItem + delta;
                        bool flag          = collectedItem < collectableItem.Amount || num < collectableItem.Amount;
                        requireItemsQuest.CollectedItems[index2] = num;
                        if (flag)
                        {
                            QuestHandler.SendUpdateItems(item.Template.ItemId, delta, this.m_Owner);
                            requireItemsQuest.UpdateStatus();
                            break;
                        }

                        break;
                    }
                }

                for (int index2 = 0; index2 < requireItemsQuest.Template.CollectableSourceItems.Length; ++index2)
                {
                    Asda2ItemStackDescription collectableSourceItem =
                        requireItemsQuest.Template.CollectableSourceItems[index2];
                    if (collectableSourceItem.ItemId == item.Template.ItemId)
                    {
                        int  collectedSourceItem = requireItemsQuest.CollectedSourceItems[index2];
                        int  num  = collectedSourceItem + delta;
                        bool flag = collectedSourceItem < collectableSourceItem.Amount ||
                                    num < collectableSourceItem.Amount;
                        requireItemsQuest.CollectedSourceItems[index2] = num;
                        if (flag)
                        {
                            QuestHandler.SendUpdateItems(item.Template.ItemId, delta, this.m_Owner);
                            requireItemsQuest.UpdateStatus();
                            break;
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Is called when the owner of this QuestLog receives or looses the given amount of Items
        /// </summary>
        /// <param name="item"></param>
        internal void OnItemAmountChanged(Item item, int delta)
        {
            for (var j = 0; j < m_RequireItemsQuests.Count; j++)
            {
                var quest = m_RequireItemsQuests[j];
                for (var i = 0; i < quest.Template.CollectableItems.Length; i++)
                {
                    var requiredItem = quest.Template.CollectableItems[i];
                    if (requiredItem.ItemId == item.Template.ItemId)
                    {
                        var amount    = quest.CollectedItems[i];
                        var newAmount = amount + delta;

                        var needsUpdate = amount < requiredItem.Amount || newAmount < requiredItem.Amount;

                        quest.CollectedItems[i] = newAmount;
                        if (needsUpdate)
                        {
                            QuestHandler.SendUpdateItems(item.Template.ItemId, delta, m_Owner);
                            quest.UpdateStatus();
                        }
                        break;
                    }
                }
                for (var i = 0; i < quest.Template.CollectableSourceItems.Length; i++)
                {
                    var requiredItem = quest.Template.CollectableSourceItems[i];
                    if (requiredItem.ItemId == item.Template.ItemId)
                    {
                        var amount    = quest.CollectedSourceItems[i];
                        var newAmount = amount + delta;

                        var needsUpdate = amount < requiredItem.Amount || newAmount < requiredItem.Amount;

                        quest.CollectedSourceItems[i] = newAmount;
                        if (needsUpdate)
                        {
                            QuestHandler.SendUpdateItems(item.Template.ItemId, delta, m_Owner);
                            quest.UpdateStatus();
                        }
                        break;
                    }
                }
            }
        }