Пример #1
0
    protected override bool GetNeighbourTile(int tileX, int tileY, float offsetX, float offsetZ, int tileCountOnX, int tileCountOnY, NeighbourTileDirection dir, out int nTileX, out int nTileY, out float nOffsetX, out float nOffsetZ)
    {
        bool ret = false;
        nTileX = 0;
        nTileY = 0;
        nOffsetX = 0.0f;
        nOffsetZ = 0.0f;

        switch (dir)
        {
        case NeighbourTileDirection.South:
            if ((tileY + 1) < tileCountOnY)
            {
         			nTileX = tileX;
                nTileY = tileY + 1;
                nOffsetX = offsetX;
                nOffsetZ = offsetZ - Map.RoundedHalfMapScale;
                ret = true;
            }
            break ;

        case NeighbourTileDirection.North:
            if (tileY > 0)
            {
         			nTileX = tileX;
                nTileY = tileY - 1;
                nOffsetX = offsetX;
                nOffsetZ = offsetZ + Map.RoundedHalfMapScale;
                ret = true;
            }
            break ;

        case NeighbourTileDirection.East:
            if ((tileX + 1) < tileCountOnX)
            {
         			nTileX = tileX + 1;
                nTileY = tileY;
                nOffsetX = offsetX + Map.RoundedHalfMapScale;
                nOffsetZ = offsetZ;
                ret = true;
            }
            break ;

        case NeighbourTileDirection.West:
            if (tileX > 0)
            {
         			nTileX = tileX - 1;
                nTileY = tileY;
                nOffsetX = offsetX - Map.RoundedHalfMapScale;
                nOffsetZ = offsetZ;
                ret = true;
            }
            break ;
        }

        return ret;
    }
Пример #2
0
 // <summary>
 // Writes the tile coordinates and offsets to the origin for the neighbour tile in the specified direction.
 // </summary>
 protected abstract bool GetNeighbourTile(int tileX, int tileY, float offsetX, float offsetY, int tileCountOnX, int tileCountOnY, NeighbourTileDirection dir, out int nTileX, out int nTileY, out float nOffsetX, out float nOffsetZ);
Пример #3
0
        /// <summary>
        /// Gets a neighbour tile. See <see cref="UnitySlippyMap.Layers.TileLayerBehaviour.GetNeighbourTile"/>.
        /// </summary>
        /// <returns><c>true</c>, if neighbour tile was gotten, <c>false</c> otherwise.</returns>
        /// <param name="tileX">Tile x.</param>
        /// <param name="tileY">Tile y.</param>
        /// <param name="offsetX">Offset x.</param>
        /// <param name="offsetZ">Offset z.</param>
        /// <param name="tileCountOnX">Tile count on x.</param>
        /// <param name="tileCountOnY">Tile count on y.</param>
        /// <param name="dir">Dir.</param>
        /// <param name="nTileX">N tile x.</param>
        /// <param name="nTileY">N tile y.</param>
        /// <param name="nOffsetX">N offset x.</param>
        /// <param name="nOffsetZ">N offset z.</param>
        protected override bool GetNeighbourTile(int tileX, int tileY, float offsetX, float offsetZ, int tileCountOnX, int tileCountOnY, NeighbourTileDirection dir, out int nTileX, out int nTileY, out float nOffsetX, out float nOffsetZ)
        {
            bool ret = false;

            nTileX   = 0;
            nTileY   = 0;
            nOffsetX = 0.0f;
            nOffsetZ = 0.0f;

            switch (dir)
            {
            case NeighbourTileDirection.South:
                if ((tileY + 1) < tileCountOnY)
                {
                    nTileX   = tileX;
                    nTileY   = tileY + 1;
                    nOffsetX = offsetX;
                    nOffsetZ = offsetZ - Map.RoundedHalfMapScale;
                    ret      = true;
                }
                break;

            case NeighbourTileDirection.North:
                if (tileY > 0)
                {
                    nTileX   = tileX;
                    nTileY   = tileY - 1;
                    nOffsetX = offsetX;
                    nOffsetZ = offsetZ + Map.RoundedHalfMapScale;
                    ret      = true;
                }
                break;

            case NeighbourTileDirection.East:
                nTileX   = tileX + 1;
                nTileY   = tileY;
                nOffsetX = offsetX + Map.RoundedHalfMapScale;
                nOffsetZ = offsetZ;
                ret      = true;
                break;

            case NeighbourTileDirection.West:
                nTileX   = tileX - 1;
                nTileY   = tileY;
                nOffsetX = offsetX - Map.RoundedHalfMapScale;
                nOffsetZ = offsetZ;
                ret      = true;
                break;
            }


            return(ret);
        }
Пример #4
0
	// <summary>
	// Writes the tile coordinates and offsets to the origin for the neighbour tile in the specified direction.
	// </summary>
	protected abstract bool GetNeighbourTile(int tileX, int tileY, float offsetX, float offsetY, int tileCountOnX, int tileCountOnY, NeighbourTileDirection dir, out int nTileX, out int nTileY, out float nOffsetX, out float nOffsetZ);