Example #1
0
 private void Wait(Func<Behavior, Behavior> func )
 {
     while (!Console.KeyAvailable)
     {
         var behavior = new Behavior();
         Thread.Sleep(TimeSpan.FromMilliseconds(500));
         func(behavior).Execute();
     }
     Console.ReadKey(true);
 }
Example #2
0
        public Behavior UntilKeyPressed(Action<Behavior> toDo)
        {
            var copy = new Behavior();
            toDo(copy);
            Tasks.Add(() =>
            {
                while (!Console.KeyAvailable)
                {
                    copy.Execute();
                    Thread.Sleep(500);
                }
                Console.ReadKey(false);
            });

            return this;
        }
Example #3
0
        private static void Main()
        {
            var behaviour = new Behavior()
                .Say("Привет мир!")
                .UntilKeyPressed(b => b
                    .Say("Ля-ля-ля!")
                    .Say("Тру-лю-лю"))
                .Jump(JumpHeight.High)
                .UntilKeyPressed(b => b
                    .Say("Aa-a-a-a-aaaaaa!!!")
                    .Say("[набирает воздух в легкие]"))
                .Say("Ой!")
                .Delay(TimeSpan.FromSeconds(1))
                .Say("Кто здесь?!")
                .Delay(TimeSpan.FromMilliseconds(20000));

            behaviour.Execute();
        }
Example #4
0
        public Behavior UntilKeyPressed(Func<Behavior, Behavior> configurate)
        {
            act.Add(() =>
            {
                var beh = new Behavior();
                beh = configurate(beh);
                while (true)
                {

                    if (Console.KeyAvailable)
                    {
                        Console.ReadKey(intercept:false);
                        break;
                    }
                    beh.Execute();
                }

            });
            return this;
        }
Example #5
0
 public void Execute()
 {
     var behavior = new Behavior();
     SomeAction(behavior);
     while (!Console.KeyAvailable)
     {
         behavior.Execute();
     }
     while (Console.KeyAvailable)
         Console.ReadKey(true);
 }