Exemplo n.º 1
0
        private void DrawBedrock()
        {
            if (TileDB.Width != 80 || TileDB.Height != 60)
            {
                return;
            }
            int location = 2;

            for (int y = TileDB.Height - 1; y > TileDB.Height - 4; y--)
            {
                for (int x = TileDB.Width - 1; x >= 0; x--)
                {
                    BlockName bn;
                    if (y == 59)
                    {
                        bn = BlockName.BedrockLava;
                    }
                    else if (y == 58)
                    {
                        bn = BlockName.Bedrock;
                    }
                    else
                    {
                        bn = BlockName.BedrockFlat;
                    }

                    Image image = new Image();
                    blockMap.TryGetValue(bn, out BitmapImage src);
                    image.Source = src;
                    Canvas.SetTop(image, y * 32);
                    Canvas.SetLeft(image, x * 32);
                    image.SetValue(Canvas.ZIndexProperty, 20);
                    MainCanvas.Children.Add(image);

                    TilePosition Position = new TilePosition(TileType.Foreground, x, y);

                    TileDB.Tiles[x, y] = new Tile(TileType.Foreground, bn.ToString(), image, Position);
                }
                location--;
            }
        }
Exemplo n.º 2
0
        private void PlaceAt(int X, int Y, Tile tile)
        {
            Image image = new Image()
            {
                Source = selectableTiles[index].source
            };

            Canvas.SetTop(image, Y * 32);
            Canvas.SetLeft(image, X * 32);
            MainCanvas.Children.Add(image);

            switch (tile.Type)
            {
            case TileType.Background:
                image.SetValue(Canvas.ZIndexProperty, 10);
                if (HasForegroundAt(X, Y))
                {
                    TileDB.Tiles[X, Y].Type       = TileType.Both;
                    TileDB.Tiles[X, Y].Background = image;
                    TileDB.Tiles[X, Y].bgName     = selectableTiles[index].bgName;
                    if (TileDB.Tiles[X, Y].Positions == null)
                    {
                        TileDB.Tiles[X, Y].Positions = new TilePosition(tile.Type, X, Y);
                    }
                    else
                    {
                        TileDB.Tiles[X, Y].Positions.SetBackgroundPositions(X, Y);
                    }
                }
                else
                {
                    TilePosition Position = new TilePosition(tile.Type, X, Y);
                    TileDB.Tiles[X, Y] = new Tile(TileType.Background, selectableTiles[index].bgName, image, Position);
                }
                break;

            case TileType.Foreground:
                image.SetValue(Canvas.ZIndexProperty, 20);
                if (HasBackgroundAt(X, Y))
                {
                    TileDB.Tiles[X, Y].Type       = TileType.Both;
                    TileDB.Tiles[X, Y].Foreground = image;
                    TileDB.Tiles[X, Y].blName     = selectableTiles[index].blName;

                    if (TileDB.Tiles[X, Y].Positions == null)
                    {
                        TileDB.Tiles[X, Y].Positions = new TilePosition(tile.Type, X, Y);
                    }
                    else
                    {
                        TileDB.Tiles[X, Y].Positions.SetForegroundPositions(X, Y);
                    }
                }
                else
                {
                    TilePosition Position = new TilePosition(tile.Type, X, Y);
                    TileDB.Tiles[X, Y] = new Tile(TileType.Foreground, selectableTiles[index].blName, image, Position);
                }
                break;
            }
        }