public IEnumerable <FrameworkElement> CreatePrintView(IGear gear) { var grid = CreateGrid(string.IsNullOrEmpty(gear.Description) ? 1 : 2); var name = CreateObjectName(gear.Name.Trim() + " (" + gear.GearType.ToString() + ")"); Grid.SetRow(name, 0); grid.Children.Add(name); if (!string.IsNullOrWhiteSpace(gear.Description)) { var description = new TextBlock { Text = gear.Description.Trim(), TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 0) }; Grid.SetRow(description, 1); grid.Children.Add(description); } DoMeasure(grid); return(new List <FrameworkElement> { grid }); }
/// <summary> /// Runs the attack action. /// </summary> public void Run(Battle battle, Character character) { // Display that the attack is happening. Console.WriteLine($"{character.Name} used {_attack.Name} on {_target.Name}."); // Get the attack's damage for this specific attack and deal it out to the target. AttackData data = _attack.Create(); _target.HP -= data.Damage; // Display that the damage has been dealt and where the character's HP is at now. Console.WriteLine($"{_attack.Name} dealt {data.Damage} damage to {_target.Name}."); Console.WriteLine($"{_target.Name} is now at {_target.HP}/{_target.MaxHP} HP."); // If the target dies because of the attack, remove it from the party and tell the user. if (!_target.IsAlive) { battle.GetPartyFor(_target).Characters.Remove(_target); Console.WriteLine($"{_target.Name} was defeated!"); if (_target.EquippedGear != null) { IGear acquiredGear = _target.EquippedGear; battle.GetPartyFor(character).Gear.Add(acquiredGear); ColoredConsole.WriteLine($"{character.Name}'s party has recovered {_target.Name}'s {acquiredGear.Name}.", ConsoleColor.Magenta); } } }
private void OnItemAdded(IGear item) { if (ItemAdded != null) { ItemAdded(this, new InventoryEventArgs(item, this)); } }
/// <summary> /// Runs the attack action. /// </summary> public void Run(Battle battle, Character character) { // Display that the attack is happening. Console.WriteLine($"{character.Name} used {_attack.Name} on {_target.Name}."); // Get the attack's damage for this specific attack and deal it out to the target. AttackData data = _attack.Create(); // Some attacks could miss. Check to see if this attack missed the target. If it did, tell the user and be done. if (_random.NextDouble() > data.ProbabilityOfHitting) { ColoredConsole.WriteLine($"{character.Name} MISSED!", ConsoleColor.DarkRed); return; } _target.HP -= data.Damage; // Display that the damage has been dealt and where the character's HP is at now. Console.WriteLine($"{_attack.Name} dealt {data.Damage} damage to {_target.Name}."); Console.WriteLine($"{_target.Name} is now at {_target.HP}/{_target.MaxHP} HP."); // If the target dies because of the attack, remove it from the party and tell the user. if (!_target.IsAlive) { battle.GetPartyFor(_target).Characters.Remove(_target); Console.WriteLine($"{_target.Name} was defeated!"); if (_target.EquippedGear != null) { IGear acquiredGear = _target.EquippedGear; battle.GetPartyFor(character).Gear.Add(acquiredGear); ColoredConsole.WriteLine($"{character.Name}'s party has recovered {_target.Name}'s {acquiredGear.Name}.", ConsoleColor.Magenta); } } }
public Car(IEngine engine, IGear gear, ITransmition transmition, IControl stwheel, IWheel wheel, IFuel pet) { this.Engine = engine; this.Transmition = transmition; this.Gear = gear; this.Stwheel = stwheel; this.Wheel = wheel; this.Fuel = pet; }
private List <MenuChoice> CreateMenuOptions(Battle battle, Character character) { Party currentParty = battle.GetPartyFor(character); Party otherParty = battle.GetEnemyPartyFor(character); List <MenuChoice> menuChoices = new List <MenuChoice>(); if (character.EquippedGear != null) { IGear gear = character.EquippedGear; IAttack specialAttack = gear.Attack; if (otherParty.Characters.Count > 0) { menuChoices.Add(new MenuChoice($"Special Attack ({specialAttack.Name} with {gear.Name})", new AttackAction(specialAttack, otherParty.Characters[0]))); } else { menuChoices.Add(new MenuChoice($"Special Attack ({specialAttack.Name} with {gear.Name})", null)); } } // Add the standard attack as an option. if (otherParty.Characters.Count > 0) { menuChoices.Add(new MenuChoice($"Standard Attack ({character.StandardAttack.Name})", new AttackAction(character.StandardAttack, otherParty.Characters[0]))); } else { menuChoices.Add(new MenuChoice($"Standard Attack ({character.StandardAttack.Name})", null)); } // Add using the potion as an item as an option. if (currentParty.Items.Count > 0) { menuChoices.Add(new MenuChoice($"Use Potion ({currentParty.Items.Count})", new UseItemAction(currentParty.Items[0]))); } else { menuChoices.Add(new MenuChoice($"Use Potion (0)", null)); } // Give the player the option to equip any gear in the party inventory. foreach (IGear gear in currentParty.Gear) { menuChoices.Add(new MenuChoice($"Equip {gear.Name}", new EquipGearAction(gear))); } // Add doing nothing as an option. menuChoices.Add(new MenuChoice("Do Nothing", new DoNothingAction())); return(menuChoices); }
private void EquipGear(IGear item) { if (CharacterManager.UniqueSlots.Contains(item.SlotType)) { var foundItemInEquipped = EquippedGear.OfType <IGear>().Any(x => x.SlotType == item.SlotType); if (foundItemInEquipped) { EquippedGear = CharacterManager.NoLongerEquippedBySlotType(item.SlotType, EquippedGear); } } item.Equipped = true; EquippedGear.Add(item); }
public void Initialize(ComponentContainer components) { if (Randomly.TrueFalse()) { bondedFamiliar = this.familiars.ChooseOne(); components.Add(bondedFamiliar); } else { bondedItem = this.items.ChooseOne(); components.Get <Inventory>().EquipItem(bondedItem); } }
static List <ICharacter> CreateGoblins(int Amount = 1) { List <ICharacter> returnChars = new List <ICharacter>(); Random rMoney = new Random(); for (int i = 0; i < Amount; i++) { ICharacter goblin = CharacterFactory.CreateCharacter(new PlayerCharacter { Name = "Goblin_" + (i + 1), Level = rMoney.Next(1, 3), ClassType = ClassType.Fighter, RaceType = RaceType.Human, RandomizeStats = true, CoinPurse = { Gold = rMoney.Next(0, 2), Copper = rMoney.Next(0, 100), Silver = rMoney.Next(0, 100), } }); //goblin.CreateCharacter(); IWeapon sword = EquipmentFactory.CreateWeapon(new Weapon { Name = "Rusty Sword", AttackType = WeaponAttackType.S, Category = WeaponCategory.ShortSword, Price = { Silver = 12 }, Damage = { SidedDie = 6 }, SlotType = EquipmentSlot.PRIMARY, Size = WeaponSize.S }); IGear LeatherChest = EquipmentFactory.CreateGear(new Gear { Name = "Leather Chest Piece", AC = 9, EquipmentType = EquipmentType.Clothing, Price = { Silver = 50 }, SlotType = EquipmentSlot.CHEST }); goblin.AddItem(LeatherChest, 1); goblin.AddItem(sword, 1); goblin.EquipItem(sword); goblin.EquipItem(LeatherChest); returnChars.Add(goblin); } return(returnChars); }
/// <summary> /// Adds the gear to the character. /// </summary> /// <param name="equip">Equipment to add.</param> public Possession AddGear(IGear equip) { var possession = Find(equip); if (possession == null) { possession = new Possession(equip); this.gear.Add(possession); } else { possession.IncrementQuantity(); } OnItemAdded(equip); return(possession); }
public Track() { InitializeComponent(); Hep = new HH(Mov); engine = new Engine(5); stwheel = new StWheel(); transmition = new Transmition(); wheel = new Wheel(); gear = new Gear(); petrol = new PetrolTank(); ChangeSpeed.DataSource = Enum.GetValues(typeof(Multiplication)); ChangeSpeed.SelectedText = Multiplication.one.ToString(); //Спросить за гибкость в данной модели car = new NormalCar(engine, gear, transmition, stwheel, wheel, petrol); runcar = new Thread(Moved); OffEngine.Enabled = false; //все изменения и функционал мы берем не напрямую через компоненты а через объекта класса Car //форма Track ничего не знает о компонентах машины, хоть и объекты создаються тут }
public GearHandler(IGear gear) { _gear = gear; }
public void Purchase(IGear item) { CoinPurse.Spend(item.Value); AddGear(item); }
public Possession Find(IGear item) { return(this.gear.FirstOrDefault(x => x.ReferenceObject == item)); }
public void replaceGear(string location, IGear newGear, out IGear oldGear) { oldGear = _gearSet[location]; _gearSet.Remove(location); _gearSet.Add(location, newGear); }
/// <summary> /// Equips the item. /// </summary> /// <param name="item">Item to equip. Adds gear if not already added</param> public void EquipItem(IGear item) { var pos = this.AddGear(item); pos.IsEquipped = true; }
public InventoryEventArgs(IGear item, Inventory inventory) { this.Item = item; this.Inventory = inventory; this.GearType = item.GetType(); }
public Player(IPlayableClass playerClass, IRace race, string name, IInventory inventory, IHealthInfo healthInfo, IGear equippedItems, ILevelInfo levelInfo) { this.Class = playerClass; this.Race = race; this.Name = name; this.Inventory = inventory; this.HealthInfo = healthInfo; this.EquippedItems = equippedItems; this.LevelInfo = levelInfo; }
public void SellItem(IGear item) { inventory.Remove(item); }
public void addGear(IGear gear) { this.gear.Add(gear); this.sortedInventory.Add(gear); }
public EquipGearAction(IGear gear) => _gear = gear;
static ICharacter CreateMainCharacter(string characterName) { ICharacter Character = CharacterFactory.CreateCharacter(new PlayerCharacter { Name = characterName, Level = 1, RaceType = RaceType.Human, ClassType = ClassType.Fighter, MainCharacter = true, RandomizeStats = true, OwnerName = "Jonathan Favorite" }); IWeapon Sword = EquipmentFactory.CreateWeapon(new Weapon { Name = "Testing Sword (One hand)", AttackType = WeaponAttackType.S, Category = WeaponCategory.BastardSwordOneHanded, TwoHanded = false, Price = { Gold = 1, Silver = 50 }, Damage = { Amount = 1, SidedDie = 8, Bonus = 1 }, Weareable = true, SlotType = EquipmentSlot.PRIMARY }); IGear Shield = EquipmentFactory.CreateGear(new Gear { Name = "Testing Shield", ArmorType = ArmorTypeList.Shield, SlotType = EquipmentSlot.SECONDARY, AC = 0, StatMods = { new StatModifier { Modifier = ItemBonusList.AC, Value = 2 } } }); IGear Head = EquipmentFactory.CreateGear(new Gear { Name = "Testing Head", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Silver = 50 }, SlotType = EquipmentSlot.HEAD, ArmorType = ArmorTypeList.ChainMail, }); IGear NewHead = EquipmentFactory.CreateGear(new Gear { Name = "Testing Head #1", AC = 1, EquipmentType = EquipmentType.Clothing, Price = { Silver = 50 }, SlotType = EquipmentSlot.HEAD, ArmorType = ArmorTypeList.PlateMail, }); IGear Shoulder = EquipmentFactory.CreateGear(new Gear { Name = "Testing Shoulder", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.SHOULDER, ArmorType = ArmorTypeList.Leather }); IGear Chest = EquipmentFactory.CreateGear(new Gear { Name = "Testing Chest", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.CHEST, ArmorType = ArmorTypeList.Leather }); IGear Wrists = EquipmentFactory.CreateGear(new Gear { Name = "Testing Wrist", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.WRIST, ArmorType = ArmorTypeList.Leather }); IGear Hands = EquipmentFactory.CreateGear(new Gear { Name = "Testing Hands", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.HANDS, ArmorType = ArmorTypeList.Leather }); IGear Legs = EquipmentFactory.CreateGear(new Gear { Name = "Testing Legs", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.LEGS, ArmorType = ArmorTypeList.Leather }); IGear Feet = EquipmentFactory.CreateGear(new Gear { Name = "Testing Feet", AC = 6, EquipmentType = EquipmentType.Clothing, Price = { Gold = 123 }, SlotType = EquipmentSlot.FEET, ArmorType = ArmorTypeList.Leather }); Character.AddItem(Head, 1); Character.AddItem(NewHead, 1); Character.AddItem(Shoulder, 1); Character.AddItem(Chest, 1); Character.AddItem(Wrists, 1); Character.AddItem(Hands, 1); Character.AddItem(Legs, 1); Character.AddItem(Feet, 1); Character.AddItem(Sword, 1); Character.AddItem(Shield, 1); Character.EquipItem(Head); Character.EquipItem(NewHead); Character.EquipItem(Shoulder); Character.EquipItem(Chest); Character.EquipItem(Wrists); Character.EquipItem(Hands); Character.EquipItem(Legs); Character.EquipItem(Feet); Character.EquipItem(Sword); Character.EquipItem(Shield); ISpell MagicMissle = SpellFactory.CreateSpell(new Spell { SpellID = "magic_missles_level_1", Name = "Magic Missle", Level = 1, School = { SpellSchool.Evocation }, Range = { RangeType = SpellRangeType.Yards, yards = 60 }, Compontents = { SpellCompontents.V, SpellCompontents.S }, Duration = new SpellDurationInfo { DurationType = SpellDurationType.Instantaneous }, CastingTime = 1, Classes = { ClassType.Wizard }, AOE = new AreaOfEffect { Type = AOETypes.CUBE, AOESize = 10, Ruler = RulerTypes.Feet }, SavingThrows = { SavingThrowType.None }, Description = "Use of magic missles spell creates up to five missles of magical energy that dart forth from the wizard's fingertip and unerringly strike their target. This includes enemy creatures in a melee." }); Character.AddSpell(MagicMissle); return(Character); }
public static IGear CreateGear(IGear gear) { gear.CreateItem(); return(gear); }
public Possession(IGear gear) { ReferenceObject = gear; Quantity = 1; }
public NormalCar(IEngine engine, IGear gear, ITransmition transmition, IControl stwheel, IWheel wheel, IFuel pet) : base(engine, gear, transmition, stwheel, wheel, pet) { }