private static void GoToExit(MoveablePictureBox car) { var fillingFinishedPoint = car.GetDestinationPoint(); car.RemoveDestinationPoint(_modelingForm); car.AddDestinationPoint(DestinationPointsDefiner.LeavePointFilled); car.AddDestinationPoint(DestinationPointsDefiner.ExitPoint3); car.AddDestinationPoint(DestinationPointsDefiner.ExitPoint2); car.AddDestinationPoint(DestinationPointsDefiner.ExitPoint1); car.AddDestinationPoint(fillingFinishedPoint); }
internal static Point PreventIntersection(MoveablePictureBox activeCar, DirectionEnum.Direction direction) { var destPoint = activeCar.GetDestinationPoint(); foreach (Control c in _modelingForm.PlaygroundPanel.Controls) { if (!(c is PictureBox) || c.Tag == null || c == activeCar) { continue; } var pictureBox = (PictureBox)c; if (!activeCar.Bounds.IntersectsWith(pictureBox.Bounds)) { continue; } // Another Car if (pictureBox is MoveablePictureBox) { var anotherCar = pictureBox; switch (direction) { case DirectionEnum.Direction.Up: { activeCar.Top = anotherCar.Bottom; break; } case DirectionEnum.Direction.Right: { activeCar.Left = anotherCar.Left - activeCar.Width; break; } case DirectionEnum.Direction.Down: { activeCar.Top = anotherCar.Top - activeCar.Height; break; } case DirectionEnum.Direction.Left: { activeCar.Left = anotherCar.Right; break; } } } // Fuel Dispenser if (pictureBox.Tag is FuelDispenserView || pictureBox.Tag is CashCounterView) { var fuelDispenser = pictureBox; var initialDestinationPoint = activeCar.GetDestinationPoint(); bool bypassFromLeft = false; bool bypassFromRight = false; bool bypassFromBottom = false; bool bypassFromTop = false; int newDestX; int newDestY; Point newDestinationPoint1; Point newDestinationPoint2; Point newDestinationPoint3; switch (direction) { case DirectionEnum.Direction.Up: { activeCar.Top = fuelDispenser.Bottom; if (!activeCar.IsBypassingObject) { activeCar.IsBypassingObject = true; // choose where to bypass newDestX = destPoint.X < activeCar.Left ? fuelDispenser.Left - (activeCar.Width + 5) : fuelDispenser.Right + (activeCar.Width + 5); if (destPoint.X < activeCar.Left) { newDestX = fuelDispenser.Left - (activeCar.Width + 5); bypassFromLeft = true; } else { newDestX = fuelDispenser.Right + (activeCar.Width + 5); bypassFromRight = true; } newDestY = fuelDispenser.Bottom + 10; newDestinationPoint1 = new Point(newDestX, newDestY); newDestY = fuelDispenser.Top + activeCar.Height + 10; newDestinationPoint2 = new Point(newDestX, newDestY); activeCar.DeleteDestinationSpot(_modelingForm); activeCar.AddDestinationPoint(newDestinationPoint2); activeCar.AddDestinationPoint(newDestinationPoint1); } break; } case DirectionEnum.Direction.Right: { break; } case DirectionEnum.Direction.Down: { activeCar.Top = fuelDispenser.Top - activeCar.Height; if (!activeCar.IsBypassingObject) { activeCar.IsBypassingObject = true; newDestX = fuelDispenser.Left - (activeCar.Width + 5); newDestY = fuelDispenser.Top - 10; newDestinationPoint1 = new Point(newDestX, newDestY); activeCar.DeleteDestinationSpot(_modelingForm); activeCar.AddDestinationPoint(newDestinationPoint1); } break; } case DirectionEnum.Direction.Left: { activeCar.Left = fuelDispenser.Right; if (!activeCar.IsBypassingObject) { activeCar.IsBypassingObject = true; newDestX = fuelDispenser.Right + 10; newDestY = fuelDispenser.Top - (ElementSizeDefiner.CarHeight + 5); newDestinationPoint1 = new Point(newDestX, newDestY); if (activeCar.IsFilled) { newDestX = fuelDispenser.Left - ElementSizeDefiner.CarWidth - 5; } else { activeCar.IsGoesHorizontal = true; //newDestX = fuelDispenser.Left - CarWidth - 5 - TopologyCellSize; newDestX = initialDestinationPoint.X + ElementSizeDefiner.TopologyCellSize / 2; } newDestinationPoint2 = new Point(newDestX, newDestY); activeCar.FromLeftBypassingPoint = newDestinationPoint2; newDestinationPoint3 = new Point(fuelDispenser.Left - 20, destPoint.Y - 20); activeCar.DeleteDestinationSpot(_modelingForm); //activeCarView.AddDestinationPoint(newDestinationPoint3); activeCar.AddDestinationPoint(newDestinationPoint2); activeCar.AddDestinationPoint(newDestinationPoint1); } break; } } } } return(activeCar.GetDestinationPoint()); }
private static void GoToEnter(MoveablePictureBox car) { car.AddDestinationPoint(DestinationPointsDefiner.EnterPoint3); car.AddDestinationPoint(DestinationPointsDefiner.EnterPoint2); car.AddDestinationPoint(DestinationPointsDefiner.EnterPoint1); }