/// <summary> /// Add tile to game table /// </summary> /// <param name="node">New node</param> /// <param name="point">Point of parent side</param> /// <param name="parentTileSide">Parent sile side</param> /// <param name="childTileSide">Child tile side</param> /// <returns>Added tile model</returns> public TileModel AddTileToGame(Node node, Point point, Side parentTileSide, Side childTileSide) { TileModel tileModel = new TileModel(); SetTileParameters(tileModel,node, point, parentTileSide, childTileSide); _parentGrid.Children.Add(tileModel); GameTableTileModels.Add(tileModel); return tileModel; }
/// <summary> /// Set tilemodel centr coords and its rotating angle /// </summary> /// <param name="tileModel">Tilemodel which is applied parametrs to</param> /// <param name="node">Node parameter</param> /// <param name="point">Point of parent side</param> /// <param name="parentTileSide">Parent sile side</param> /// <param name="childTileSide">Child tile side</param> /// <returns></returns> private TileModel SetTileParameters(TileModel tileModel, Node node, Point point, Side parentTileSide, Side childTileSide) { tileModel.CurrentNode = node; int angle = 0; if (parentTileSide != Side.Center) { angle = 2 - ((int)parentTileSide) + ((int)childTileSide); } tileModel.Angle = angle%4; var offset = tileModel.OffsetVector(childTileSide); point.X = point.X - offset.X; point.Y = point.Y - offset.Y; tileModel.Center = point; return tileModel; }
public Leaf(TileModel connectorTileModel, Side connectorSide, Point connectorPoint) { ConnectorSide = connectorSide; ConnectorPoint = connectorPoint; ParentTileModel = connectorTileModel; }
/// <summary> /// Add tile to user interface on exact coords /// </summary> /// <param name="tile">New tile</param> /// <param name="point">Point on the table</param> public void AddTileToUserBase(Tile tile, Point point) { TileModel tileModel = new TileModel(); var node = new Node { CurrentTile = tile }; tileModel.CurrentNode = node; tileModel.Center = point; tileModel.MouseDown += TileModel_MouseDown; UserBaseTileModels.Add(tileModel); _parentGrid.Children.Add(tileModel); }
/// <summary> /// Initialization of helper tile binded to mouse /// </summary> private void HelperInit() { _newTile = new TileModel { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left }; _newTile.Visibility = Visibility.Hidden; _newTile.Rect.Fill = Brushes.Red; Background.Children.Add(_newTile); }