Exemplo n.º 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();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void Init()
 {
     this.vertices  = new List <Vector3> ();
     this.triangles = new List <int> ();
     this.uvs       = new List <Vector2> ();
     this.normals   = new List <Vector3> ();
     this.neighbors = new TileNeighbors();
 }
Exemplo n.º 3
0
    private ReadOnlyDictionary <Tile, TileNeighbors> GetNeighborsDictionary()
    {
        Dictionary <Tile, TileNeighbors> ret = new Dictionary <Tile, TileNeighbors>();

        foreach (Tile tile in _tiles.Values)
        {
            TileNeighbors neighbors = GetNeighborsList(tile);
            ret.Add(tile, neighbors);
        }
        return(new ReadOnlyDictionary <Tile, TileNeighbors>(ret));
    }
Exemplo n.º 4
0
        protected void LoadContextSource()
        {
            for (int z = 0; z < Depth; z++)
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        if (Tiles[x, y, z].Sprites == null)
                        {
                            continue;
                        }

                        TileNeighbors hood  = TileNeighbors.None;
                        TileStyle     style = Tiles[x, y, z].Style;

                        if ((GetStyle(x - 1, y - 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.TopLeft;
                        }
                        if ((GetStyle(x, y - 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.TopCenter;
                        }
                        if ((GetStyle(x + 1, y - 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.TopRight;
                        }
                        if ((GetStyle(x - 1, y, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.CenterLeft;
                        }
                        if ((GetStyle(x + 1, y, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.CenterRight;
                        }
                        if ((GetStyle(x - 1, y + 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.BottomLeft;
                        }
                        if ((GetStyle(x, y + 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.BottomCenter;
                        }
                        if ((GetStyle(x + 1, y + 1, z) & style) != TileStyle.None)
                        {
                            hood = hood | TileNeighbors.BottomRight;
                        }

                        Tiles[x, y, z].LoadContextualSource(hood);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public virtual void SetupNeighbours(IDictionary <Point, Tile> tilesPositions)
        {
            Tile north = null;
            Tile east  = null;
            Tile south = null;
            Tile west  = null;

            tilesPositions.TryGetValue(GridPosition + new Point(0, -1), out north);
            tilesPositions.TryGetValue(GridPosition + new Point(1, 0), out east);
            tilesPositions.TryGetValue(GridPosition + new Point(0, 1), out south);
            tilesPositions.TryGetValue(GridPosition + new Point(-1, 0), out west);
            var neighbours = new TileNeighbors(Check(north), Check(south), Check(east), Check(west));

            Neighbors = neighbours;
        }
Exemplo n.º 6
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();
        }