Esempio n. 1
0
        public static void POSTSvrstr(string query, string param, Action <string> cb, bool rcvJSONHandler = true, string method = "POST")
        {
            bool flag = query == null || query == "" || cb == null;

            if (!flag)
            {
                IURLReq iURLReq = os.net.CreateURLReq(null);
                iURLReq.url         = query;
                iURLReq.contentType = "application/x-www-form-urlencoded";
                iURLReq.dataFormat  = "text";
                string text = "";
                text += param;
                debug.Log(" POSTSvr query:" + query + "\n param:" + param);
                iURLReq.data   = text;
                iURLReq.method = method;
                iURLReq.load(delegate(IURLReq r, object vari)
                {
                    bool flag2 = vari == null;
                    if (flag2)
                    {
                        DebugTrace.print(" POSTSvr urlReq.load vari Null!");
                    }
                    string text2 = vari as string;
                    DebugTrace.print(" POSTSvr urlReq.loaded str[" + text2 + "]!");
                    Variant variant = JsonManager.StringToVariant(text2, true);
                    bool flag3      = cb != null;
                    if (flag3)
                    {
                        cb(text2);
                    }
                }, null, null);
            }
        }
        public void dataGrd(string path, Action onfin)
        {
            IURLReq urlreqimpl = m_mgr.g_netM.getUrlImpl();

            urlreqimpl.url        = path;
            urlreqimpl.dataFormat = "binary";            //text, binary, assetbundle

            debug.Log("处理地图的阻挡数据,数据的文件位置" + path);

            urlreqimpl.load(
                (IURLReq r, object ret) =>
            {
                byte[] data = ret as byte[];

                //解压地图阻挡数据
                ByteArray msk_data = new ByteArray(data);
                msk_data.uncompress();

                m_grd = new short[msk_data.length / 2];
                int n = 0;
                while (msk_data.bytesAvailable > 0)
                {
                    m_grd[n++] = msk_data.readShort();    // br.ReadInt16();
                }

                msk_data.clear();

                onfin();
            },
                (IURLReq url, float prog) => {
                Variant v = new Variant();
                v["tp"]   = GameConstant.LOADING_MAP_GRD;
                v["prog"] = prog;

                GameTools.PrintNotice("LOADING_MAP_GRD load prog:" + prog);

                m_mgr.g_gameM.dispatchEvent(
                    GameEvent.Createimmedi(GAME_EVENT.GAME_LOADING, this, v)
                    );
            },
                (IURLReq url, string err) => {
                Variant v = new Variant();
                v["tp"]   = GameConstant.LOADING_MAP_GRD;
                v["err"]  = err;
                m_mgr.g_gameM.dispatchEvent(
                    GameEvent.Createimmedi(GAME_EVENT.GAME_LOADING, this, v)
                    );
            }
                );
        }
Esempio n. 3
0
        public void prepareMapConfig(uint mapID, Action onFin, Action <uint, int, int> onProg)
        {
            bool flag = this.mapConfig[mapID];

            if (flag)
            {
                onFin();
            }
            else
            {
                Variant val = string.Concat(new object[]
                {
                    this.m_conf["serverURL"],
                    "?sid=",
                    this.m_conf["serverID"],
                    "&get_smap&id=",
                    mapID,
                    "&ver=",
                    StringUtil.make_version(this.m_conf["configVers"]["mpver"])
                });
                IURLReq iURLReq = os.net.CreateURLReq(val);
                iURLReq.dataFormat = "binary";
                iURLReq.load(delegate(IURLReq r, object ret)
                {
                    byte[] d       = ret as byte[];
                    ByteArray data = new ByteArray(d);
                    bool flag2     = !this.on_map_data(data);
                    if (flag2)
                    {
                        DebugTrace.add(Define.DebugTrace.DTT_ERR, "parser map id[" + mapID + "] config error");
                    }
                    onFin();
                }, delegate(IURLReq r, float progress)
                {
                    onProg(mapID, (int)(progress * 100f), 100);
                }, delegate(IURLReq r, string msg)
                {
                    DebugTrace.add(Define.DebugTrace.DTT_ERR, string.Concat(new object[]
                    {
                        "load map id[",
                        mapID,
                        "] config error msg: ",
                        msg
                    }));
                    onFin();
                });
            }
        }
Esempio n. 4
0
        public static void POSTSvr(string query, string param, Action <Variant> cb, bool rcvJSONHandler = true, string method = "POST")
        {
            ////这里要改成异步的才能继续
            //return;
            if (query == null || query == "" || cb == null)
            {
                return;
            }
            IURLReq urlReq = os.net.CreateURLReq(null);

            urlReq.url         = query;
            urlReq.contentType = NetConst.URL_CONTENT_TYPE_URLENCODE;
            urlReq.dataFormat  = NetConst.URL_DATA_FORMAT_TEXT;

            string data = "";

            data += param;
            debug.Log(" POSTSvr query:" + query + "\n param:" + param);
            urlReq.data = data;

            //DebugTrace.dumpObj("POSTSvr data:" + data);

            urlReq.method = method;


            urlReq.load(
                //delegate(IURLReq r, byte[] vari)
                delegate(IURLReq r, object vari)
            {
                if (vari == null)
                {
                    DebugTrace.print(" POSTSvr urlReq.load vari Null!");
                }
                string str = vari as string;

                DebugTrace.print(" POSTSvr urlReq.loaded str[" + str + "]!");

                Variant t = JsonManager.StringToVariant(str);

                if (cb != null)
                {
                    cb(JsonManager.StringToVariant(str));
                }
            },
                null,
                null
                );
        }
        //        public function SvrMapConfig(s:ServerGameConfig)
        //        {
        //            super(s);
        //            simpleMapConfig = new Dictionary();
        //            mapConfig = new Dictionary();
        //            _npc_in_map_id = new Dictionary();
        //        }
        //public function prepareMapConfig(mapID:uint, onFin:Function, onProg:Function):void
        public void prepareMapConfig(uint mapID, Action onFin, Action <uint, int, int> onProg)
        {
            //if(mapID in mapConfig)
            if (mapConfig[mapID])
            {
                onFin();
                return;
            }
            //var url:String = _sc.serverURL+"?sid="+_sc.serverID+"&get_smap&id=" + mapID +"&ver=" + StringUtil.make_version(_sc.configVers.mpver);
            Variant url = m_conf["serverURL"] + "?sid=" + m_conf["serverID"] + "&get_smap&id=" + mapID + "&ver=" + StringUtil.make_version(m_conf["configVers"]["mpver"]);
            //var urlReq:URLReq = os.net.createURLReq(url);
            IURLReq urlReq = os.net.CreateURLReq(url);

            urlReq.dataFormat = NetConst.URL_DATA_FORMAT_BINARY;
            //()=>{}
            urlReq.load(
                //function (r:URLReq, data:ByteArray):void
                (IURLReq r, object ret) =>
            {
                byte[] data = ret as byte[];
                //if(!on_map_data(data))
                ByteArray confbyte = new ByteArray(data);
                if (!on_map_data(confbyte))
                {
                    //DebugTrace.add(DebugTrace.DTT_ERR, "parser map id["+mapID+"] config error");
                    DebugTrace.add(Define.DebugTrace.DTT_ERR, "parser map id[" + mapID + "] config error");
                }
                onFin();
            },
                //function (r:URLReq, bytesLoaded:uint, bytesTotal:uint):void
                (IURLReq r, float progress) =>
            {
                onProg(mapID, (int)(progress * 100), 100);
            },
                (IURLReq r, String msg) =>
            {
                //DebugTrace.add(DebugTrace.DTT_ERR, "load map id["+mapID+"] config error msg: " + msg);
                DebugTrace.add(Define.DebugTrace.DTT_ERR, "load map id[" + mapID + "] config error msg: " + msg);
                onFin();
            }
                );
        }
        public void dataHdt(string path, Action onfin)
        {
            if ("null" == path)
            {
                debug.Log("此地图不需要处理,地表的高度信息");
                m_hdtdata = null;
                onfin();
                return;
            }

            IURLReq urlreqimpl = m_mgr.g_netM.getUrlImpl();

            urlreqimpl.url        = path;
            urlreqimpl.dataFormat = "binary";

            debug.Log("处理地图的高度数据,数据的文件位置" + path);

            urlreqimpl.load((IURLReq r, object ret) =>
            {
                //old 久的高度图处理
                //byte[] data = ret as byte[];
                //BinaryReader br = new BinaryReader(new MemoryStream(data));
                //char[] magic = br.ReadChars(4);
                //if (magic[0] != 'C' || magic[1] != 'R' || magic[2] != 'H' || magic[3] != 'M')
                //{
                //    DebugTrace.add(Define.DebugTrace.DTT_ERR, "Could not support hdt file anymore, please use CRHM: " + path);
                //    return;
                //}

                //ushort ver = br.ReadUInt16();
                //if (ver < 2)
                //{
                //    DebugTrace.add(Define.DebugTrace.DTT_ERR, "Could not support old version CRHM file: " + path);
                //    return;
                //}

                //this.m_grayWidth = (int)br.ReadUInt16();
                //this.m_grayHeight = (int)br.ReadUInt16();

                //int len = m_grayWidth * m_grayHeight;
                //this.m_gray = new byte[len];
                //br.Read(this.m_gray, 0, len);

                ////this.m_width = m_grayWidth / 5;
                ////this.m_height = m_grayHeight / 5;

                //onfin();


                byte[] data = ret as byte[];
                //解压地图阻挡数据
                ByteArray hdt_data = new ByteArray(data);
                hdt_data.uncompress();

                m_hdtdata = new float[hdt_data.length / 4];
                int n     = 0;
                while (hdt_data.bytesAvailable > 0)
                {
                    m_hdtdata[n++] = hdt_data.readFloat();// br.ReadInt16();
                }

                hdt_data.clear();

                onfin();
            });
        }