Exemplo n.º 1
0
        public override void ActionPerform()
        {
            var painterBrushNum = 0;

            terrain = Map.Terrain;

            painter = Map.Painter;

            tile    = terrain.Tiles[PosNum.X, PosNum.Y];
            texture = tile.Texture;

            terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff     = false;
            terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff    = false;
            terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff  = false;
            terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = false;
            terrain.Tiles[PosNum.X, PosNum.Y].DownSide = TileUtil.None;

            for (painterBrushNum = 0; painterBrushNum <= painter.CliffBrushCount - 1; painterBrushNum++)
            {
                var a = 0;
                for (a = 0; a <= painter.CliffBrushes[painterBrushNum].Tiles_Straight.TileCount - 1; a++)
                {
                    painterTexture = painter.CliffBrushes[painterBrushNum].Tiles_Straight.Tiles[a];
                    if (painterTexture.TextureNum == texture.TextureNum)
                    {
                        if (tile.Tri)
                        {
                            terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff     = true;
                            terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true;
                        }
                        else
                        {
                            terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff   = true;
                            terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true;
                        }
                        terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff = true;
                        TileUtil.RotateDirection(painterTexture.Direction, texture.Orientation, ref resultDirection);
                        terrain.Tiles[PosNum.X, PosNum.Y].DownSide = resultDirection;
                    }
                }
                for (a = 0; a <= painter.CliffBrushes[painterBrushNum].Tiles_Corner_In.TileCount - 1; a++)
                {
                    painterTexture = painter.CliffBrushes[painterBrushNum].Tiles_Corner_In.Tiles[a];
                    if (painterTexture.TextureNum == texture.TextureNum)
                    {
                        TileUtil.RotateDirection(painterTexture.Direction, texture.Orientation, ref resultDirection);
                        if (tile.Tri)
                        {
                            if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.TopLeft))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff   = true;
                            }
                            else if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.BottomRight))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff       = true;
                            }
                        }
                        else
                        {
                            if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.TopRight))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff    = true;
                            }
                            else if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.BottomLeft))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff      = true;
                            }
                        }
                    }
                }
                for (a = 0; a <= painter.CliffBrushes[painterBrushNum].Tiles_Corner_Out.TileCount - 1; a++)
                {
                    painterTexture = painter.CliffBrushes[painterBrushNum].Tiles_Corner_Out.Tiles[a];
                    if (painterTexture.TextureNum == texture.TextureNum)
                    {
                        oppositeDirection = painterTexture.Direction;
                        oppositeDirection.FlipX();
                        oppositeDirection.FlipY();
                        TileUtil.RotateDirection(oppositeDirection, texture.Orientation, ref resultDirection);
                        if (tile.Tri)
                        {
                            if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.TopLeft))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriTopLeftIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff   = true;
                            }
                            else if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.BottomRight))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriBottomRightIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff       = true;
                            }
                        }
                        else
                        {
                            if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.TopRight))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriTopRightIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff    = true;
                            }
                            else if (TileUtil.IdenticalTileDirections(resultDirection, TileUtil.BottomLeft))
                            {
                                terrain.Tiles[PosNum.X, PosNum.Y].TriBottomLeftIsCliff = true;
                                terrain.Tiles[PosNum.X, PosNum.Y].Terrain_IsCliff      = true;
                            }
                        }
                    }
                }
            }

            Map.SectorTerrainUndoChanges.TileChanged(PosNum);
        }
Exemplo n.º 2
0
        private void ToolPerformTile()
        {
            var PainterBrushNum = 0;
            var A = 0;

            for (PainterBrushNum = 0; PainterBrushNum <= Painter.TerrainCount - 1; PainterBrushNum++)
            {
                PainterTerrainA = Painter.Terrains[PainterBrushNum];
                for (A = 0; A <= PainterTerrainA.Tiles.TileCount - 1; A++)
                {
                    PainterTexture = PainterTerrainA.Tiles.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
            }
            for (PainterBrushNum = 0; PainterBrushNum <= Painter.TransitionBrushCount - 1; PainterBrushNum++)
            {
                PainterTerrainA = Painter.TransitionBrushes[PainterBrushNum].TerrainInner;
                PainterTerrainB = Painter.TransitionBrushes[PainterBrushNum].TerrainOuter;
                for (A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].TilesStraight.TileCount - 1; A++)
                {
                    PainterTexture = Painter.TransitionBrushes[PainterBrushNum].TilesStraight.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.DirectionsOnSameSide(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                    }
                }
                for (A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].TilesCornerIn.TileCount - 1; A++)
                {
                    PainterTexture = Painter.TransitionBrushes[PainterBrushNum].TilesCornerIn.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                    }
                }
                for (A = 0; A <= Painter.TransitionBrushes[PainterBrushNum].TilesCornerOut.TileCount - 1; A++)
                {
                    PainterTexture = Painter.TransitionBrushes[PainterBrushNum].TilesCornerOut.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        OppositeDirection = PainterTexture.Direction;
                        OppositeDirection.FlipX();
                        OppositeDirection.FlipY();
                        TileUtil.RotateDirection(OppositeDirection, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                    }
                }
            }

            for (PainterBrushNum = 0; PainterBrushNum <= Painter.CliffBrushCount - 1; PainterBrushNum++)
            {
                PainterTerrainA = Painter.CliffBrushes[PainterBrushNum].Terrain_Inner;
                PainterTerrainB = Painter.CliffBrushes[PainterBrushNum].Terrain_Outer;
                for (A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.TileCount - 1; A++)
                {
                    PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Straight.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.DirectionsOnSameSide(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                    }
                }
                for (A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.TileCount - 1; A++)
                {
                    PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_In.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TileUtil.RotateDirection(PainterTexture.Direction, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                    }
                }
                for (A = 0; A <= Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.TileCount - 1; A++)
                {
                    PainterTexture = Painter.CliffBrushes[PainterBrushNum].Tiles_Corner_Out.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        OppositeDirection = PainterTexture.Direction;
                        OppositeDirection.FlipX();
                        OppositeDirection.FlipY();
                        TileUtil.RotateDirection(OppositeDirection, Texture.Orientation, ref ResultDirection);
                        if (TileUtil.IdenticalTileDirections(VertexDirection, ResultDirection))
                        {
                            TerrainCount[PainterTerrainA.Num]++;
                        }
                        else
                        {
                            TerrainCount[PainterTerrainB.Num]++;
                        }
                    }
                }
            }

            for (PainterBrushNum = 0; PainterBrushNum <= Painter.RoadBrushCount - 1; PainterBrushNum++)
            {
                PainterTerrainA = Painter.RoadBrushes[PainterBrushNum].Terrain;
                for (A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_Corner_In.TileCount - 1; A++)
                {
                    PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_Corner_In.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
                for (A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_CrossIntersection.TileCount - 1; A++)
                {
                    PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_CrossIntersection.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
                for (A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_End.TileCount - 1; A++)
                {
                    PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_End.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
                for (A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_Straight.TileCount - 1; A++)
                {
                    PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_Straight.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
                for (A = 0; A <= Painter.RoadBrushes[PainterBrushNum].Tile_TIntersection.TileCount - 1; A++)
                {
                    PainterTexture = Painter.RoadBrushes[PainterBrushNum].Tile_TIntersection.Tiles[A];
                    if (PainterTexture.TextureNum == Texture.TextureNum)
                    {
                        TerrainCount[PainterTerrainA.Num]++;
                    }
                }
            }
        }