예제 #1
0
        static void Main(string[] args)
        {
            var ork = new Ork();

            ork.SetStrategy(new StrategyWalk());
            ork.Move();

            Console.WriteLine();

            var troll = new Troll();

            troll.SetStrategy(new StrategyWalk());
            troll.Move();

            Console.WriteLine();

            var pegas = new Pegas();

            pegas.SetStrategy(new StrategyFlyAndWalk());
            pegas.Move();

            Console.WriteLine();

            var elf = new Elf();

            elf.SetStrategy(new StrategyMagic());
            elf.Move();

            Console.WriteLine();

            var vampire = new Vampire();

            vampire.SetStrategy(new StrategyFlyAndWalk());
            vampire.Move();

            Console.WriteLine();

            var harp = new Harp();

            harp.SetStrategy(new StrategyFlyAndWalk());
            harp.Move();

            Console.WriteLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            // init
            Console.WriteLine("Adventure Castle Game v1.0");

            Character king   = new King();
            Character queen  = new Queen();
            Character knight = new Knight();
            Character troll  = new Troll();

            king.Display();
            king.Fight();

            queen.Display();
            queen.Fight();

            knight.Display();
            knight.Fight();

            troll.Display();
            troll.Fight();

            Console.WriteLine();

            // change weapon
            king.Display();
            king.SetWeapon(new BowAndArrowBehavior());
            king.Fight();

            queen.Display();
            queen.SetWeapon(new KnifeBehavior());
            queen.Fight();

            knight.Display();
            knight.SetWeapon(new AxeBehavior());
            knight.Fight();

            troll.Display();
            troll.SetWeapon(new SwordBehavior());
            troll.Fight();

            Console.WriteLine("End fight");
        }