Ejemplo n.º 1
0
        public void Place(int destinationX, int destinationY, WorldViewModel wvm)
        {
            ErrorLogging.TelemetryClient?.TrackEvent("PlaceSprite", new Dictionary <string, string> {
                ["Tile"] = Tile.ToString(), ["UV"] = UV.ToString()
            });

            if (Tile == (ushort)TileType.ChristmasTree)
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        if (x == 0 && y == 0)
                        {
                            curtile.U = 10;
                        }
                        else
                        {
                            curtile.U = (short)x;
                        }
                        curtile.V = (short)y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
            else
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    Vector2Short[,] tiles = GetTiles();
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        curtile.U        = tiles[x, y].X;
                        curtile.V        = tiles[x, y].Y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void PlaceSprite(int destinationX, int destinationY, Sprite sprite, WorldViewModel wvm)
        {
            if (sprite.Tile == (ushort)TileType.ChristmasTree)
            {
                for (int x = 0; x < sprite.Size.X; x++)
                {
                    int tilex = x + destinationX;
                    for (int y = 0; y < sprite.Size.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = sprite.Tile;
                        if (x == 0 && y == 0)
                        {
                            curtile.U = 10;
                        }
                        else
                        {
                            curtile.U = (short)x;
                        }
                        curtile.V = (short)y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, sprite.Size.X, sprite.Size.Y);
                    }
                }
            }
            else
            {
                for (int x = 0; x < sprite.Size.X; x++)
                {
                    Vector2Short[,] tiles = sprite.GetTiles();
                    int tilex = x + destinationX;
                    for (int y = 0; y < sprite.Size.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = sprite.Tile;
                        curtile.U        = tiles[x, y].X;
                        curtile.V        = tiles[x, y].Y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, sprite.Size.X, sprite.Size.Y);
                    }
                }
            }
        }