/// <summary> /// Gets the tiles that are interconnected to provide tile. /// </summary> /// <param name="tile">The tile.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public List <IInteractiveElement> GetGroupedTiles(IInteractiveElement origin) { List <IInteractiveElement> result = new List <IInteractiveElement>(); //Find the group, if any, containing provided tile var hostGroups = this.Groups.Where(g => g.Items.Any(t => t == origin)).ToList(); if (hostGroups.Any()) { //Get the unique tiles from containing groups var tiles = hostGroups.SelectMany(g => g.Items).Distinct(); result.AddRange(tiles); if (this.Groups.Count > 1) { //Search other groups for linked tiles foreach (var otherTile in tiles.Where(t => t != origin)) { hostGroups = this.Groups.Where(g => !hostGroups.Contains(g) && g.Items.Any(t => t == otherTile)).ToList(); if (hostGroups.Any()) { tiles = hostGroups.SelectMany(g => g.Items).Distinct().Except(result); result.AddRange(tiles); } } } } return(result); }
private ConnectableViewItem GetConnectable(string tileId) { IInteractiveElement tile = this.scatterView.Items.OfType <IInteractiveElement>().FirstOrDefault(t => t.Id == tileId); if (tile == null) { return(null); } return((ConnectableViewItem)this.scatterView.ContainerFromItem(tile)); }
/// <summary> /// Removes a tile from the groups it is part of /// </summary> /// <param name="tile">The tile.</param> public void UnGroup(IInteractiveElement tile) { var affectedGroups = this.Groups.Where(g => g.Items.Any(t => t == tile)); if (affectedGroups.Any()) { foreach (InteractiveGroup group in affectedGroups) { //If deleted element is the first of the group is the one containing all others aka 'the glue' of the group bool isGroupGlue = group.Items.First() == tile; group.Remove(tile); //Check if tile is not pinned to any other tile, if so ungroups it if (group.Items.Count == 1 || isGroupGlue) { group.Clear(true); } } } }
public UsableElement(int cellId, IInteractiveElement element, List <InteractiveElementSkill> skills) { CellId = cellId; Element = element; Skills = skills; }