Beispiel #1
0
        //
        //// главное меню
        //
        public static void Main(string[] args)
        {
            Game game1 = new Game();

            game1.TakingDamage += DisplayWithColor;
            game1.RecoveryHP   += DisplayWithColor;
            game1.FullHeal     += DisplayWithColor;
            game1.Death        += DisplayWithColor;
            game1.Failure      += DisplayWithColor;

            ////

            Delg1 DelegatWar  = game1.Attack;
            Delg2 DelegatArch = game1.Attack;
            Delg1 InfoWar     = game1.Info;
            Delg2 InfoArch    = game1.Info;


            ////

            /*Warrior w1 = new Warrior();
             * DelegatWar(w1);
             * InfoWar(w1);*/


            Warrior w2 = new Warrior();

            DelegatWar(w2);
            DelegatWar(w2);
            DelegatWar(w2);
            InfoWar(w2);
            DelegatWar = game1.Heal;
            DelegatWar(w2);


            Archer arch1 = new Archer();

            DelegatArch(arch1);
            InfoArch(arch1);
            DelegatArch = game1.Heal;
            DelegatArch(arch1);

            //Archer arch2 = new Archer();

            //
            //// работа со строками
            //

            Action <string> action;
            //Action<string> _out = Out;
            //Action<string> _firstWord = FirstWord;
            string value = "Добрый день";

            action  = Out;
            action += FirstWord;
            action(value);
            action -= FirstWord;
            Func <int, string, string> func;

            func  = Add;
            value = func(6, value);
            action(value);
            func  = Replace;
            value = func(1, value);
            action(value);
            func  = ToUpperCase;
            value = func(2, value);
            action(value);

            Console.ReadKey();
        }