Esempio n. 1
0
        // Set the correct sprite for a tile connected in 1 direction
        // The Sprite arguments should show variations for the same direction
        // depending on adjacent ocean tiles
        // checkOceanLeft and checkOceanRight specify offsets to use when
        // checking for ocean tiles
        protected virtual void Set1ConnectionSprite(
            Vector3Int position, Vector2Int checkOceanLeft,
            Vector2Int checkOceanRight, ITilemap tilemap, Sprite source,
            Sprite mouthStraight, Sprite mouthLeft, Sprite mouthRight)
        {
            // Is there an ocean tile on the left bank?
            Vector3Int checkOceanPos = new Vector3Int(
                Globals.WrappedCoord(position.x + checkOceanLeft.x,
                                     Parameters.Width, Parameters.WrapX),
                Globals.WrappedCoord(position.y + checkOceanLeft.y,
                                     Parameters.Height, Parameters.WrapY), 0);
            bool leftOcean =
                checkOceanPos.x != -1 && checkOceanPos.y != -1 &&
                LandTilemap.GetTile <Tile>(checkOceanPos).Elevation < 0.0f;

            // Is there an ocean tile on the right bank?
            checkOceanPos = new Vector3Int(
                Globals.WrappedCoord(position.x + checkOceanRight.x,
                                     Parameters.Width, Parameters.WrapX),
                Globals.WrappedCoord(position.y + checkOceanRight.y,
                                     Parameters.Height, Parameters.WrapY), 0);
            bool rightOcean =
                checkOceanPos.x != -1 && checkOceanPos.y != -1 &&
                LandTilemap.GetTile <Tile>(checkOceanPos).Elevation < 0.0f;

            if (leftOcean && rightOcean)
            {
                // Straight river mouth
                sprite = mouthStraight;
            }
            else if (leftOcean)
            {
                // River mouth turning left
                sprite = mouthLeft;
            }
            else if (rightOcean)
            {
                // River mouth turning right
                sprite = mouthRight;
            }
            else
            {
                // River source
                sprite = source;
            }
        }
Esempio n. 2
0
        // Set the correct sprite for a tile connected in 2 adjacent directions
        // The Sprite arguments should show variations for the same directions
        // depending on whether an ocean tile is adjacent
        // checkOcean specifies offset to use when checking for ocean tile
        protected virtual void SetLSprite(
            Vector3Int position, Vector2Int checkOcean, ITilemap tilemap,
            Sprite bend, Sprite mouth)
        {
            Vector3Int checkOceanPos = new Vector3Int(
                Globals.WrappedCoord(position.x + checkOcean.x,
                                     Parameters.Width, Parameters.WrapX),
                Globals.WrappedCoord(position.y + checkOcean.y,
                                     Parameters.Height, Parameters.WrapY), 0);
            bool ocean =
                checkOceanPos.x != -1 && checkOceanPos.y != -1 &&
                LandTilemap.GetTile <Tile>(checkOceanPos).Elevation < 0.0f;

            if (ocean)
            {
                // Two rivers' mouth
                sprite = mouth;
            }
            else
            {
                // River bend
                sprite = bend;
            }
        }