// -------------------------------------------------------------------------------
        // GetEquipped
        // -------------------------------------------------------------------------------
        public TemplateEquipment GetEquipped(TemplateMetaEquipmentSlot t, CharacterBase target)
        {
            InstanceEquipment tmp = Equipment.FirstOrDefault(x => x.IsEquipped && x.template.equipmentType == t && x.character == target);

            if (tmp == null)
            {
                return(null);
            }
            return(tmp.template);
        }
        // -------------------------------------------------------------------------------
        // UnequipItem
        // -------------------------------------------------------------------------------
        public void UnequipItem(InstanceEquipment item, CharacterBase target)
        {
            int index = Equipment.FindIndex(x => x.template == item.template && x.character == target);

            if (index != -1)
            {
                target.InflictBuffs(Equipment[index].template.equipBuffType, 0, true, true);
                Equipment[index].character = null;
            }
        }
        // -------------------------------------------------------------------------------
        // AddEquipment
        // -------------------------------------------------------------------------------
        public void AddEquipment(TemplateEquipment tmpl)
        {
            InstanceEquipment newEquip = new InstanceEquipment
            {
                template  = tmpl,
                character = null,
                Level     = 0
            };

            Equipment.Add(newEquip);
        }
        // -------------------------------------------------------------------------------
        // EquipItem
        // -------------------------------------------------------------------------------
        public void EquipItem(InstanceEquipment item, CharacterBase target)
        {
            if (GetEquipped(item.template.equipmentType, target) != null)
            {
                return;
            }

            int index = Equipment.FindIndex(x => x.template.equipmentType == item.template.equipmentType && !x.IsEquipped);

            if (index != -1)
            {
                Equipment[index].character = target;
                target.InflictBuffs(Equipment[index].template.equipBuffType, 0, true);
            }
        }
Beispiel #5
0
        // -------------------------------------------------------------------------------
        // EquipRequestHandler
        // -------------------------------------------------------------------------------
        protected void EquipRequestHandler()
        {
            CharacterBase     target = Finder.ui.GetFirstSelectedCharacter();
            InstanceEquipment equip  = (InstanceEquipment)selectedSlot;

            if (!equip.template.CanEquip(target))
            {
                Finder.audio.PlaySFX(SFX.ButtonCancel);
                Finder.log.Add(target.Name + " " + Finder.txt.basicVocabulary.requirementsNotMet + " " + equip.name);
                return;
            }

            Finder.audio.PlaySFX(SFX.Equip);
            Finder.party.equipment.EquipItem(equip, target);

            target.CalculateDerivedStats();
        }
Beispiel #6
0
        // -------------------------------------------------------------------------------
        // SellHandlerEquipment
        // -------------------------------------------------------------------------------
        protected void SellHandlerEquipment(InventorySlot selectedSlot)
        {
            InstanceEquipment equip = (InstanceEquipment)selectedSlot;

            if (equip.template.tradeCost.sellValue == 0)
            {
                Finder.audio.PlaySFX(SFX.ButtonCancel);
                Finder.log.Add(Finder.txt.basicVocabulary.cannotSell);
                return;
            }

            Finder.audio.PlaySFX(SFX.Sell);

            Finder.party.equipment.Equipment.Remove(equip);
            content.Remove(selectedSlot);
            Finder.party.currencies.setResource(parent.shop.currencyType, equip.template.tradeCost.sellValue);

            Finder.log.Add(string.Format("{0} " + Finder.txt.basicVocabulary.soldFor + " {1} " + Finder.txt.getCurrencyName(parent.shop.currencyType), equip.template.name, equip.template.tradeCost.sellValue));
        }
Beispiel #7
0
        // -------------------------------------------------------------------------------
        // TrashConfirmedHandler
        // -------------------------------------------------------------------------------
        protected override void TrashConfirmedHandler()
        {
            if (selectedSlot != null)
            {
                if (selectedSlot is InstanceEquipment)
                {
                    InstanceEquipment equip = (InstanceEquipment)selectedSlot;
                    Finder.party.equipment.Equipment.Remove(equip);
                    content.Remove(selectedSlot);
                }
                else if (selectedSlot is InstanceItem)
                {
                    InstanceItem item = (InstanceItem)selectedSlot;
                    Finder.party.inventory.Items.Remove(item);
                    content.Remove(selectedSlot);
                }

                selectedSlot = null;
                Refresh();
            }
        }
Beispiel #8
0
        // -------------------------------------------------------------------------------
        // getCanUseType
        // -------------------------------------------------------------------------------
        public static void DropLoot(List <LootDrop> lootdrop)
        {
            List <InventorySlot> lootList;

            lootList = new List <InventorySlot>();

            InventorySlot tmpl = null;

            bool uniqueDrop = false;

            int quantity = 0;

            int[] resourceCount = new int[Enum.GetNames(typeof(CurrencyType)).Length];

            if (lootdrop != null)
            {
                foreach (LootDrop loot in lootdrop)
                {
                    if (
                        UnityEngine.Random.value <= loot.dropChance &&
                        (!loot.useAcquisitionRules ||
                         (loot.useAcquisitionRules &&
                          (loot.lootObject.PartyClassRequirementsMet || !loot.useClassRequirementRules) &&
                          (loot.lootObject.PartyStatRequirementsMet || !loot.useStatRequirementRules) &&
                          (loot.lootObject.AcquisitionRequirementsMet || !loot.useAcquisitionRules)
                         )))
                    {
                        if (loot.minQuantity > 0 && loot.maxQuantity > 0)
                        {
                            quantity = UnityEngine.Random.Range(loot.minQuantity, loot.maxQuantity);
                        }
                        else
                        {
                            quantity = Math.Max(loot.minQuantity, loot.maxQuantity);
                            if (quantity <= 0)
                            {
                                quantity = 1;
                            }
                        }

                        if (loot.lootObject is TemplateResource && (loot.uniqueDrop == false || uniqueDrop == false))
                        {
                            if (quantity > 0)
                            {
                                Finder.party.currencies.setResource(((TemplateResource)loot.lootObject).currencyType, quantity);
                                resourceCount[(int)((TemplateResource)loot.lootObject).currencyType] += quantity;
                                uniqueDrop = loot.uniqueDrop;
                            }
                        }
                        else if (loot.lootObject is TemplateEquipment && (loot.uniqueDrop == false || uniqueDrop == false))
                        {
                            TemplateEquipment obj = (TemplateEquipment)loot.lootObject;
                            Finder.party.equipment.AddEquipment(obj);

                            tmpl = new InstanceEquipment {
                                template = obj
                            };
                            lootList.Add(tmpl);

                            uniqueDrop = loot.uniqueDrop;
                        }
                        else if (loot.lootObject is TemplateItem && (loot.uniqueDrop == false || uniqueDrop == false))
                        {
                            TemplateItem obj = (TemplateItem)loot.lootObject;
                            Finder.party.inventory.AddItem(obj, quantity);

                            tmpl = new InstanceItem {
                                template = obj, Quantity = quantity
                            };
                            lootList.Add(tmpl);

                            uniqueDrop = loot.uniqueDrop;
                        }
                    }
                }

                int i = 0;

                foreach (int value in resourceCount)
                {
                    if (value > 0)
                    {
                        tmpl = new InstanceResource {
                            currencyType = (CurrencyType)i, Quantity = value
                        };
                        lootList.Add(tmpl);
                    }
                    i++;
                }
            }

            if (lootList.Count > 0)
            {
                lootList.Sort((x, y) => y.Quantity.CompareTo(x.Quantity));
            }
            Finder.loot.Show(lootList);
        }