Ejemplo n.º 1
0
 public LaserFactory.LaserDirection LaserEntered(LaserFactory.LaserDirection direction)
 {
     if (RoomMirror != null)
     {
         return(RoomMirror.CalculateReflection(direction));
     }
     return(direction);
 }
Ejemplo n.º 2
0
 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;
         }
     }
 }
Ejemplo n.º 3
0
        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");
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public LaserFactory.LaserDirection CalculateReflection(LaserFactory.LaserDirection direction)
 {
     return(_reflectionStrategy.Reflect(Direction, direction));
 }
Ejemplo n.º 6
0
 public abstract LaserFactory.LaserDirection Reflect(MirrorFactory.Direction orientation,
                                                     LaserFactory.LaserDirection directionOfTravel);