public bool LoadForEditor(LevelManager levelManager)
        {
            SaveLevelFile save = Serialization.LoadLevel(levelName);

            if (save == null)
            {
                return(false);
            }

            if (debugNode)
            {
                debugNodeObject = WorldNode(true);
            }

            sizeX = save.sizeX;
            sizeY = save.sizeY;
            sizeZ = save.sizeZ;

            scaleXZ = save.scaleXZ;
            scaleY  = save.scaleY;

            Checks();
            CreateGrid();
            LoadLevel(save);

            return(true);
        }
        public static void SaveLevel(string saveName, GridBase gridBase)
        {
            if (string.IsNullOrEmpty(saveName))
            {
                saveName = "level1";
            }

            SaveLevelFile saveFile = new SaveLevelFile();

            saveFile.sizeX = gridBase.sizeX;
            saveFile.sizeY = gridBase.sizeY;
            saveFile.sizeZ = gridBase.sizeZ;

            saveFile.scaleXZ    = gridBase.scaleXZ;
            saveFile.scaleY     = gridBase.scaleY;
            saveFile.scaleXZ    = gridBase.scaleXZ;
            saveFile.savedNodes = NodeToSaveable(gridBase);

            string saveLocation = SaveLocation();

            saveLocation += saveName;

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(saveLocation, FileMode.Create, FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, saveFile);
            stream.Close();
        }
        bool CheckForSavedLevel()
        {
            SaveLevelFile save = Serialization.LoadLevel(levelName);

            if (save == null)
            {
                return(false);
            }

            savedLevel = save;

            return(true);
        }
        void LoadLevel(SaveLevelFile sf = null)
        {
            SaveLevelFile targetSaveFile = sf;

            if (targetSaveFile == null)
            {
                targetSaveFile = savedLevel;
            }

            List <SaveableNode> s = targetSaveFile.savedNodes;

            for (int i = 0; i < s.Count; i++)
            {
                grid[s[i].x, s[i].y, s[i].z].ChangeNodeStatus(s[i].isWalkable, this);
            }
        }
        public static SaveLevelFile LoadLevel(string loadName)
        {
            SaveLevelFile saveFile = null;

            string targetName = SaveLocation();

            targetName += loadName;

            if (!File.Exists(targetName))
            {
                Debug.Log("Can't find level " + targetName);
            }
            else
            {
                IFormatter    formatter  = new BinaryFormatter();
                FileStream    fileStream = new FileStream(targetName, FileMode.Open);
                SaveLevelFile save       = (SaveLevelFile)formatter.Deserialize(fileStream);

                saveFile = save;
                fileStream.Close();
            }

            return(saveFile);
        }