Ejemplo n.º 1
0
        /*
         * Network Init EquipmentData
         */
        IEnumerator InitEquipData()
        {
            Debug.Log("BackPack::InitEquipData  ");
            UserEquipClear();

            var packet = new KBEngine.PacketHolder();

            CGLoadPackInfo.Builder equip = CGLoadPackInfo.CreateBuilder();
            equip.PackType = PackType.DRESSED_PACK;
            var data = equip.BuildPartial();

            KBEngine.Bundle bundle = new KBEngine.Bundle();
            bundle.newMessage(data.GetType());
            uint fid = bundle.writePB(data);

            yield return(StartCoroutine(bundle.sendCoroutine(KBEngine.KBEngineApp.app.networkInterface(), fid, packet)));

            if (packet.packet.responseFlag == 0)
            {
                var ret = packet.packet.protoBody as GCLoadPackInfo;
                foreach (PackInfo pkinfo in ret.PackInfoList)
                {
                    var eqData = new EquipData(pkinfo);
                    UseEquip(eqData);
                }
            }
            else
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 每次进入一个新场景都重新初始化背包和装备信息
        /// </summary>
        /// <returns>The from network.</returns>
        public IEnumerator InitFromNetwork()
        {
            Log.Sys("BackPack::InitFromNetwork ");
            if (KBEngine.KBEngineApp.app == null)
            {
                Log.Sys("BackPack:: no network connection");
            }
            else
            {
                UserBagClear();

                var packet = new KBEngine.PacketHolder();
                CGLoadPackInfo.Builder load = CGLoadPackInfo.CreateBuilder();
                load.PackType = PackType.DEFAULT_PACK;
                var             data   = load.BuildPartial();
                KBEngine.Bundle bundle = new KBEngine.Bundle();
                bundle.newMessage(data.GetType());
                uint fid = bundle.writePB(data);
                yield return(StartCoroutine(bundle.sendCoroutine(KBEngine.KBEngineApp.app.networkInterface(), fid, packet)));

                if (packet.packet.responseFlag == 0)
                {
                    var ret = packet.packet.protoBody as GCLoadPackInfo;
                    foreach (PackInfo pkinfo in ret.PackInfoList)
                    {
                        Log.Sys("read Pack info is " + pkinfo.PackEntry.BaseId);
                        PutItemInBackpackIndex(pkinfo.PackEntry.Index, new BackpackData(pkinfo));
                    }
                }
                else
                {
                }
                Log.Important("LoadPacketInfo is " + load);
                yield return(StartCoroutine(InitEquipData()));

                MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.UpdateItemCoffer);
            }
        }