コード例 #1
0
 public void Update(double deltaSec)
 {
     foreach (var system in LogicSystems)
     {
         if (system.IsEnabled)
         {
             system.Update(deltaSec);
             CommandRecorder.Execute(World);
         }
     }
 }
コード例 #2
0
        public static void Main(string[] args)
        {
            const string path            = @"C:\Users\Vlad\Documents\Rider Projects\Interpreter\Interpreter\1.am";
            var          text            = File.ReadAllText(path);
            var          lexer           = new Lexer(text);
            var          parser          = new Parser(lexer);
            var          commandRecorder = new CommandRecorder();
            var          vm = new VirtualMachine(parser, commandRecorder);

            var interpreter = new Performers.Interpreter(lexer, parser, vm);

            interpreter.Run();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            ICommandRecorder    commandRecorder     = new CommandRecorder();
            RobotCommandHandler robotCammandHandler = new RobotCommandHandler(commandRecorder);
            RobotCommandType    drawingCommand      = RobotCommandType.None;

            Console.WriteLine("Welcome to the Mock Robot Interface:");
            Console.WriteLine("'Move' command will move Robot A. Syntax: M <Distance in Decimal number> Example: M 10.3");
            Console.WriteLine("'Turn' command will Turn Robot A. Syntax: T <Angle in Decimal number> Eg: T 45.8");
            Console.WriteLine("'Beep' command will Beep Robot A. Syntax: B");
            Console.WriteLine("'Replay' command will replay all the past commands sent to Robot A on Robot B. Syntax: R");
            Console.WriteLine("'Quit' command syntax not matched. Syntax: Q");
            do
            {
                IRobot robotA = new MockRobotA();
                IRobot robotB = new MockRobotB();
                IRobot robot;
                try
                {
                    Console.Write("Enter Command: ");
                    var commandStr = Console.ReadLine();
                    if (commandStr != null && commandStr.Trim().ToUpper() == "R")
                    {
                        robot = robotB;
                    }
                    else
                    {
                        robot = robotA;
                    }

                    drawingCommand = RobotCommandType.None;
                    try
                    {
                        drawingCommand = robotCammandHandler.Run(robot, commandStr);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            } while (drawingCommand != RobotCommandType.Quit);
            Console.WriteLine("Press a key to Quit");
            Console.ReadKey();
        }
コード例 #4
0
        protected override void InnerExecute(RobotCommandEventArgs robotCommandEventArgs)
        {
            var replayCommands = CommandRecorder.Replay();

            foreach (var command in replayCommands)
            {
                try
                {
                    _robotCommandHandler.Run(robotCommandEventArgs.Robot, command);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
コード例 #5
0
        public void Update(double deltaSec)
        {
            foreach (var system in PreLogicSystems)
            {
                var stopwatch = Stopwatch.StartNew();
                if (system.IsEnabled)
                {
                    system.PreUpdate(deltaSec);
                    CommandRecorder.Execute(World);
                }
                stopwatch.Stop();
                if (stopwatch.Elapsed.TotalMilliseconds > 1)
                {
                    Utilties.Logging.Metrics.LogMetric($"LogicSystems:{system.GetType().Name}:Time", stopwatch.Elapsed.TotalMilliseconds, TimeSpan.FromSeconds(5));
                }
            }

            foreach (var system in LogicSystems)
            {
                var stopwatch = Stopwatch.StartNew();
                if (system.IsEnabled)
                {
                    system.Update(deltaSec);
                    CommandRecorder.Execute(World);
                }
                stopwatch.Stop();
                if (stopwatch.Elapsed.TotalMilliseconds > 1)
                {
                    Utilties.Logging.Metrics.LogMetric($"LogicSystems:{system.GetType().Name}:Time", stopwatch.Elapsed.TotalMilliseconds, TimeSpan.FromSeconds(5));
                }
            }

            foreach (var system in PostLogicSystems)
            {
                var stopwatch = Stopwatch.StartNew();
                if (system.IsEnabled)
                {
                    system.PostUpdate(deltaSec);
                    CommandRecorder.Execute(World);
                }
                stopwatch.Stop();
                if (stopwatch.Elapsed.TotalMilliseconds > 1)
                {
                    Utilties.Logging.Metrics.LogMetric($"LogicSystems:{system.GetType().Name}:Time", stopwatch.Elapsed.TotalMilliseconds, TimeSpan.FromSeconds(5));
                }
            }
        }
コード例 #6
0
ファイル: SampleApplication.cs プロジェクト: AximoGames/AxGui
        protected override void OnRenderFrame(FrameEventArgs args)
        {
            GL.Viewport(0, 0, ClientSize.X, ClientSize.Y);
            GL.ClearColor(Color4.Beige);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            using (new SKAutoCanvasRestore(surface.Canvas, true))
            {
                // We've modified opengl state, so let's reset
                grContext.ResetContext();

                var canvas = surface.Canvas;
                canvas.Clear(new SKColor(128, 0, 128));
                //canvas.Translate(20, 20);
                //Paint.Color = new SKColor(0, 0, 200);
                //Paint.TextSize = 64;
                //canvas.DrawText("Hello", 0, 64, Paint);
                //canvas.DrawRect(0, 0, 100, 100, Paint);

                var el = new Element();
                el.Data = "root";

                el.Style.Display     = StyleDisplay.Block;
                el.Style.Position    = StylePosition.Absolute;
                el.Style.Height      = 320;
                el.Style.Width       = 220;
                el.Style.BorderWidth = 5;
                el.Style.Padding     = 5;

                Element child;
                Element box;

                var box1 = box = new Element();
                box.Data           = "b1";
                box.Style.Display  = StyleDisplay.Block;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child1 = child = new TextElement();
                child.Data                      = "child";
                child.Style.Width               = 5;
                child.Style.Height              = 30;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck Testduck2 Testduck3";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var box2 = box = new Element();
                box.Data           = "b1";
                box.Style.Display  = StyleDisplay.InlineBlock;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child2 = child = new TextElement();
                child.Data                      = "child2";
                child.Style.Width               = 5;
                child.Style.Height              = 30;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck4 Testduck5 Testduck6";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var box3 = box = new Element();
                box.Data           = "b3";
                box.Style.Display  = StyleDisplay.Block;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child3 = child = new TextElement();
                child.Data                      = "child3";
                child.Style.Height              = 30;
                child.Style.Width               = 5;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck4 Testduck5 Test|ö|└|²³|ₚ|☑|😂";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var layouter = new LayoutProcessor();
                layouter.ViewPort = new Box(0, 0, ClientSize.X, ClientSize.Y);
                //layouter.ViewPort = new Box(0, 0, ClientSize.X, 20);
                layouter.Process(el);

                var recorder = new CommandRecorder();
                recorder.Record(el);

                var executor = new CommandExecutor();
                executor.Execute(recorder, canvas);

                canvas.Flush();
            }

            //System.Threading.Thread.Sleep(500);

            SwapBuffers();

            var ticks  = FPSCounter.ElapsedTicks;
            var ms     = ticks / 10000.0;
            var newFPS = 1000f / (float)ms;

            FPSCounter.Restart();
            CurrentFPS = Smooth(CurrentFPS, newFPS, 0.01f);
            if ((DateTime.UtcNow - LastUpdatedFPS).TotalSeconds > 1)
            {
                LastUpdatedFPS = DateTime.UtcNow;
                Title          = $"FPS: {CurrentFPS.ToString("F0", CultureInfo.CurrentCulture)}";
            }
        }
コード例 #7
0
 protected override void InnerExecute(RobotCommandEventArgs robotCommandEventArgs)
 {
     CommandRecorder.Reset();
 }