public RoomLinkElement(IRoomLink roomLink, RoomLinkLocation location) { // Background = new SolidColorBrush(Colors.Blue); RoomLink = roomLink; Location = location; myImage = new Image { Source = RoomLink.Image, Stretch = Stretch.Fill}; if (Location.Vertical) myImage.RenderTransform = new RotateTransform { Angle = 90, CenterX = 0, CenterY = 0 }; Children.Add(myImage); }
private StuffManager() { DxMCards = GetTypesByInterface(typeof(IDxMCard)).Select(type => (IDxMCard)Activator.CreateInstance(type)).ToList(); TreasureCards = GetTypesByInterface(typeof(ITreasureCard)).Select(type => (ITreasureCard)Activator.CreateInstance(type)).ToList(); MonsterCards = GetTypesByInterface(typeof(IMonsterCard)).Select(type => (IMonsterCard)Activator.CreateInstance(type)).ToList(); RoomLinks = new IRoomLink[] { myOpenPassageway, myRegularDoor, myLockedDoor, myHiddenDoor, myWall }; RoomCards = new IRoomCard[] { new RoomCard(new HallOfShameRoom(), new SeeminglyEmptyRoom()), new RoomCard(new BugHouseRoom(), new SpikedPitRoom()), }; EnterRoom = new EnterRoom(); RoomLinkWidthToHeight = (double)myOpenPassageway.Image.PixelWidth / myOpenPassageway.Image.PixelHeight; RoomLinkWidthToRoomSize = (double)myOpenPassageway.Image.PixelWidth / RoomCards[0].Side1.Image.PixelWidth; EnterRoomSizeToNormalRoomSize = (double)EnterRoom.Image.PixelWidth / RoomCards[0].Side1.Image.PixelWidth; }
public void SetLink(Direction direction, IRoomLink link) { switch (direction) { case Direction.Left: if (Y == 0 && (X == 0 || X == 1)) throw new InvalidOperationException("Cannot change links of enter room"); Maze.myLeftRoomLinks[new Coords(X, Y)] = link; break; case Direction.Right: if (Y == 0 && (X == 0 || X == -1)) throw new InvalidOperationException("Cannot change links of enter room"); Maze.myLeftRoomLinks[new Coords(X + 1, Y)] = link; break; case Direction.Up: if (X == 0 && (Y == 0 || Y == 1)) throw new InvalidOperationException("Cannot change links of enter room"); Maze.myUpRoomLinks[new Coords(X, Y)] = link; break; case Direction.Down: if (X == 0 && (Y == 0 || Y == -1)) throw new InvalidOperationException("Cannot change links of enter room"); Maze.myUpRoomLinks[new Coords(X, Y + 1)] = link; break; default: throw new ArgumentOutOfRangeException("direction"); } }