// -------------------------------------------------------------------
        // UpdateAround
        // -------------------------------------------------------------------

        public void UpdateAround(int x, int y1, int y2, int z, bool update)
        {
            int[] portion = MapEditor.Control.GetPortion(x, z); // portion where you are setting autotile
            for (int X = x - 1; X <= x + 1; X++)
            {
                for (int Z = z - 1; Z <= z + 1; Z++)
                {
                    int[]    coords         = new int[] { X, y1, y2, Z };
                    Autotile autotileAround = TileOnWhatever(coords);
                    if (autotileAround != null)
                    {
                        if (update)
                        {
                            autotileAround.Update(this, coords, portion);
                        }
                        else
                        {
                            int[] newPortion = MapEditor.Control.GetPortion(X, Z);
                            if (WANOK.IsInPortions(newPortion))
                            {
                                MapEditor.Control.AddPortionsAutotileToUpdate(newPortion);
                                WANOK.AddPortionsToAddCancel(MapEditor.Control.Map.MapInfos.RealMapName, MapEditor.Control.GetGlobalPortion(newPortion));
                            }
                            else
                            {
                                autotileAround.Update(this, coords, portion);
                            }
                        }
                    }
                }
            }
        }
        // -------------------------------------------------------------------
        // Add
        // -------------------------------------------------------------------

        public void Add(int[] coords, bool update = true)
        {
            if (!Tiles.ContainsKey(coords))
            {
                Tiles[coords] = new Autotile();
                UpdateAround(coords[0], coords[1], coords[2], coords[3], update);
            }
        }
Exemple #3
0
        // -------------------------------------------------------------------
        // CreateCopy
        // -------------------------------------------------------------------

        public Autotile CreateCopy()
        {
            Autotile newAutotile = new Autotile();

            newAutotile.TilesId = TilesId;

            return(newAutotile);
        }
        // -------------------------------------------------------------------
        // CreateTex
        // -------------------------------------------------------------------

        protected VertexPositionTexture[] CreateTex(int[] coords, Autotile autotile)
        {
            int x = coords[0], y = coords[1] * WANOK.SQUARE_SIZE + coords[2], z = coords[3];

            int xTile = autotile.TilesId % 125;
            int yTile = autotile.TilesId / 125;

            // Texture coords
            float left  = xTile / 125.0f;
            float top   = yTile / 5.0f;
            float bot   = (yTile + 1) / 5.0f;
            float right = (xTile + 1) / 125.0f;

            // Vertex Position and Texture
            return(new VertexPositionTexture[]
            {
                new VertexPositionTexture(new Vector3(x, y, z), new Vector2(left, top)),
                new VertexPositionTexture(new Vector3(x + 1, y, z), new Vector2(right, top)),
                new VertexPositionTexture(new Vector3(x + 1, y, z + 1), new Vector2(right, bot)),
                new VertexPositionTexture(new Vector3(x, y, z + 1), new Vector2(left, bot))
            });
        }