public void SaveBtn()
    {
        if (_caveParent == null)
        {
            _caveParent = GameObject.Find("Caves").GetComponent <Transform>();
        }
        GetNumSections();
        Level.Caves = new LevelContainer.CaveType[_numSections];
        InitialiseCaveList();
        StoreCaveIndexes();

        StoreStalactites();
        StoreMushrooms();
        StoreMoths();
        StoreSpiders();
        StoreWebs();
        StoreTriggers();
        StoreNpcs();

        string       levelName = LevelId + ".xml";
        const string pathName  = "Assets/Resources/LevelXML";

        Level.Save(Path.Combine(pathName, levelName));
        Debug.Log("Level data saved to " + pathName + "/" + levelName);
    }
Example #2
0
    public void SaveLevel(string levelFilePath)
    {
        LevelContainer newLevel = new LevelContainer();

        newLevel.rows      = _rows;
        newLevel.cols      = _cols;
        newLevel.numLayers = numLayers;
        newLevel.layers    = new TileMapContainer[numLayers];
        for (int x = 0; x < numLayers; ++x)
        {
            newLevel.layers[x]       = new TileMapContainer();
            newLevel.layers[x].rows  = _rows;
            newLevel.layers[x].cols  = _cols;
            newLevel.layers[x].cells = new Cell[_rows * _cols];
            for (int i = 0; i < _rows; ++i)
            {
                for (int j = 0; j < _cols; ++j)
                {
                    Tile workingTile = layers[x]._tileMap[i, j].GetComponent <Tile>();
                    Cell workingCell = new Cell();
                    workingCell.x         = i;
                    workingCell.y         = j;
                    workingCell.scaleX    = (int)workingTile.transform.localScale.x;
                    workingCell.scaleY    = (int)workingTile.transform.localScale.y;
                    workingCell.rotation  = (int)workingTile.transform.rotation.eulerAngles.z;
                    workingCell.tileType  = (int)workingTile.GetTileType();
                    workingCell.tileShape = (int)workingTile.GetTileShape();
                    workingCell.spriteID  = (int)workingTile.GetSpriteID();
                    newLevel.layers[x].cells[i + (j * _rows)] = workingCell;
                }
            }
        }
        _xmlContainer = newLevel;
        Debug.Log(_xmlContainer.layers.Length);
        _xmlContainer.Save(Path.Combine(Application.dataPath + "/Resources", levelFilePath + ".txt"));
    }
Example #3
0
    /**Haalt alle levels in een file op, mits de file bestaat en voegt er een nieuwe entry aan toe*/
    public void WriteData(string reason)
    {
        LevelContainer levelCollection;
        List<Level> levels;

        /**Als file bestaat haal alle bestaaned data op en voeg een entry toe, anders maak een bestand */
        if (File.Exists(Path.Combine(Application.persistentDataPath, "gamedata.xml")))
        {
            Debug.Log("File Found");
            levelCollection = LevelContainer.Load(Path.Combine(Application.persistentDataPath, "gamedata.xml"));
            levels = levelCollection.Levels;
            bool hasLevel = false;
            foreach (Level l in levels)
            {
                if (l.lastLevel == Application.loadedLevel - 1)
                    hasLevel = true;
            }
            if (!hasLevel)
                levels.Add(new Level(Application.loadedLevel - 1));

            foreach (Level l in levels)
            {
                if(l.lastLevel == Application.loadedLevel - 1)
                {
                    l.AddPoging(msEind, vKStart, dKStart, Mass, Score, reason, l.pogingen.Count + 1);

                }
            }
            Debug.Log(Path.Combine(Application.persistentDataPath, "gamedata.xml"));
            levelCollection.Save(Path.Combine(Application.persistentDataPath, "gamedata.xml"));

        }
        else
        {
            levels = new List<Level>();
            levelCollection = new LevelContainer(levels);
            levels.Add(new Level(Application.loadedLevel - 1));
            foreach (Level l in levels)
            {
                if (l.lastLevel == Application.loadedLevel - 1)
                {
                    l.AddPoging(msEind, vKStart, dKStart, Mass, Score, reason, 1);
                }
            }
            Debug.Log(Path.Combine(Application.persistentDataPath, "gamedata.xml"));
            levelCollection.Save(Path.Combine(Application.persistentDataPath, "gamedata.xml"));
        }
    }