コード例 #1
0
ファイル: GearPrinter.cs プロジェクト: polepage/L5R_NPCTool
        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
            });
        }
コード例 #2
0
    /// <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);
            }
        }
    }
コード例 #3
0
 private void OnItemAdded(IGear item)
 {
     if (ItemAdded != null)
     {
         ItemAdded(this, new InventoryEventArgs(item, this));
     }
 }
コード例 #4
0
    /// <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);
            }
        }
    }
コード例 #5
0
 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;
 }
コード例 #6
0
    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);
    }
コード例 #7
0
 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);
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
 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 ничего не знает о компонентах машины, хоть и объекты создаються тут
 }
コード例 #12
0
 public GearHandler(IGear gear)
 {
     _gear = gear;
 }
コード例 #13
0
 public void Purchase(IGear item)
 {
     CoinPurse.Spend(item.Value);
     AddGear(item);
 }
コード例 #14
0
 public Possession Find(IGear item)
 {
     return(this.gear.FirstOrDefault(x => x.ReferenceObject == item));
 }
コード例 #15
0
 public void replaceGear(string location, IGear newGear, out IGear oldGear)
 {
     oldGear = _gearSet[location];
      _gearSet.Remove(location);
      _gearSet.Add(location, newGear);
 }
コード例 #16
0
        /// <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;
        }
コード例 #17
0
 public InventoryEventArgs(IGear item, Inventory inventory)
 {
     this.Item      = item;
     this.Inventory = inventory;
     this.GearType  = item.GetType();
 }
コード例 #18
0
 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;
 }
コード例 #19
0
 public void SellItem(IGear item)
 {
     inventory.Remove(item);
 }
コード例 #20
0
ファイル: Inventory.cs プロジェクト: JARVADAHUT/DCDesign
 public void addGear(IGear gear)
 {
     this.gear.Add(gear);
     this.sortedInventory.Add(gear);
 }
コード例 #21
0
 public EquipGearAction(IGear gear) => _gear = gear;
コード例 #22
0
        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);
        }
コード例 #23
0
 public static IGear CreateGear(IGear gear)
 {
     gear.CreateItem();
     return(gear);
 }
コード例 #24
0
 public Possession(IGear gear)
 {
     ReferenceObject = gear;
     Quantity        = 1;
 }
コード例 #25
0
ファイル: NormalCar.cs プロジェクト: OlegVasilyev/CarModel
 public NormalCar(IEngine engine, IGear gear, ITransmition transmition, IControl stwheel, IWheel wheel, IFuel pet) : base(engine, gear, transmition, stwheel, wheel, pet)
 {
 }