Esempio n. 1
0
 //initialize using permanent data for a level, savedData can either be passed or a new empty object will be created
 public LevelData(LevelPermanentData permanentData, LevelSaveData savedData = null)
 {
     permData = permanentData;
     if (savedData == null)
     {
         savedData = new LevelSaveData(GetLevelID());
     }
     saveData = savedData;
 }
Esempio n. 2
0
    //returns the index of the currentLevel in the childLevels array
    private int FindChildLevel(LevelPermanentData level)
    {
        int ind = 0;

        for (int i = 0; i < childLevels.Count; i++)
        {
            if (childLevels [i] == level)
            {
                ind = i;
            }
        }
        return(ind);
    }
    public static void CreateLevelDataAsset()
    {
        LevelPermanentData asset = ScriptableObject.CreateInstance <LevelPermanentData> ();
        int num = 0;

        while (AssetDatabase.FindAssets("LevelPermanentData" + num, new string[] { "Assets/ScriptableObjects" }).Length > 0)
        {
            num += 1;
        }
        AssetDatabase.CreateAsset(asset, "Assets/ScriptableObjects/LevelPermanentData" + num + ".asset");
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        Selection.activeObject = asset;
    }
Esempio n. 4
0
    //returns the levelId of the level preceeding the currentLevel
    //if the current level is the first in the world, returns 0
    public int GetPreviousLevelID(LevelPermanentData level)
    {
        int ind = FindChildLevel(level);

        return(ind > 0 ? childLevels[ind - 1].levelID : 0);
    }
Esempio n. 5
0
    //returns the levelID of the level following on from the currentLevel
    //if the current level is the last in the world, returns 0
    public int GetNextLevelID(LevelPermanentData level)
    {
        int ind = FindChildLevel(level);

        return(ind < childLevels.Count - 1 ?  childLevels[ind + 1].levelID : 0);
    }