コード例 #1
0
        public override void LoadContextualSource(TileNeighbors hood)
        {
            base.LoadContextualSource(hood);

            for (int z = DIVS - 1; z >= 0; z--)
            {
                for (int y = 0; y < DIVS; y++)
                {
                    for (int x = 0; x < DIVS; x++)
                    {
                        //	Check against the line of the slope
                        if (Incline.X == -1 && z + x >= DIVS - 1 || Incline.X == 1 && z >= x ||
                            Incline.Y == -1 && z + y >= DIVS - 1 || Incline.Y == 1 && z >= y)
                        {
                            // Check to see if an X slope is by nothing north/south
                            // or a Y slope by nothing east/west, to clone edge sprites
                            if (z > 0 && (
                                    (y == 0 && Registry.Stage.GetStyle(MapX, MapY - 1, MapZ) == TileStyle.None) ||
                                    (y == DIVS - 1 && Registry.Stage.GetStyle(MapX, MapY + 1, MapZ) == TileStyle.None) ||
                                    (x == 0 && Registry.Stage.GetStyle(MapX - 1, MapY, MapZ) == TileStyle.None) ||
                                    (x == DIVS - 1 && Registry.Stage.GetStyle(MapX + 1, MapY, MapZ) == TileStyle.None)))
                            {
                                Sprites[x, y, z - 1] = Sprites[x, y, z];
                            }

                            // Remove extra sprites above slope line
                            Sprites[x, y, z] = new Subtile();
                        }
                    }
                }
            }
        }
コード例 #2
0
 private void SmoothSubtiles()
 {
     for (int subZ = 0; subZ < Sprites.GetLength(2); subZ++)
     {
         for (int subY = 0; subY < Sprites.GetLength(1); subY++)
         {
             for (int subX = 0; subX < Sprites.GetLength(0); subX++)
             {
                 if (Sprites[subX, subY, subZ] == null)
                 {
                     if (subZ == DIVS - 1 || (
                             subX == 0 || subX == DIVS - 1 || subY == 0 || subY == DIVS - 1))
                     {
                         Sprites[subX, subY, subZ] = new Subtile(Subtile.Smooth, 0.0f);
                     }
                     else
                     {
                         Sprites[subX, subY, subZ] = new Subtile();
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
        public virtual void LoadContextualSource(TileNeighbors hood)
        {
            if (Registry.Stage.GetStyle(Position + new Vector3(Vector2.Zero, DEPTH)).HasFlag(Style))
            {
                SmoothSubtiles();
                return;
            }

            // index of top top subtile by depth
            int edge = DIVS - 1;

            // Make the four edge subtiles straight sprites if no like tile above
            if ((hood & TileNeighbors.TopCenter) != TileNeighbors.TopCenter)
            {
                for (int i = 0; i < Sprites.GetLength(0); i++)
                {
                    Sprites[i, 0, edge] = new Subtile(Subtile.Straight, 0.0f);
                }
            }
            if ((hood & TileNeighbors.BottomCenter) != TileNeighbors.BottomCenter)
            {
                for (int i = 0; i < Sprites.GetLength(0); i++)
                {
                    Sprites[i, Sprites.GetLength(1) - 1, edge] = new Subtile(Subtile.Straight, MathHelper.Pi);
                }
            }
            if ((hood & TileNeighbors.CenterLeft) != TileNeighbors.CenterLeft)
            {
                for (int i = 0; i < Sprites.GetLength(1); i++)
                {
                    Sprites[0, i, edge] = new Subtile(Subtile.Straight, -MathHelper.Pi / 2.0f);
                }
            }
            if ((hood & TileNeighbors.CenterRight) != TileNeighbors.CenterRight)
            {
                for (int i = 0; i < Sprites.GetLength(1); i++)
                {
                    Sprites[Sprites.GetLength(0) - 1, i, edge] = new Subtile(Subtile.Straight, MathHelper.Pi / 2.0f);
                }
            }

            // Make corner subtiles inside corners if adjacent tiles alike, but diagonal not
            if ((hood & (TileNeighbors.TopCenter | TileNeighbors.CenterRight)) == (TileNeighbors.TopCenter | TileNeighbors.CenterRight) &&
                (hood & TileNeighbors.TopRight) == TileNeighbors.None)
            {
                Sprites[Sprites.GetLength(0) - 1, 0, edge] = new Subtile(Subtile.Inside, 0.0f);
            }
            if ((hood & (TileNeighbors.BottomCenter | TileNeighbors.CenterRight)) == (TileNeighbors.BottomCenter | TileNeighbors.CenterRight) &&
                (hood & TileNeighbors.BottomRight) == TileNeighbors.None)
            {
                Sprites[Sprites.GetLength(0) - 1, Sprites.GetLength(1) - 1, edge] = new Subtile(Subtile.Inside, MathHelper.Pi / 2.0f);
            }
            if ((hood & (TileNeighbors.BottomCenter | TileNeighbors.CenterLeft)) == (TileNeighbors.BottomCenter | TileNeighbors.CenterLeft) &&
                (hood & TileNeighbors.BottomLeft) == TileNeighbors.None)
            {
                Sprites[0, Sprites.GetLength(1) - 1, edge] = new Subtile(Subtile.Inside, MathHelper.Pi);
            }
            if ((hood & (TileNeighbors.TopCenter | TileNeighbors.CenterLeft)) == (TileNeighbors.TopCenter | TileNeighbors.CenterLeft) &&
                (hood & TileNeighbors.TopLeft) == TileNeighbors.None)
            {
                Sprites[0, 0, edge] = new Subtile(Subtile.Inside, -MathHelper.Pi / 2.0f);
            }

            // Make corner subtiles outside corners if like-tiles adjacent on opposite sides
            if ((hood & (TileNeighbors.TopCenter | TileNeighbors.CenterRight)) == TileNeighbors.None)
            {
                Sprites[Sprites.GetLength(0) - 1, 0, edge] = new Subtile(Subtile.Outside, 0.0f);
            }
            if ((hood & (TileNeighbors.BottomCenter | TileNeighbors.CenterRight)) == TileNeighbors.None)
            {
                Sprites[Sprites.GetLength(0) - 1, Sprites.GetLength(1) - 1, edge] = new Subtile(Subtile.Outside, MathHelper.Pi / 2.0f);
            }
            if ((hood & (TileNeighbors.BottomCenter | TileNeighbors.CenterLeft)) == TileNeighbors.None)
            {
                Sprites[0, Sprites.GetLength(1) - 1, edge] = new Subtile(Subtile.Outside, MathHelper.Pi);
            }
            if ((hood & (TileNeighbors.TopCenter | TileNeighbors.CenterLeft)) == TileNeighbors.None)
            {
                Sprites[0, 0, edge] = new Subtile(Subtile.Outside, -MathHelper.Pi / 2.0f);
            }

            SmoothSubtiles();
        }