Esempio n. 1
0
        public EditorScreen(string levelPath)
        {
            if (!string.IsNullOrEmpty(levelPath))
            {
                _editorFile = new EditorFile(Path.GetDirectoryName(levelPath), Path.GetFileName(levelPath));
                this.LoadLevel(true);
            }
            else
            {
                _editorFile = new EditorFile();

                _level = EditorLevel.Generate();
                _levelRenderer = new EditorLevelRenderer(_level);
                _levelController = new EditorLevelController(_level);
            }
        }
Esempio n. 2
0
        private void LoadLevel(bool loadFromFile = true)
        {
            if (_levelRenderer != null)
            {
                _levelRenderer.Unload();
            }

            if (loadFromFile)
            {
                using (BinaryReader reader = new BinaryReader(File.OpenRead(_editorFile.FullPath)))
                {
                    _level = EditorLevel.Load(reader);
                }
            }
            else
            {
                _level = EditorLevel.Generate();
            }

            _levelRenderer = new EditorLevelRenderer(_level);
            _levelController = new EditorLevelController(_level);

            if (base.IsLoaded)
            {
                _levelRenderer.LoadContent();
                this.CreateUi();
            }
        }