// ------------------------------------------------------------------------------- // loadTemplate // ------------------------------------------------------------------------------- public override void loadTemplate() { if (string.IsNullOrEmpty(name)) { return; } template = DictionaryEquipment.Get(name); }
// ------------------------------------------------------------------------------- // AddEquipment // ------------------------------------------------------------------------------- public void AddEquipment(TemplateEquipment tmpl) { InstanceEquipment newEquip = new InstanceEquipment { template = tmpl, character = null, Level = 0 }; Equipment.Add(newEquip); }
// ------------------------------------------------------------------------------- // CanEquipItem // ------------------------------------------------------------------------------- public bool CanEquipItem(TemplateEquipment tmpl) { foreach (CharacterBase character in characters) { if (tmpl.CanEquip(character)) { return(true); } } return(false); }
// ------------------------------------------------------------------------------- // RefreshEquipment // ------------------------------------------------------------------------------- public void RefreshEquipment(TemplateEquipment tmpl) { if (tmpl is TemplateEquipmentWeapon) { contentText.text += ((TemplateEquipmentWeapon)tmpl).GetDescription(); } else { contentText.text += ((TemplateEquipment)tmpl).statModifiers.GetDescription(); } RefreshElements(tmpl.element); }
// ------------------------------------------------------------------------------- // 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); }