Beispiel #1
0
 public static string[] getCharFile(string path)
 {
     //path = path.ToUpper();
     if (!loadedCharFiles.ContainsKey(path))
     {
         string[] loaded = System.IO.File.ReadAllLines(ContentDistributor.addNecesaryPathing(path));
         loadedCharFiles.Add(path, loaded);
         return(loaded);
     }
     else
     {
         return(loadedCharFiles[path]);
     }
 }
Beispiel #2
0
        static PaintedCubeSpace loadSpaceFromDisk(string path)
        {
            byte[, ,] byteArray;
            string fullPath = ContentDistributor.addNecesaryPathing(path);
            Stream stream   = File.Open(fullPath, FileMode.Open);

            BinaryFormatter formatter = new BinaryFormatter();

            byteArray = (byte[, , ])formatter.Deserialize(stream);

            FileInfo fileInfo    = new FileInfo(fullPath);
            long     fileLength  = fileInfo.Length;
            int      spaceWidth  = (int)Math.Pow(fileLength, 1.0 / 3.0);
            int      spaceHeight = (int)Math.Pow(fileLength, 1.0 / 3.0);

            stream.Close();

            //loadedByteArrays.Add(path, byteArray);
            PaintedCubeSpace paintedCubeSpace = new PaintedCubeSpace(1, 1, new Vector3());

            paintedCubeSpace.spaceWidth  = spaceWidth;
            paintedCubeSpace.spaceHeight = spaceHeight;
            paintedCubeSpace.array       = byteArray;

            paintedCubeSpace.createModel(Main.graphics.GraphicsDevice);

            LoadedCubeSpaceData dataToSave = new LoadedCubeSpaceData();

            dataToSave.array        = byteArray;
            dataToSave.spaceHeight  = spaceHeight;
            dataToSave.spaceWidth   = spaceWidth;
            dataToSave.vertexBuffer = paintedCubeSpace.getVertexBuffer();
            dataToSave.indexBuffer  = paintedCubeSpace.getIndexBuffer();
            loadedByteArrays.Add(path, dataToSave);

            paintedCubeSpace.setLoadedFrompath(path);
            return(paintedCubeSpace);
        }