Esempio n. 1
0
    public void LoadTileMap(String mapText)
    {
        Array.Clear(Tiles, 0, Tiles.Length);
        levelData = new LevelData();
        levelData.LevelDataXML(mapText);
        Tiles = new int[(int)levelData.getTileMapSize().x, (int)levelData.getTileMapSize().y];
        Debug.Log(levelData.getTileMapSize().x + " " + levelData.getTileMapSize().y);
        // fill TileMap with zeroes.
        loadTiles();
        TileMap.CurrentMap = this;
        // size of the map
        lengthI = Tiles.GetLength(1);
        lengthJ = Tiles.GetLength(0);

        portals = getLevelData().getPortalSpawns();

        for (int x = portals.Count - 1; x >= 0; x--)
        {
            portals[x].SetPosition(portals[x].getPosition());
            AddChild(portals[x]);
        }

        hazards = getLevelData().getHazardSpawns();

        for (int x = hazards.Count - 1; x >= 0; x--)
        {
            FSprite haz = new FSprite("hazard");
            haz.SetPosition(hazards[x].getPosition());
            AddChild(haz);
        }

        for (int x = getLevelData().getEnemySpawns().Count - 1; x >= 0; x--)
        {

        }
        items = new List<Item>();
        if (getLevelData().getItemSpawns() !=null)
        for (int x = getLevelData().getItemSpawns().Count - 1; x >= 0; x--)
        {
            Item it = new Item(getLevelData().getItemSpawns()[x]);
            it.SetPosition(it.getPosition());
            items.Add(it);
            AddChild(it);
        }
        enemies = new List<Entity>();
        if (getLevelData().getEnemySpawns() != null)
            for (int x = getLevelData().getEnemySpawns().Count - 1; x >= 0; x--)
            {
                EnemyPortal it = new EnemyPortal(getLevelData().getEnemySpawns()[x]);
                it.SetPosition(it.Position);
                enemies.Add(it);
                AddChild(it);
            }
    }