Esempio n. 1
0
    private MapPair SpawnMapPair(string mapName, Vector3 origin, Vector2 sizeLerp)
    {
        var mapEntry = mapNames.GetEntry(mapName);
        var map      = SpawnTilemap(mapEntry.tiled, Vector3.zero);
        var mapSize  = MapSize(map);

        origin += new Vector3(sizeLerp.x * mapSize.x, sizeLerp.y * mapSize.y);
        isDead  = IsSpirit(mapName);
        var mapPair = new MapPair(NormalizeName(mapName));

        isDead = IsSpirit(mapName);

        if (isDead)
        {
            var otherEntry = mapNames.GetEntry(NormalizeName(mapName));

            mapPair.deadMap   = map;
            mapPair.livingMap = SpawnTilemap(otherEntry.tiled, UnusedOffset);
        }
        else
        {
            var otherEntry = mapNames.GetEntry(SpiritName(mapName));

            mapPair.deadMap   = SpawnTilemap(otherEntry.tiled, UnusedOffset);
            mapPair.livingMap = map;
        }

        SetActiveMap(map);
        currentMap = mapPair;

        var min = LerpMap(map, Vector2.zero);
        var max = LerpMap(map, Vector2.one);

        worldBounds.min = Vector3.Min(min, max);
        worldBounds.max = Vector3.Max(min, max);

        if (followCamera != null)
        {
            followCamera.bounds = worldBounds;
        }

        return(mapPair);
    }