Beispiel #1
0
        // -------------------------------------------------------------------
        // CreateCopy
        // -------------------------------------------------------------------

        public Mountains CreateCopy()
        {
            Mountains newMountains = new Mountains();

            foreach (int id in Groups.Keys)
            {
                newMountains.Groups[id] = Groups[id].CreateCopy();
            }

            return(newMountains);
        }
        // -------------------------------------------------------------------
        // AddMountain
        // -------------------------------------------------------------------

        public bool AddMountain(int[] coords, int newId, Mountain newMountain)
        {
            bool modified = false;
            int  height   = WANOK.GetCoordsPixelHeight(coords);

            object[] before = ContainsMountain(height, coords);

            // Remplacing
            if (before == null)
            {
                modified = true;
            }
            else
            {
                int      beforeId       = (int)before[0];
                Mountain beforeMountain = (Mountain)before[1];
                if (beforeId != newId)
                {
                    modified = true;
                }
                Mountains[height].Remove(coords, beforeId, height);
            }

            if (!Mountains.ContainsKey(height))
            {
                Mountains[height] = new Mountains();
            }
            Mountains[height].Add(coords, newId, newMountain, height);

            SystemTileset tileset = MapEditor.GetMapTileset();

            object[] reliefTop = tileset.ReliefTop[tileset.Reliefs.IndexOf(newId)];


            switch ((DrawType)reliefTop[0])
            {
            case DrawType.Floors:
                AddFloor(new int[] { coords[0], coords[1] + newMountain.SquareHeight, coords[2] + newMountain.PixelHeight, coords[3] }, (int[])reliefTop[1]);
                break;

            case DrawType.Autotiles:
                int id = ((int[])reliefTop[1])[0];
                if (id > 0)
                {
                    AddAutotile(new int[] { coords[0], coords[1] + newMountain.SquareHeight, coords[2] + newMountain.PixelHeight, coords[3] }, id, true);
                }
                break;
            }


            return(modified);
        }
Beispiel #3
0
        // -------------------------------------------------------------------
        // Update
        // -------------------------------------------------------------------

        public void Update(Mountains mountains, int[] coords, int[] portion, int height)
        {
            DrawTop   = !CanDraw(mountains.TileOnTop(coords, portion, height));
            DrawBot   = !CanDraw(mountains.TileOnBottom(coords, portion, height));
            DrawLeft  = !CanDraw(mountains.TileOnLeft(coords, portion, height));
            DrawRight = !CanDraw(mountains.TileOnRight(coords, portion, height));

            // 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));
        }