Пример #1
0
        //텍스트로 저장된 맵데이터를 파싱한다
        public bool Load(string strFilename)
        {
            CPaser ps = new CPaser();

            if (!ps.Load(strFilename))
            {
                return(false);
            }

            ps.SetCodePage(949);

            mMapData = null;

            byte[] buf = new byte[1024];

            int pos = 0;

            while (true)
            {
                int len = ps.GetOne(buf);
                if (len == 0)
                {
                    break;
                }

                if (ps.Compare(buf, "width")) //맵의 가로 셀 개수
                {
                    mWidth = ps.GetInt(buf);
                    continue;
                }
                else if (ps.Compare(buf, "height")) //맵의 세로 셀 개수
                {
                    mHeight = ps.GetInt(buf);
                    continue;
                }
                else if (ps.Compare(buf, "mapstart"))      //이후부터 맵데이터가 시작된다.
                {
                    mMapData = new byte[mWidth * mHeight]; //셀 개수만큼 배열을 할당하고
                    pos      = 0;
                }
                else
                {
                    //맵데이터 파싱하기

                    string conv = Encoding.GetEncoding(949).GetString(buf, 0, len);

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

                    mMapData[pos++] = (byte)int.Parse(conv);
                }
            }

            return(true);
        }
Пример #2
0
        //텍스트로 저장된 맵데이터를 파싱한다
        public bool Load(string strFilename)
        {
            CPaser ps = new CPaser();

            if (!ps.Load(strFilename))
            {
                return(false);
            }

            ps.SetCodePage(949);

            m_MapData = null;

            byte[] buf = new byte[1024];

            int iPos = 0;

            while (true)
            {
                int len = ps.GetOne(buf);
                if (len == 0)
                {
                    break;
                }

                if (ps.Compare(buf, "width"))
                {
                    m_iWidth = ps.GetInt(buf);
                    continue;
                }
                else if (ps.Compare(buf, "height"))
                {
                    m_iHeight = ps.GetInt(buf);
                    continue;
                }
                else if (ps.Compare(buf, "mapstart"))
                {
                    m_MapData = new byte[m_iWidth * m_iHeight];
                    iPos      = 0;
                }
                else
                {
                    string conv = Encoding.GetEncoding(949).GetString(buf, 0, len);
                    if (conv == null)
                    {
                        return(false);
                    }
                    m_MapData[iPos++] = (byte)int.Parse(conv);
                }
            }

            return(true);
        }