Ejemplo n.º 1
0
    public static LevelDataList CreateLevelDataList()
    {
        LevelDataList asset = ScriptableObject.CreateInstance <LevelDataList>();

        AssetDatabase.CreateAsset(asset, "Assets/LevelDataList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
Ejemplo n.º 2
0
    public void PassLevel(int level)
    {
        levelDataList = ReadFromBinaryFile <LevelDataList>(path);

        levelDataList.levels[level - 1] = true;

        WriteToBinaryFile(path, levelDataList);
    }
Ejemplo n.º 3
0
    public void setStateFuctions(List <StateFunction> stateFunctions, int level)
    {
        levelDataList = ReadFromBinaryFile <LevelDataList>(path);

        levelDataList.levelDataList[level - 1].stateFunctions = stateFunctions;

        WriteToBinaryFile(path, levelDataList);
    }
Ejemplo n.º 4
0
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         _levelDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(LevelDataList)) as LevelDataList;
     }
 }
Ejemplo n.º 5
0
 void CreateNewLevelList()
 {
     viewIndex      = 1;
     _levelDataList = CreateLevelList.CreateLevelDataList();
     if (_levelDataList)
     {
         _levelDataList.levelList = new List <Level>();
         string relPath = AssetDatabase.GetAssetPath(_levelDataList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Ejemplo n.º 6
0
    private void Awake()
    {
        path = Application.dataPath + "/Save Data";

        levelDataList = new LevelDataList();

        if (!File.Exists(path))
        {
            WriteToBinaryFile(path, levelDataList); // for new builds
        }
        levelDataList = ReadFromBinaryFile <LevelDataList>(path);
    }
Ejemplo n.º 7
0
    public static LevelID[] GetAllLevelIDs()
    {
        List <LevelID> ids = new List <LevelID>();

        LevelDataList[] lists = Instance.levelDatas.Data;
        for (int type = 0; type < lists.Length; type++)
        {
            LevelDataList list = lists[type];
            for (int index = 0; index < list.list.Length; index++)
            {
                ids.Add(new LevelID((LevelType)type, index));
            }
        }
        return(ids.ToArray());
    }
Ejemplo n.º 8
0
    void OpenLevelList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select level item list", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            _levelDataList = AssetDatabase.LoadAssetAtPath(relPath, typeof(LevelDataList)) as LevelDataList;
            if (_levelDataList.levelList == null)
            {
                _levelDataList.levelList = new List <Level>();
            }
            if (_levelDataList)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
Ejemplo n.º 9
0
 public List <StateFunction> getStateFunctions(int level)
 {
     levelDataList = ReadFromBinaryFile <LevelDataList>(path);
     return(levelDataList.levelDataList[level - 1].stateFunctions);
 }
Ejemplo n.º 10
0
    public List <bool> GetLevels()
    {
        levelDataList = ReadFromBinaryFile <LevelDataList>(path);

        return(levelDataList.levels);
    }