Esempio n. 1
0
    public void Init(TextAsset mapFile, Material tileSheet, Material wallMaterial)
    {
        foreach (Transform child in tileContainer)
        {
            DestroyObject(child.gameObject);
        }
        foreach (Transform child in objectContainer)
        {
            DestroyObject(child.gameObject);
        }
        TmxMap map;

        map = new TmxMap(mapFile.text, "rnd");
        this.wallMaterial = wallMaterial;

        horizontal_tiles = map.Width;
        vertical_tiles   = map.Height;

        tile_width  = map.TileWidth;
        tile_height = map.TileHeight;

        //tileSetName = map.Tilesets[0].Name;
        firstGids = new int[map.Tilesets.Count];
        mapTitle  = map.Properties["Title"];
        time      = IntParseFast(map.Properties["Time"]);
        villains  = IntParseFast(map.Properties["Villain"]);
        gold      = IntParseFast(map.Properties["Gold"]);
        timer.Init(time);

        tileMap = new Map(map.Width, map.Height);

        if (map.Layers.Count > 0)
        {
            GenerateTiles(map.Layers);
            mapDebug.text = tileMap.PrintableString();
        }

        if (map.ObjectGroups.Count > 0)
        {
            GenerateObjects(map.ObjectGroups);
        }
        hero.SetEndSpot(endX, endY);

        foreach (Transform child in tempContainer)
        {
            DestroyObject(child.gameObject);
        }
        manager.MapGenerationCallBack(this);
    }