public ISlmmMove GetSlmmMoveDirection(DirectionEnum.Direction direction) { switch (direction) { case DirectionEnum.Direction.North: return(ObjectsContainer.GetObjectByName <ISlmmMove>("SlmmMoveNorthService")); case DirectionEnum.Direction.South: return(ObjectsContainer.GetObjectByName <ISlmmMove>("SlmmMoveSouthService")); case DirectionEnum.Direction.East: return(ObjectsContainer.GetObjectByName <ISlmmMove>("SlmmMoveEastService")); case DirectionEnum.Direction.West: return(ObjectsContainer.GetObjectByName <ISlmmMove>("SlmmMoveWestService")); default: throw new Exception(String.Format("Slmm Move not implemented for Direction : {0}", direction)); } }
public void MoveOneSteptest(int currentX, int currentY, int maxX, int maxY, DirectionEnum.Direction direction, int expectedCurrentX, int expectedCurrentY, DirectionEnum.Direction expectedDirection, int expectedClockWise90, int expectedAntiClockWise90) { //Arrange var mowerHttpClientMock = new Mock<IMowerHttpClient>(); ObjectsContainer.InjectObject<IMowerHttpClient>(mowerHttpClientMock.Object); var slmmService = ObjectsContainer.GetObject<ISlmmService>(); slmmService.SmartMower = new SmartMowerMachine(currentX, currentY, maxX, maxY, direction); var slmmMoveService = ObjectsContainer.GetObjectByName<ISlmmMove>("SlmmMoveSouthService"); //Act slmmMoveService.MoveOneStep(slmmService); //Assert Assert.AreEqual(expectedCurrentX, slmmService.SmartMower.CurrentX); Assert.AreEqual(expectedCurrentY, slmmService.SmartMower.CurrentY); Assert.AreEqual(expectedDirection, slmmService.SmartMower.Direction); mowerHttpClientMock.Verify(a => a.Turn90Clockwise(slmmService.SmartMower), Times.Exactly(expectedClockWise90)); mowerHttpClientMock.Verify(a => a.Turn90AntiClockwise(slmmService.SmartMower), Times.Exactly(expectedAntiClockWise90)); }
private KeyCode DetectPlayerRotation(DirectionEnum.Direction direction) { KeyCode expectedKey = 0; switch (this.OwnerId) { case (int)PlayerEnum.PlayerId.PLAYER_1: if (direction == DirectionEnum.Direction.LEFT) { expectedKey = KeyCode.LeftAlt; } else if (direction == DirectionEnum.Direction.RIGHT) { expectedKey = KeyCode.Space; } break; case (int)PlayerEnum.PlayerId.PLAYER_2: if (direction == DirectionEnum.Direction.LEFT) { expectedKey = KeyCode.RightAlt; } else if (direction == DirectionEnum.Direction.RIGHT) { expectedKey = KeyCode.RightControl; } break; default: break; } return(expectedKey); }
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()); }