Exemple #1
0
 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);
 }
Exemple #2
0
        public void Update()
        {
            Children.Clear();
              myRoomElements.Clear();
              myRoomLinkElements.Clear();

              if (Game == null) return;

              bool containsEnter = Rooms.Any(info => info.Room is IEnterRoom);
              foreach(IMazeRoomInfo roomInfo in Rooms)
              {
            // ReSharper disable AccessToModifiedClosure
            var roomElement = new RoomElement(roomInfo, Game.Players.Where(player => player.Location == roomInfo).ToList());
            // ReSharper restore AccessToModifiedClosure
            Children.Add(roomElement);
            myRoomElements.Add(roomInfo, roomElement);

            RegisterRoomElement(roomElement);

            foreach(Direction direction in CoreUtil.EnumerateDirections())
            {
              IRoomLink roomLink = roomInfo.Link(direction);
              int x = roomInfo.X;
              int y = roomInfo.Y;
              RoomLinkLocation location;
              switch(direction)
              {
            case Direction.Left:
              location = new RoomLinkLocation(x, y, true);
              break;
            case Direction.Right:
              location = new RoomLinkLocation(x + 1, y, true);
              break;
            case Direction.Up:
              location = new RoomLinkLocation(x, y, false);
              break;
            case Direction.Down:
              location = new RoomLinkLocation(x, y + 1, false);
              break;
            default:
              throw new ArgumentOutOfRangeException();
              }
              if (containsEnter)
              {
            // skip links for enter room
            if (location.Vertical)
            {
              if (location.Y == 0 && (location.X == 0 || location.X == 1)) continue;
            }
            else
            {
              if (location.X == 0 && (location.Y == 0 || location.Y == 1)) continue;
            }
              }
              if (!myRoomLinkElements.ContainsKey(location))
              {
            var linkElement = new RoomLinkElement(roomLink, location);
            Children.Add(linkElement);
            myRoomLinkElements.Add(location, linkElement);
              }
            }
              }

              InvalidateArrange();
        }