public GameControl() { InitializeComponent(); DataContext = game = App.MainModel.Game; CompositionTarget.Rendering += OnRendering; elapsedWatch.Start(); Application.Current.MainWindow.KeyDown += MainWindow_KeyDown; Application.Current.MainWindow.KeyUp += MainWindow_KeyUp; var path = Path.Combine(Environment.CurrentDirectory, "Assets"); BitmapImage image = new BitmapImage(new Uri(path + "\\tiles.png")); // Definition des zentralen Dirt-Brushes dirtBrush = new ImageBrush(image); dirtBrush.TileMode = TileMode.Tile; dirtBrush.Viewbox = new Rect(1820, 0, 128, 128); dirtBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; dirtBrush.ViewboxUnits = BrushMappingMode.Absolute; // Definition der Gras-Brushes grasTiles.Add(TileType.Center, new ImageBrush(image) { Viewbox = new Rect(910, 260, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.Left, new ImageBrush(image) { Viewbox = new Rect(910, 1300, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.Right, new ImageBrush(image) { Viewbox = new Rect(910, 1040, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.Upper, new ImageBrush(image) { Viewbox = new Rect(910, 0, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.Lower, new ImageBrush(image) { Viewbox = new Rect(910, 520, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.UpperLeftConcave, new ImageBrush(image) { Viewbox = new Rect(910, 780, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.UpperRightConcave, new ImageBrush(image) { Viewbox = new Rect(910, 910, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.LowerLeftConcave, new ImageBrush(image) { Viewbox = new Rect(910, 1430, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.LowerRightConcave, new ImageBrush(image) { Viewbox = new Rect(910, 1560, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.UpperLeftConvex, new ImageBrush(image) { Viewbox = new Rect(910, 130, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.UpperRightConvex, new ImageBrush(image) { Viewbox = new Rect(780, 1820, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.LowerLeftConvex, new ImageBrush(image) { Viewbox = new Rect(910, 650, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); grasTiles.Add(TileType.LowerRightConvex, new ImageBrush(image) { Viewbox = new Rect(910, 390, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); // Definition der Sand-Brushes sandTiles.Add(TileType.Center, new ImageBrush(image) { Viewbox = new Rect(780, 260, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.Left, new ImageBrush(image) { Viewbox = new Rect(780, 1300, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.Right, new ImageBrush(image) { Viewbox = new Rect(780, 1040, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.Upper, new ImageBrush(image) { Viewbox = new Rect(780, 0, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.Lower, new ImageBrush(image) { Viewbox = new Rect(780, 520, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.UpperLeftConcave, new ImageBrush(image) { Viewbox = new Rect(780, 780, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.UpperRightConcave, new ImageBrush(image) { Viewbox = new Rect(780, 910, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.LowerLeftConcave, new ImageBrush(image) { Viewbox = new Rect(780, 1430, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.LowerRightConcave, new ImageBrush(image) { Viewbox = new Rect(780, 1560, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.UpperLeftConvex, new ImageBrush(image) { Viewbox = new Rect(780, 130, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.UpperRightConvex, new ImageBrush(image) { Viewbox = new Rect(780, 1690, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.LowerLeftConvex, new ImageBrush(image) { Viewbox = new Rect(780, 650, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); sandTiles.Add(TileType.LowerRightConvex, new ImageBrush(image) { Viewbox = new Rect(780, 390, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); // Definition der Road-Brushes roadTiles.Add(TileType.Center, new ImageBrush(image) { Viewbox = new Rect(2470, 650, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.Left, new ImageBrush(image) { Viewbox = new Rect(2470, 780, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.Right, new ImageBrush(image) { Viewbox = new Rect(2470, 520, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.Upper, new ImageBrush(image) { Viewbox = new Rect(2600, 1040, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.Lower, new ImageBrush(image) { Viewbox = new Rect(2340, 260, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.UpperLeftConcave, new ImageBrush(image) { Viewbox = new Rect(2210, 1430, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.UpperRightConcave, new ImageBrush(image) { Viewbox = new Rect(2210, 1560, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.LowerLeftConcave, new ImageBrush(image) { Viewbox = new Rect(2340, 1820, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.LowerRightConcave, new ImageBrush(image) { Viewbox = new Rect(2470, 0, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.UpperLeftConvex, new ImageBrush(image) { Viewbox = new Rect(2600, 780, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.UpperRightConvex, new ImageBrush(image) { Viewbox = new Rect(2600, 650, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.LowerLeftConvex, new ImageBrush(image) { Viewbox = new Rect(2470, 390, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); roadTiles.Add(TileType.LowerRightConvex, new ImageBrush(image) { Viewbox = new Rect(2470, 260, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }); // Goal Brushes goalHorizontalBottom = new ImageBrush(image) { Viewbox = new Rect(1820, 1690, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; goalHorizontalTop = new ImageBrush(image) { Viewbox = new Rect(1950, 0, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; goalVerticalLeft = new ImageBrush(image) { Viewbox = new Rect(2080, 390, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; goalVerticalRight = new ImageBrush(image) { Viewbox = new Rect(2080, 130, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; startPositionDown = new ImageBrush(image) { Viewbox = new Rect(1950, 260, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; startPositionLeft = new ImageBrush(image) { Viewbox = new Rect(1950, 130, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; startPositionRight = new ImageBrush(image) { Viewbox = new Rect(1950, 390, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; startPositionUp = new ImageBrush(image) { Viewbox = new Rect(1950, 520, 128, 128), ViewboxUnits = BrushMappingMode.Absolute }; }
public void NewGame(Track track) { Game = new Game(track); }