void RoomWorker() { while (true) { try { HighResolutionTime.Start(); HandleUserMovements(); HandleRollerActions(); if (mHasPoolCam) { HandlePoolCamera(); } double numberMilli = HighResolutionTime.GetTime(); if (numberMilli < FrameTime) { Thread.Sleep(FrameTime - (int)numberMilli); } } catch (Exception e) { Logging.LogEvent("A room error occured. Stack trace: " + e.ToString(), Logging.LogLevel.Error); } } }
public void Paint() { MapReader reader = new MapReader(@"test.svg"); HighResolutionTime.Start(); if (reader.Read()) { map = reader.GetMap(new Dictionary <string, byte>()); } Console.WriteLine("Чтение карты: " + HighResolutionTime.GetTime()); BaseBmp = map.GetLayerMask(0); Graphics g = Graphics.FromImage(BaseBmp); foreach (var node in map._patensyGraph.Vertices) { g.FillRectangle(System.Drawing.Brushes.Red, node.SourceWP.X, node.SourceWP.Y, node.SourceWP.PointWidth, node.SourceWP.PointHeight); g.FillRectangle(System.Drawing.Brushes.Red, node.TargetWP.X, node.TargetWP.Y, node.TargetWP.PointWidth, node.TargetWP.PointHeight); } foreach (var edge in map._patensyGraph.Edges) { g.DrawLine(System.Drawing.Pens.Green, edge.Source.SourceWP.Center, edge.Target.SourceWP.Center); } Agents.Human.HumanManager mng = new Agents.Human.HumanManager(); //agent = mng.GetInstance(map, null, new System.Windows.Media.Media3D.Size3D(0.5, 0.3, 2.0), 1.4, 1.0, 1.0); //agent.Initialize(new System.Drawing.Point(10, 3), new List<WayPoint> { new WayPoint(300, 10), new WayPoint(154, 550), new WayPoint(630, 130) }); g.FillEllipse(System.Drawing.Brushes.Orange, 300, 10, 5, 5); g.FillEllipse(System.Drawing.Brushes.Orange, 154, 550, 5, 5); g.FillEllipse(System.Drawing.Brushes.Orange, 630, 130, 5, 5); SetMapImage(BaseBmp); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(10); timer.Tick += new EventHandler(timer_Tick); timer.Start(); }
private void PaintPanel_MouseDown(object sender, MouseButtonEventArgs e) { if (e.RightButton == MouseButtonState.Pressed) { to = new System.Drawing.Point((int)e.GetPosition((IInputElement)e.OriginalSource).X, (int)e.GetPosition((IInputElement)e.OriginalSource).Y); } else if (e.LeftButton == MouseButtonState.Pressed) { from = new System.Drawing.Point((int)e.GetPosition((IInputElement)e.OriginalSource).X, (int)e.GetPosition((IInputElement)e.OriginalSource).Y); } if (to != new System.Drawing.Point(-1, -1) && to != from) { //HighResolutionTime.Start(); var route = map.GetRoute(from, to); //Console.WriteLine("Построение маршрута: " + HighResolutionTime.GetTime()); if (route != null) { var bitmap = (Bitmap)BaseBmp.Clone(); HighResolutionTime.Start(); for (int i = 0; i < route.Count - 1; i++) { var path = map.GetWay(route[i], route[i + 1]); if (path == null) { continue; } foreach (var point in path) { bitmap.SetPixel(point.X - 1, point.Y - 1, System.Drawing.Color.Blue); } } Console.WriteLine("Построение всех путей: " + HighResolutionTime.GetTime()); SetMapImage(bitmap); } } }