public static void Update(this TileStruct tile, Type item) { if (item.BaseType == typeof(BaseEnvironment)) { tile.UpdateEnvironment(item); } else if (item.BaseType == typeof(BaseFloor)) { tile.UpdateFloor(item); } else { tile.UpdateObject(item); } }
private void TileClicked(object sender, RoutedEventArgs e) { if (Mouse.LeftButton == MouseButtonState.Pressed) { if (lvAllItems.SelectedItem != null) { BuilderItemStruct item = (BuilderItemStruct)lvAllItems.SelectedItem; TileStruct tile = (TileStruct)((Label)sender).DataContext; if (item.type.BaseType == typeof(BaseFloor)) { tile.UpdateFloor(item.type); } else { tile.UpdateObject(item.type); } } else { MessageBox.Show("Kies een item"); } } else if (Mouse.RightButton == MouseButtonState.Pressed) { TileStruct tile = (TileStruct)((Label)sender).DataContext; if (tile.gameObject.GetType() != Blocks.EMPTY) { tile.UpdateObject(Blocks.EMPTY); } else if (tile.gameObject.GetType() != Floors.EMPTY_FLOOR) { tile.UpdateFloor(Floors.EMPTY_FLOOR); } } }
public static void Update(this TileStruct tile, Type floor, Type obj) { tile.UpdateFloor(floor); tile.UpdateObject(obj); }