public void UseItem(GenericItems item, Target targets) { var cmd = new StatAugmentCommand(); foreach (var target in targets) { cmd.AddEffects(item.Properties,target); } cmd.RegisterCommand(); }
public void UseItem(GenericItems item, Target targets) { var cmd = new StatAugmentCommand(); var effectsResult = item.Properties.Select(effect => effect.GetInverse()).ToList(); foreach (var target in targets) { cmd.AddEffects(effectsResult, target); } cmd.RegisterCommand(); }
public override bool Use() { try { Dictionary<EnumGearSlot, Equipable> PlayerEquipedInventory = Player.GetInstance().GetEquipedInventory(); Equipable currentlyEquipedItem = PlayerEquipedInventory[Slot]; StatAugmentCommand cmd = new StatAugmentCommand(); // for each effect on current equiped item, add its inverse effect to cmd foreach (EffectInformation effect in currentlyEquipedItem.Properties) { cmd.AddEffect(effect.GetInverse(), Hero.GetInstance()); } // apply inverse cmd to character to "unequpid" item. cmd.RegisterCommand(); // remove item from equipped, add to inventory PlayerEquipedInventory.Remove(Slot); Player.GetInstance().GetInventory().AddItem(currentlyEquipedItem); // reset command cmd = new StatAugmentCommand(); //Give the properties of this gear to the hero and register cmd.AddEffects(this.Properties, Hero.GetInstance()); cmd.RegisterCommand(); // add item to equpied, remove from inventory PlayerEquipedInventory.Add(Slot, this); //Player.GetInstance().GetInventory().RemoveItem(this); } catch (Exception e) // <---- WILL CHANGE FROM GENERIC EXCEPTION { // Write error out to text file for debugging return false; } return true; }