コード例 #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);
            }
        }
コード例 #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());
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: peterkirilov/SoftUni-1
        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());
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: 0000duck/Fundamental-Level
        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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: AsenTahchiyski/SoftUni
        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;
        }