Пример #1
0
    public void LoadLevel(string levelName)
    {
        if (!EditorManager.LevelExists(levelName))
        {
            return;
        }

        string path    = Application.persistentDataPath + "/Wolf3DLevels/" + levelName + ".json";
        bool   fromRes = false;

        if (!File.Exists(path))
        {
            TextAsset level = Resources.Load <TextAsset>($"Maps/{levelName}");
            if (level)
            {
                fromRes = true;
                path    = levelName;
            }
            else
            {
                Debug.LogError($"Couldn't find map with name {levelName}");
                return;
            }
        }

        Debug.Log("Opening level " + path);

        ClearLevel();
        level = LevelSerialiser.LoadLevel(path, fromRes);
        LoadTiles();
        LoadEntities();
        mouseLook = playerObject.GetComponentInChildren <PlayerMouseLook>();
        mapInfoPanel.SetValues(level.name, tilesCount, enemyCount);
        mapNameText.text = level.name;
    }
Пример #2
0
    public void LoadLevel(string name)
    {
        if (!File.Exists(Application.persistentDataPath + "/Wolf3DLevels/" + name + ".json"))
        {
            Debug.Log("Level " + Application.persistentDataPath + "/Wolf3DLevels/" + name + ".json not found.");
            return;
        }

        Debug.Log("Opening level " + Application.persistentDataPath + "/Wolf3DLevels/" + name + ".json");

        ClearEditor();
        level = LevelSerialiser.LoadLevel(Application.persistentDataPath + "/Wolf3DLevels/" + name + ".json", false);
        levelNameControl.SetName(level.name);
        LoadTiles();
        LoadEntities();
    }
Пример #3
0
 public void Save()
 {
     Debug.Log("Saving level.");
     LevelSerialiser.Save(level);
 }