// -------------------------------------------------------------------
        // AddAutotile
        // -------------------------------------------------------------------

        public bool AddAutotile(int[] coords, int newId, bool update)
        {
            bool modified = false;
            int  beforeId = ContainsAutotiles(coords);

            if (beforeId == -1)
            {
                modified = true;
                int[] beforeTexture = ContainsFloor(coords);
                if (!beforeTexture.SequenceEqual(new int[] { 0, 0, 0, 0 }))
                {
                    Floors.Remove(coords);
                }
            }
            else
            {
                Autotiles[beforeId].Remove(coords, update);
            }

            // Adding the new autotile
            if (!Autotiles.ContainsKey(newId))
            {
                Autotiles[newId] = new Autotiles(newId);
            }
            Autotiles[newId].Add(coords, update);

            return(modified || beforeId != newId);
        }
示例#2
0
        // -------------------------------------------------------------------
        // CreateCopy
        // -------------------------------------------------------------------

        public Autotiles CreateCopy()
        {
            Autotiles newAutotiles = new Autotiles(Id);

            foreach (KeyValuePair <int[], Autotile> entry in Tiles)
            {
                newAutotiles.Tiles[entry.Key] = entry.Value.CreateCopy();
            }

            return(newAutotiles);
        }
示例#3
0
        // -------------------------------------------------------------------
        // Update
        // -------------------------------------------------------------------

        public void Update(Autotiles autotiles, int[] coords, int[] portion)
        {
            int[] tiles = new int[4];
            int   num   = 0;

            // Top left
            if (!autotiles.TileOnLeft(coords, portion) && !autotiles.TileOnTop(coords, portion))
            {
                num = 2;
            }
            else if (!autotiles.TileOnTop(coords, portion) && autotiles.TileOnLeft(coords, portion))
            {
                num = 4;
            }
            else if (!autotiles.TileOnLeft(coords, portion) && autotiles.TileOnTop(coords, portion))
            {
                num = 5;
            }
            else if (autotiles.TileOnLeft(coords, portion) && autotiles.TileOnTop(coords, portion) && autotiles.TileOnTopLeft(coords, portion))
            {
                num = 3;
            }
            else
            {
                num = 1;
            }
            tiles[0] = num - 1;

            // Top right
            if (!autotiles.TileOnRight(coords, portion) && !autotiles.TileOnTop(coords, portion))
            {
                num = 2;
            }
            else if (!autotiles.TileOnTop(coords, portion) && autotiles.TileOnRight(coords, portion))
            {
                num = 4;
            }
            else if (!autotiles.TileOnRight(coords, portion) && autotiles.TileOnTop(coords, portion))
            {
                num = 5;
            }
            else if (autotiles.TileOnRight(coords, portion) && autotiles.TileOnTop(coords, portion) && autotiles.TileOnTopRight(coords, portion))
            {
                num = 3;
            }
            else
            {
                num = 1;
            }
            tiles[1] = num - 1;

            // Bottom left
            if (!autotiles.TileOnLeft(coords, portion) && !autotiles.TileOnBottom(coords, portion))
            {
                num = 2;
            }
            else if (!autotiles.TileOnBottom(coords, portion) && autotiles.TileOnLeft(coords, portion))
            {
                num = 4;
            }
            else if (!autotiles.TileOnLeft(coords, portion) && autotiles.TileOnBottom(coords, portion))
            {
                num = 5;
            }
            else if (autotiles.TileOnLeft(coords, portion) && autotiles.TileOnBottom(coords, portion) && autotiles.TileOnBottomLeft(coords, portion))
            {
                num = 3;
            }
            else
            {
                num = 1;
            }
            tiles[2] = num - 1;

            // Bottom right
            if (!autotiles.TileOnRight(coords, portion) && !autotiles.TileOnBottom(coords, portion))
            {
                num = 2;
            }
            else if (!autotiles.TileOnBottom(coords, portion) && autotiles.TileOnRight(coords, portion))
            {
                num = 4;
            }
            else if (!autotiles.TileOnRight(coords, portion) && autotiles.TileOnBottom(coords, portion))
            {
                num = 5;
            }
            else if (autotiles.TileOnRight(coords, portion) && autotiles.TileOnBottom(coords, portion) && autotiles.TileOnBottomRight(coords, portion))
            {
                num = 3;
            }
            else
            {
                num = 1;
            }
            tiles[3] = num - 1;

            // Update tileId
            TilesId = (tiles[0] * 125) + (tiles[1] * 25) + (tiles[2] * 5) + tiles[3];

            // Update & save update
            int[] portionToUpdate = MapEditor.Control.GetPortion(coords[0], coords[3]);
            MapEditor.Control.AddPortionToUpdate(portionToUpdate);
            MapEditor.Control.AddPortionToSave(portionToUpdate);
            WANOK.AddPortionsToAddCancel(MapEditor.Control.Map.MapInfos.RealMapName, MapEditor.Control.GetGlobalPortion(portionToUpdate));
        }