public void Start() { World world = new World(20, 20); world.GenerateWorld(); world.WriteWorldToConsole(); PrefabCreatures creatures = new PrefabCreatures(); var centaur = creatures.Centaur; var mage = creatures.Mage; var peasant = creatures.Peasant; ICreatureFactory creatureFactory = new CreatureFactory(); var ogre = creatureFactory.CreateCreature("Ogre", 10, 10, 50, new CustomRange(5, 10)); var vampire = creatureFactory.CreateCreature <VampiricCreature>("Vampire", 10, 5, 30, new CustomRange(3, 7)); vampire.Attach(world); ogre.Attach(world); mage.Loot(new Item("Staff", 2)); Console.WriteLine(mage); Console.WriteLine(vampire); CombatLoop(vampire, ogre); Logger.Close(); }
public void Run() { string input; int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { input = Console.ReadLine(); string[] inputArg = input.Split(); string creatureType = inputArg[0]; IBuyer creature = factory.CreateCreature(inputArg); if (creature != null) { this.buyers.Add(creature); } } input = Console.ReadLine(); while (input != "End") { IBuyer buyer = GetBuyer(input); if (buyer != null) { buyer.BuyFood(); } input = Console.ReadLine(); } int foods = this.buyers.Sum(b => b.Food); Console.WriteLine(foods); Console.ReadLine(); }
private void TEST_addStuffToWorld() { ICreature bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(9, 94), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(32, 96), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(40, 87), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(66, 86), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(46, 75), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); bat = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.GiantBat, new Vector2(76, 32), this); bat.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(bat); ICreature fireSpirit = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.FireSpirit, new Vector2(82, 23), this); fireSpirit.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(fireSpirit); ICreature manEatingPlant = CreatureFactory.CreateCreature(Creatures.Creatures.ManEatingPlant, new Vector2(53, 33), this); manEatingPlant.Death += new CreatureEvent(HandleCreatureDeath); manEatingPlant.Death += new CreatureEvent(manEatingPlant_Death); _creatures.Add(manEatingPlant); _quests.Add(QuestFactory.MakeQuest(this, manEatingPlant)); _quests[0].AnnounceQuest(); _quests[0].DoneWithQuest += new QuestEvent(World_DoneWithQuest); ICreature golem = CreatureFactory.CreateCreature(Creatures.Creatures.Golem, new Vector2(46, 24), this); golem.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(golem); ICreature skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(65, 33), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(56, 13), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(51, 12), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(63, 5), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(50, 3), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(36, 20), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(34, 13), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(41, 70), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(44, 63), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); skeleton = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.SkeletonWarrior, new Vector2(57, 58), this); skeleton.Death += new CreatureEvent(HandleCreatureDeath); _creatures.Add(skeleton); //ICreature octopus = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.Octopus, new Vector2(11, 87), this); //octopus.Death += new CreatureEvent(HandleCreatureDeath); //_creatures.Add(octopus); //octopus = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.Octopus, new Vector2(14, 94), this); //octopus.Death += new CreatureEvent(HandleCreatureDeath); //_creatures.Add(octopus); //octopus = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.Octopus, new Vector2(65, 22), this); //octopus.Death += new CreatureEvent(HandleCreatureDeath); //_creatures.Add(octopus); ICreature walkingDragon = CreatureFactory.CreateCreature(DodongosQuest.Creatures.Creatures.WalkingDragon, new Vector2(15, 92), this); walkingDragon.Death += new CreatureEvent(HandleCreatureDeath); walkingDragon.FlamingAttack += new CreatureFlameEvent(HandleFlameAttack); _creatures.Add(walkingDragon); IItem doll = ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.CursedDoll, new Vector2(68, 30), this); TreasureChest chest = new TreasureChest(new List <IItem>(), true, new Vector2(68, 30), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfBlindness, new Vector2(68, 30), this)); chest.Contents.Add(doll); _containers.Add(chest); _quests.Add(QuestFactory.MakeItemFindQuest(this, doll)); _quests[1].AnnounceQuest(); _quests[1].DoneWithQuest += new QuestEvent(World_DoneWithQuest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(53, 30), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorHealth, new Vector2(53, 30), this)); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(53, 30), this)); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.OldKey, new Vector2(53, 30), this)); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorEnergy, new Vector2(53, 30), this)); chest.Contents.Add((IItem)WeaponFactory.CreateGiantAxe(new Vector2(53, 30), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(59, 11), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(59, 11), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(53, 11), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorHealth, new Vector2(53, 11), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(17, 17), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorHealth, new Vector2(17, 17), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(66, 60), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(66, 60), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(46, 64), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(46, 64), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(47, 64), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorHealth, new Vector2(47, 64), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(70, 83), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(70, 83), this)); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.PotionOfMinorHealth, new Vector2(70, 83), this)); _containers.Add(chest); chest = new TreasureChest(new List <IItem>(), false, new Vector2(6, 94), this); chest.Contents.Add(ItemFactory.CreateItem(DodongosQuest.Items.ItemTypes.Diamond, new Vector2(6, 94), this)); _containers.Add(chest); _doors.Add(new Door(new Vector2(55, 34), false, this)); _doors.Add(new Door(new Vector2(62, 33), false, this)); _doors.Add(new Door(new Vector2(51, 16), false, this)); _doors.Add(new Door(new Vector2(57, 16), false, this)); _doors.Add(new Door(new Vector2(45, 21), false, this)); _doors.Add(new Door(new Vector2(45, 9), false, this)); _doors.Add(new Door(new Vector2(42, 6), false, this)); _doors.Add(new Door(new Vector2(30, 11), false, this)); _doors.Add(new Door(new Vector2(30, 23), false, this)); _doors.Add(new Door(new Vector2(15, 18), false, this)); _doors.Add(new Door(new Vector2(47, 73), false, this)); _doors.Add(new Door(new Vector2(49, 51), false, this)); _doors.Add(new Door(new Vector2(42, 51), false, this)); _doors.Add(new Door(new Vector2(43, 40), false, this)); _doors.Add(new Door(new Vector2(27, 44), false, this)); }