public void Update(float deltaTime) { if (mainController == null) { mainController = Kernel.Get <MainController>(); } if (capacityController == null) { capacityController = Kernel.Get <CapacityController>(); } foreach (var vehicle in mainController.Vehicles) { float prevSpeed = vehicle.Speed; CalculateSpeed(vehicle, deltaTime); if (!vehicle.IsOnStop) { CalculatePosition(vehicle, prevSpeed, deltaTime); } if (FinishCoursePredicate(vehicle)) { vehicle.Position.Node1.VehiclesOn.Remove(vehicle); } } }
public void InitMap() { if (mainController == null) { mainController = Kernel.Get <MainController>(); } if (capacityController == null) { capacityController = Kernel.Get <CapacityController>(); } minX = mainController.Map.Min(n => n.Coordinates.X); maxX = mainController.Map.Max(n => n.Coordinates.X); minY = mainController.Map.Min(n => n.Coordinates.Y); maxY = mainController.Map.Max(n => n.Coordinates.Y); foreach (var node in mainController.Map.OrderBy(n => !n.IsUnderground)) { float pX = CalculateXPosition(node.Coordinates.X); float pY = CalculateYPosition(node.Coordinates.Y); if (node.Type != NodeType.CarCross) { vertexes.Add( DirectxHelper.CreateCircle( pX, pY, node.Type == NodeType.CarCross ? ViewConsts.GREEN_LIGHT_COLOR.ToArgb() : node.Type == NodeType.TramStop ? ViewConsts.STOP_COLOR.ToArgb() : ViewConsts.POINT_NORMAL_COLOR.ToArgb(), ViewConsts.POINT_RADIUS, ViewConsts.POINT_PRECISION)); } if (node.Child != null) { float pX2 = CalculateXPosition(node.Child.Node.Coordinates.X); float pY2 = CalculateYPosition(node.Child.Node.Coordinates.Y); edges.Add(DirectxHelper.CreateLine(pX, pY, pX2, pY2, GetLineColor(node, node.Child.Node).ToArgb(), ViewConsts.POINT_RADIUS)); } else if (node.Children != null) { foreach (var child in node.Children) { float pX2 = CalculateXPosition(child.Node.Coordinates.X); float pY2 = CalculateYPosition(child.Node.Coordinates.Y); edges.Add(DirectxHelper.CreateLine(pX, pY, pX2, pY2, GetLineColor(node, child.Node).ToArgb(), ViewConsts.POINT_RADIUS)); } } } }