public BorderWalls(Room r) { StartCell = r.StartCell; EndCell = r.EndCell; Type = r.Type; Theme = r.Theme; Traversable = false; }
public Floor(Room r) { Index2D start = new Index2D(Math.Min(r.StartCell.X, r.EndCell.X), Math.Min(r.StartCell.Y, r.EndCell.Y)); Index2D end = new Index2D(Math.Max(r.StartCell.X, r.EndCell.X), Math.Max(r.StartCell.Y, r.EndCell.Y)); StartCell = new Index2D(start.X + 1, start.Y + 1); EndCell = new Index2D(end.X - 1, end.Y - 1); Type = r.Type; Theme = r.Theme; Traversable = r.FloorType == TileTypes.Floor ? true : false; FloorType = r.FloorType; Type = r.FloorType == TileTypes.Floor ? TileTypes.Floor : r.FloorType == TileTypes.Lava ? TileTypes.Lava : TileTypes.Water; }
void Level_MouseDown(object sender, MouseButtonEventArgs e) { //do some handling here for end of room that skips the rest if (SelectedTile != null && SelectedTile.IsSpecialObject) { if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) { if (SelectedObject == null) { GridCell = GetCell(e.GetPosition(Level)); Index2D i = new Index2D(GridCell.X, GridCell.Y); // fill the pieces if (SelectedTile.Name == "Room") { SelectedObject = new Room(i) { FloorType = SelectedTile.FloorType, }; } else if (SelectedTile.Name == "Walls") { SelectedObject = new BorderWalls(i) { FloorType = SelectedTile.FloorType, }; } else if (SelectedTile.Name == "Wall") { SelectedObject = new Wall(i) { FloorType = SelectedTile.FloorType, }; } else if (SelectedTile.Name == "Floor") { SelectedObject = new Floor(i) { FloorType = SelectedTile.FloorType, }; } } else//here we complete things for the object { GridCell=GetCell(e.GetPosition(Level)); SelectedObject.EndCell = new Index2D(GridCell.X, GridCell.Y); //determine what it is List<Tile> tiles = ToListTile(TileMap.Add(SelectedObject)); foreach (Tile t in tiles) { Grid.SetColumn(t, t.GridCell.X); Grid.SetRow(t, t.GridCell.Y); This.mainWindow.Level.Children.Add(t); } SelectedObject = null; } } else if (e.MouseDevice.RightButton == MouseButtonState.Pressed) { } } else { if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) { if (SelectedTile != null) { GridCell = GetCell(e.GetPosition(Level)); FirstClick = true; AddTile(GridCell); } } else if (e.MouseDevice.RightButton == MouseButtonState.Pressed) { if (ClearTile) { GridCell = GetCell(e.GetPosition(Level)); RemoveTile(GridCell); FirstClick = true; } CancelSelection = true; } } }