public void Use(string thing) { if (String.IsNullOrWhiteSpace(thing)) { Console.WriteLine("Please select a object to use."); } else { Item item = Inventory.Find(x => x.Name.ToLower() == thing); if (item == null) { Console.WriteLine("There is no item with the name '" + thing + "' in your inventory."); } else { if (item is Weapon) { Weapon newWeapon = (Weapon)item; EquippedWeapon = newWeapon; Damage = BaseDamage + newWeapon.Damage; Console.WriteLine("You equipped " + newWeapon.Name + " as your Weapon. Your damage is now " + Damage + "."); } else if (item is Healer) { Healer healer = (Healer)item; Health += healer.Cure; if (Health >= MaxHealth) { Health = MaxHealth; } Console.WriteLine("You consumed " + healer.Name + ". You now have " + Health + " healthpoints."); } else { Console.WriteLine("You can't use this."); } } } }
public void LookAt(string thing) { if (String.IsNullOrWhiteSpace(thing)) { Console.WriteLine("Please select a Object to look at."); } else { GameObject subject = CurrentRoom.Items.Find(x => x.Name.ToLower() == thing); if (subject == null) { subject = CurrentRoom.NPCs.Find(x => x.Name.ToLower() == thing); } if (subject == null) { subject = Inventory.Find(x => x.Name.ToLower() == thing); } if (subject == null) { Console.WriteLine("There is nothing with the name '" + thing + "' in the room."); } else { Console.WriteLine(subject.Description); if (subject is Weapon) { Weapon weapon = (Weapon)subject; Console.WriteLine(weapon.Name + " can be used as a weapon and causes " + weapon.Damage + " damage."); } else if (subject is Healer) { Healer potion = (Healer)subject; Console.WriteLine(potion.Name + " can be consumed and is capable of curing " + potion.Cure + " healthpoints."); } } } }