Beispiel #1
0
        // -------------------------------------------------------------------
        // UpdateAround
        // -------------------------------------------------------------------

        public void UpdateAround(int x, int y1, int y2, int z, int height, 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 };
                    Mountain mountainAround = TileOnWhatever(coords, height);
                    if (mountainAround != null)
                    {
                        if (update)
                        {
                            mountainAround.Update(this, coords, portion, height);
                        }
                        else
                        {
                            int[] newPortion = MapEditor.Control.GetPortion(X, Z);
                            if (WANOK.IsInPortions(newPortion))
                            {
                                MapEditor.Control.AddPortionsMountainToUpdate(newPortion);
                                WANOK.AddPortionsToAddCancel(MapEditor.Control.Map.MapInfos.RealMapName, MapEditor.Control.GetGlobalPortion(newPortion));
                            }
                            else
                            {
                                mountainAround.Update(this, coords, portion, height);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        // -------------------------------------------------------------------
        // CreateCopy
        // -------------------------------------------------------------------

        public Mountain CreateCopy()
        {
            Mountain newMountain = CreatePartialCopy();

            newMountain.DrawTop   = DrawTop;
            newMountain.DrawBot   = DrawBot;
            newMountain.DrawLeft  = DrawLeft;
            newMountain.DrawRight = DrawRight;

            return(newMountain);
        }
Beispiel #3
0
        // -------------------------------------------------------------------
        // Add
        // -------------------------------------------------------------------

        public void Add(int[] coords, int id, Mountain mountain, int height, bool update = true)
        {
            if (!Groups.ContainsKey(id))
            {
                Groups[id] = new MountainsGroup();
            }
            if (!Groups[id].Tiles.ContainsKey(coords))
            {
                Groups[id].Tiles[coords] = mountain.CreatePartialCopy();
                UpdateAround(coords[0], coords[1], coords[2], coords[3], height, update);
            }
        }
        // -------------------------------------------------------------------
        // 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);
        }
        // -------------------------------------------------------------------
        // RemoveMountain
        // -------------------------------------------------------------------

        public bool RemoveMountain(int[] coords)
        {
            bool modified = false;
            int  height   = WANOK.GetCoordsPixelHeight(coords);

            object[] before = ContainsMountain(height, coords);
            if (before != null)
            {
                modified = true;
                int      beforeId       = (int)before[0];
                Mountain beforeMountain = (Mountain)before[1];
                Mountains[height].Remove(coords, beforeId, height);
                RemoveFloor(new int[] { coords[0], coords[1] + beforeMountain.SquareHeight, coords[2] + beforeMountain.PixelHeight, coords[3] });
            }

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

        protected List <VertexPositionTexture> CreateTex(Texture2D texture, int[] coords, Mountain mountain)
        {
            int   x = coords[0], y = coords[1] * WANOK.SQUARE_SIZE + coords[2], z = coords[3];
            float top = 0;
            float bot = ((float)WANOK.SQUARE_SIZE) / texture.Height;


            List <VertexPositionTexture> res = new List <VertexPositionTexture>();

            if (mountain.DrawTop)
            {
                FillTexture(res, bot, top, texture.Width, mountain.SquareHeight, mountain.PixelHeight, x, x + 1, x + 1, x, z, z, z, z, y);
            }
            if (mountain.DrawBot)
            {
                FillTexture(res, bot, top, texture.Width, mountain.SquareHeight, mountain.PixelHeight, x, x + 1, x + 1, x, z + 1, z + 1, z + 1, z + 1, y);
            }
            if (mountain.DrawLeft)
            {
                FillTexture(res, bot, top, texture.Width, mountain.SquareHeight, mountain.PixelHeight, x, x, x, x, z, z + 1, z + 1, z, y);
            }
            if (mountain.DrawRight)
            {
                FillTexture(res, bot, top, texture.Width, mountain.SquareHeight, mountain.PixelHeight, x + 1, x + 1, x + 1, x + 1, z, z + 1, z + 1, z, y);
            }

            return(res);
        }
Beispiel #7
0
        // -------------------------------------------------------------------
        // CanDraw
        // -------------------------------------------------------------------

        public bool CanDraw(Mountain mountain)
        {
            return(mountain != null && WANOK.GetPixelHeight(SquareHeight, PixelHeight) <= WANOK.GetPixelHeight(mountain.SquareHeight, mountain.PixelHeight));
        }