public LaserFactory.LaserDirection LaserEntered(LaserFactory.LaserDirection direction) { if (RoomMirror != null) { return(RoomMirror.CalculateReflection(direction)); } return(direction); }
public void GetNextRoom(LaserFactory.LaserDirection direction, ref bool hasExited) { if (direction == LaserFactory.LaserDirection.Up) { if (Rooms.Exists(x => x.XCoord == Path.Peek().XCoord&& x.YCoord == Path.Peek().YCoord + 1)) { Path.Push(Rooms.First(x => x.XCoord == Path.Peek().XCoord&& x.YCoord == Path.Peek().YCoord + 1)); } else { hasExited = true; } } else if (direction == LaserFactory.LaserDirection.Down) { if (Rooms.Exists(x => x.XCoord == Path.Peek().XCoord&& x.YCoord == Path.Peek().YCoord - 1)) { Path.Push(Rooms.First(x => x.XCoord == Path.Peek().XCoord&& x.YCoord == Path.Peek().YCoord - 1)); } else { hasExited = true; } } else if (direction == LaserFactory.LaserDirection.Left) { if (Rooms.Exists(x => x.XCoord == Path.Peek().XCoord - 1 && x.YCoord == Path.Peek().YCoord)) { Path.Push(Rooms.First(x => x.XCoord == Path.Peek().XCoord - 1 && x.YCoord == Path.Peek().YCoord)); } else { hasExited = true; } } else { if (Rooms.Exists(x => x.XCoord == Path.Peek().XCoord + 1 && x.YCoord == Path.Peek().YCoord)) { Path.Push(Rooms.First(x => x.XCoord == Path.Peek().XCoord + 1 && x.YCoord == Path.Peek().YCoord)); } else { hasExited = true; } } }
public override LaserFactory.LaserDirection Reflect(MirrorFactory.Direction orientation, LaserFactory.LaserDirection directionOfTravel) { if (orientation == MirrorFactory.Direction.Right) { switch (directionOfTravel) { case LaserFactory.LaserDirection.Right: return(LaserFactory.LaserDirection.Up); case LaserFactory.LaserDirection.Left: return(LaserFactory.LaserDirection.Down); case LaserFactory.LaserDirection.Up: return(LaserFactory.LaserDirection.Right); case LaserFactory.LaserDirection.Down: return(LaserFactory.LaserDirection.Left); default: throw new Exception("Direction not implemented"); } } switch (directionOfTravel) { case LaserFactory.LaserDirection.Right: return(LaserFactory.LaserDirection.Down); case LaserFactory.LaserDirection.Left: return(LaserFactory.LaserDirection.Up); case LaserFactory.LaserDirection.Up: return(LaserFactory.LaserDirection.Left); case LaserFactory.LaserDirection.Down: return(LaserFactory.LaserDirection.Right); default: throw new Exception("Direction not implemented"); } }
public override LaserFactory.LaserDirection Reflect(MirrorFactory.Direction orientation, LaserFactory.LaserDirection directionOfTravel) { if (orientation == MirrorFactory.Direction.Right) { switch (directionOfTravel) { case LaserFactory.LaserDirection.Down: return(LaserFactory.LaserDirection.Left); case LaserFactory.LaserDirection.Right: return(LaserFactory.LaserDirection.Up); default: return(directionOfTravel); } } switch (directionOfTravel) //orientation must be left { case LaserFactory.LaserDirection.Up: return(LaserFactory.LaserDirection.Left); case LaserFactory.LaserDirection.Right: return(LaserFactory.LaserDirection.Down); default: return(directionOfTravel); } }
public LaserFactory.LaserDirection CalculateReflection(LaserFactory.LaserDirection direction) { return(_reflectionStrategy.Reflect(Direction, direction)); }
public abstract LaserFactory.LaserDirection Reflect(MirrorFactory.Direction orientation, LaserFactory.LaserDirection directionOfTravel);