コード例 #1
0
    static public void SaveGameplay(ShapeData[] t_shapes, InventoryData t_inventory)
    {
        LevelData levelData = new LevelData();


        foreach (ShapeData shape in t_shapes)
        {
            SaveShapeData shapeData = new SaveShapeData();

            shapeData.name           = shape.name;
            shapeData.objectPosition = shape.m_position;

            levelData.m_saveShapeDatas.Add(shapeData);
        }

        SaveInventoryData inventoryData = new SaveInventoryData();

        inventoryData.itemTypes       = t_inventory.m_inventoryItems;
        levelData.m_saveInventoryData = inventoryData;

        string jsonData = JsonUtility.ToJson(levelData, true);
        string fullPath = s_jsonPath + s_currentLevel + ".txt";

        System.IO.File.WriteAllText(fullPath, jsonData);
    }
コード例 #2
0
    static public void SaveLevel(ShapeData[] t_shapes)
    {
        float     m_numberOfLevel = 0;
        LevelData levelData       = new LevelData();

        foreach (ShapeData shape in t_shapes)
        {
            SaveShapeData shapeData = new SaveShapeData();

            shapeData.name           = shape.name;
            shapeData.objectPosition = shape.m_position;

            levelData.m_saveShapeDatas.Add(shapeData);
        }

        m_numberOfLevel++;
        string jsonData = JsonUtility.ToJson(levelData, true);
        string fullPath = s_jsonPath + "Level" + m_numberOfLevel + ".txt";

        System.IO.File.WriteAllText(fullPath, jsonData);
    }