Пример #1
0
        public static void CreateTraversableNodeMap()
        {
            BitArray ba = new BitArray((WIDTH * HEIGHT), false);

            byte[] buff = new byte[1];

            for (int j = 0; j < WIDTH; j++)
            {
                for (int i = 0; i < HEIGHT; i++)
                {
                    _mapViewSteam.Position = ((WIDTH * i) + (j));
                    int offset = 0;
                    int read   = _mapViewSteam.Read(buff, offset, 1);
                    if (buff[0] > 4)
                    {
                        ba[((WIDTH * i) + (j))] = false;
                    }
                    else
                    {
                        ba[((WIDTH * i) + (j))] = true;
                    }
                }
            }

            // Save data to file
            FileStream stream = new FileStream("C:\\Traversable.bin", FileMode.OpenOrCreate);

            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(stream, ba);
            stream.Close();
        }
 /// <summary>
 ///
 /// </summary>
 public virtual int Read(byte[] buffer, int offset, int count)
 {
     if (!m_IsOpen)
     {
         return(-1);
     }
     if (m_Count < count)
     {
         count = m_Count;                        // Get min size.
     }
     count = m_Stream.Read(buffer, offset, count);
     return(count);
 }
Пример #3
0
 public static byte[] Read(int offset, int count)
 {
     byte[] b = new byte[count];
     if (mapViewStream != null)
     {
         mapViewStream.Read(offset, b, 0, count);
     }
     else
     {
         NekoClient.Logging.Log.Info("error when try to read memory: mapView is null");
     }
     return(b);
 }