Ejemplo n.º 1
0
        static void Main()
        {
            Weapon weapon = new Weapon(20, 10);
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100, weapon);

            List <Warrior> warriors = new List <Warrior>();

            warriors.Add(new Warrior("Ulfric Stormcloak", 80, 80));
            warriors.Add(new Warrior("Cicero", 15, 50));
            warriors.Add(new Warrior("Jarl Balgruuf", 40, 30));

            dragon.Attach(warriors[0]);
            dragon.Attach(warriors[1]);

            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;

            foreach (var warrior in warriors)
            {
                Console.WriteLine(warrior);
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100);
            
            List<Warrior> warriors = new List<Warrior>();
            warriors.Add(new Warrior("Ulfric Stormcloak", 80, 80));
            warriors.Add(new Warrior("Cicero", 15, 50));
            warriors.Add(new Warrior("Jarl Balgruuf", 40, 30));

            foreach (var warrior in warriors)
            {
                dragon.Attach(warrior);
            }

            var war = warriors.First();
            Console.WriteLine(war.Inventory.FirstOrDefault());
            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;

            Console.WriteLine(war.Inventory.First());
        }
Ejemplo n.º 3
0
        static void Main()
        {
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100);

            List<Warrior> warriors = new List<Warrior>();
            warriors.Add(new Warrior("Ulfric Stormcloak", 80, 80));
            warriors.Add(new Warrior("Cicero", 15, 50));
            warriors.Add(new Warrior("Jarl Balgruuf", 40, 30));

            foreach (var warrior in warriors)
            {
                dragon.Attach(warrior);
            }

            var war = warriors.First();
            Console.WriteLine(war.Inventory.FirstOrDefault());
            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;

            Console.WriteLine(war.Inventory.First());
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100);

            List <Warrior> warriors = new List <Warrior>();

            warriors.Add(new Warrior("Ulfric Stormcloak", 80, 80));
            warriors.Add(new Warrior("Cicero", 15, 50));
            warriors.Add(new Warrior("Jarl Balgruuf", 40, 30));

            dragon.OnDragonDeath += (sender, args) =>
            {
                foreach (var warrior in warriors)
                {
                    warrior.Update(new Weapon(10, 10));
                }
            };

            foreach (var warrior in warriors)
            {
                dragon.Attach(warrior);
            }

            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;

            Console.WriteLine(warriors[0].AttackPoints);
            Console.WriteLine(warriors[0].HealthPoints);
            Console.WriteLine(warriors[1].AttackPoints);
            Console.WriteLine(warriors[1].HealthPoints);
            Console.WriteLine(warriors[2].AttackPoints);
            Console.WriteLine(warriors[2].HealthPoints);
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100);

            List<Warrior> warriors = new List<Warrior>();
            warriors.Add(new Warrior("Ulfric Stormcloak", 80, 80));
            warriors.Add(new Warrior("Cicero", 15, 50));
            warriors.Add(new Warrior("Jarl Balgruuf", 40, 30));

            dragon.OnDragonDeath += (sender, args) =>
            {
                foreach (var warrior in warriors)
                {
                    warrior.Update(new Weapon(10, 10));
                }
            };

            foreach (var warrior in warriors)
            {
                dragon.Attach(warrior);
            }

            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;

            Console.WriteLine(warriors[0].AttackPoints);
            Console.WriteLine(warriors[0].HealthPoints);
            Console.WriteLine(warriors[1].AttackPoints);
            Console.WriteLine(warriors[1].HealthPoints);
            Console.WriteLine(warriors[2].AttackPoints);
            Console.WriteLine(warriors[2].HealthPoints);
        }
Ejemplo n.º 6
0
        static void Main()
        {
            // Dragon with 100 HP
            var dragon = new Dragon("Alduin", 300, 100);

            List<Warrior> warriors = new List<Warrior>
            {
                new Warrior("Ulfric Stormcloak", 80, 80),
                new Warrior("Cicero", 15, 50),
                new Warrior("Jarl Balgruuf", 40, 30)
            };

            foreach (var warrior in warriors)
            {
                dragon.Attach(warrior);
            }

            // Nothing happens
            dragon.HealthPoints -= 20;
            // Nothing happens
            dragon.HealthPoints -= 10;
            // Dragon dies
            dragon.HealthPoints -= 90;
        }