示例#1
0
    private void JumpToDungeonView()
    {
        var c = KHDataManager.CONFIG.getChapterItemConfig(_chapterID);

        if (c.chapterType == 0)
        {
            // 禁用输入
            KHUIManager.uiTouchEnabled = false;

            //DuplicateModel model = KHPluginManager.Instance.GetPluginByName (DuplicatePlugin.pluginName).Model as DuplicateModel;
            model.CurChapterID = _chapterID;

            KHUIManager.Instance.SendMessage(UIDef.LEVEL_SELECT_CHAPTER, "SetIsAni", true);
            KHUIManager.Instance.SendMessage(UIDef.LEVEL_SELECT_CHAPTER, "ChangeToDungeonView");

            //如果点击了最新的章节(冒险模式),并且是第一次访问该章节,则记录下来
            if (_chapterID == model.NewestChapterID && model.VisitedNewestChapterID != model.NewestChapterID)
            {
                model.VisitedNewestChapterID = model.NewestChapterID;
                KHUtil.SetInt("JumpToChapterID", model.NewestChapterID);
                KHUtil.Save();
            }
        }
        else
        {
            model.CurChapterID = _chapterID;
            ClickChapterGroup(_chapterID);
        }
    }
示例#2
0
    private void SendMatchEnemyReq(object data)
    {
        PVPRealTimeMainUIModel.MatchType = PVPMatchType.Enemy;
        MatchEnemyData     tmpData = data as MatchEnemyData;
        ZonePvp1v1MatchReq req     = new ZonePvp1v1MatchReq();
        int state = KHUtil.GetInt(UISettingMoreView.OnlyReal, 0);

        req.only_real_player = state == 1;
        NetworkManager.Instance.Send((uint)ZoneCmd.ZONE_PVP_1V1_MATCH, req, (object fullInfo) => {
            ZonePvp1v1MatchResp resp = fullInfo as ZonePvp1v1MatchResp;
            if (resp.ret_info.ret_code == 0)
            {
                tmpData.expectSeconds   = (int)resp.expect_wait_second;
                EstimatedTimeLabel.text = tmpData.expectSeconds + "秒";
                NGUITools.SetActive(EstimatedContainer.gameObject, true);
                isStarted = true;
            }
            else
            {
                ErrorCodeCenter.DefaultProcError(resp.ret_info);
                _CloseWindow(null);
            }
        }, false, onTimeout => {
            UIAPI.ShowMsgTip("匹配请求超时");
            _CloseWindow(null);
        });
    }
示例#3
0
        public void ShowForceUpGradeTip(string attr)
        {
            if (Application.platform != RuntimePlatform.IPhonePlayer || !KHUtil.IsLowMemoryDevice())
            {
                return;
            }

            //每天提示一次
            int lastTimeStamp = PlayerPrefs.GetInt(attr, 0);

            if ((int)RemoteModel.Instance.CurrentTime - lastTimeStamp < 86400)
            {
                return;
            }
            PlayerPrefs.SetInt(attr, (int)RemoteModel.Instance.CurrentTime);

            var info = KHUtil.GetOsInfo();

            if (info.MainLevel == 12 && info.Sub1Level == 1)
            {
                UIAPI.ShowMsgOK("建议您升级到iOS最新系统版本,可改善闪退和卡顿问题。");
            }
        }
示例#4
0
        protected List <object> ReadBody(ClientHead head, MemoryStream stream)
        {
            ///此处对读取 BODYSTEAM做了一些优化,如果有问题请注意排查 2015 08 21
            //byte[] bodyBuffer = new byte[head.BodyLength];
            //int bodyBufferOffset = 0;
            //stream.Read(bodyBuffer, 0, (int)head.BodyLength);

            byte[] bodyBuffer = stream.GetBuffer();

            int bodyBufferOffset = (int)stream.Position;

            int bodyLen = (int)head.BodyLength;

            if (bodyLen < 0)
            {
                bodyLen = 0;
            }

            stream.Position = bodyBufferOffset + bodyLen;

            ///bodylen大于零才去读MESSAGE

            //if (bodyLen > 0) //去掉吧,有些协议的长度就是为零
            {
                List <object> msgs = new List <object>();
                if (head.Format == ClientHeadFormatType.Protobuf)
                {
                    bool isLua    = false;
                    bool isCSharp = false;
                    if (__Proxy.__LuaPBProcessor.ContainsKey(head.CmdId) && _router.getPBType(head.Serial) == PBTYPE.LuaPB || _router.getPBType(head.Serial) == PBTYPE.Both)
                    {
                        byte[] buff = new byte[bodyLen];
                        //stream.Write(buff, bodyBufferOffset, bodyLen);
                        stream.Position = bodyBufferOffset;
                        stream.Read(buff, 0, bodyLen);
                        stream.Position = bodyBufferOffset + bodyLen;
                        msgs.Add(buff);
                        //return buff;
                        isLua = true;
                    }


                    if (_typeProvider.ContainsKey(head.CmdId) && _router.getPBType(head.Serial) == PBTYPE.CSharpPB || _router.getPBType(head.Serial) == PBTYPE.Both)
                    {
                        ReceiveMessageStream.Write(bodyBuffer, bodyBufferOffset, bodyLen);
                        ReceiveMessageStream.Position = 0;

                        Type messageType;
                        TypeProvider.TryGetValue(head.CmdId, out messageType);

                        if (DefineExt.Net_Log_Level > 0)
                        {
                            Debuger.Log(string.Format("Received Package 0x{0}({4}), Body Length = {1}, Message Id = {2}, Serial Id = {3}.", _recentHead.CmdId.ToString("X2"), _recentHead.BodyLength.ToString(), _recentHead.MessageId, _recentHead.Serial, _recentHead.CmdId));
                            ///解析详细的字段
                            ///todo..
                        }

                        if (messageType == null)
                        {
                            ReceiveMessageStream.SetLength(0);
                            if (_router.getPBType(head.Serial) == PBTYPE.CSharpPB)
                            {
                                Debuger.LogWarning(@"返回cmdID消息类型未注册。请在NetworkManager.registerTypes()方法中添加cmdID到返回消息类型的映射。
        CmdId = 0x" + _recentHead.CmdId.ToString("X2") + "(" + _recentHead.CmdId + ")");
                                //return null;
                            }
                        }
                        else
                        {
                            object message = null;
                            message = Serializer.NonGeneric.Deserialize(messageType, ReceiveMessageStream);
                            ReceiveMessageStream.SetLength(0);

                            if ((DefineExt.Net_Log_Level & DefineExt.LOG_FULL_RECV_PROTO_INFO) > 0)
                            {
                                Debuger.Log(String.Format("Receive ----> cmd={0}, serial={1}, proto={2}", head.CmdId, head.Serial, KHUtil.GetProtoStr(message, messageType.FullName)));
                            }

                            msgs.Add(message);

                            isCSharp = true;
                        }
                    }


                    // Update by Chicheng
                    if (msgManager.IsActivate && msgManager.IsSerializeToLocal)
                    {
                        Type messageType;
                        TypeProvider.TryGetValue(head.CmdId, out messageType);

                        // Debug.LogWarning("把读到的消息包序列化到本地");
                        RemoteModel remoteModel = RemoteModel.Instance;
                        ulong       timeStamp   = remoteModel.CurrentTime;
                        if (isCSharp && isLua)
                        {
                            serializeToLocalWithType(msgs, messageType, head.CmdId, timeStamp, head.Serial, MessageSource.CSharpAndLua);
                        }
                        else if (isLua)
                        {
                            serializeToLocalWithType(msgs, null, head.CmdId, timeStamp, head.Serial, MessageSource.Lua);
                        }
                        else if (isCSharp)
                        {
                            if (messageType != null)
                            {
                                serializeToLocalWithType(msgs, messageType, head.CmdId, 0, head.Serial, MessageSource.CSharp);
                            }
                            else
                            {
                                Debug.LogWarning("丢弃" + head.Serial);
                            }
                        }
                    }
                }
                return(msgs);
            }
        }
示例#5
0
        public bool Write(uint cmdId
                          , object message
                          , uint serialNumber = 0
                          , int connID        = -1)
        {
            bool result = false;

            IConnection conn = _defaultConn;

            if (connID != -1)
            {
                _connectionDict.TryGetValue(connID, out conn);
            }

            ///连接不为空或者尝试可以发送...
            if (conn != null && conn.TryDoSend(cmdId))
            {
                clearStreams();

                _send_head.CmdId     = cmdId;
                _send_head.ZoneId    = ZoneId;
                _send_head.MessageId = _messageId++;

                if (connectionHook != null &&
                    connectionHook.FilterCmd(cmdId, message, _messageId - 1, serialNumber))
                {
                    connectionHook.HookMessage(_send_head, message, WriteMSG);
                    return(true);
                }

                if (message is byte[])
                {
                    byte[] buff = message as byte[];

                    if (buff != null)
                    {
                        sendMessageBodyStream.Write(buff, 0, buff.Length);
                    }
                }
                else
                {
                    ///序列化message且设置长度
                    Serializer.NonGeneric.Serialize(sendMessageBodyStream, message);

                    if ((DefineExt.Net_Log_Level & DefineExt.LOG_FULL_SEND_PROTO_INFO) > 0)
                    {
                        Debuger.Log(String.Format("Send ----> cmd={0}, serial={1}, proto={2}", cmdId, serialNumber, KHUtil.GetProtoStr(message, message.GetType().FullName)));
                    }
                }
                _send_head.BodyLength = (uint)sendMessageBodyStream.Length;
                _send_head.Serial     = serialNumber;

                MessageManager msgManager = MessageManager.Instance;
                // 模拟服务器,从本地读包
                if (!msgManager.IsActivate || msgManager.IsSerializeToLocal)
                {
                    result = conn.DoSend(_send_head, message, sendMessageBodyStream);
                }
                if (!result)
                {
                    _messageId--;
                }
            }

            return(result);
        }
示例#6
0
        public void OnClickButton(UIPlayerBar.BtnDestination btnDest)
        {
            if (KHVer.IsOfflineMatch)
            {
                if (btnDest != UIPlayerBar.BtnDestination.Match && btnDest != UIPlayerBar.BtnDestination.PVPRealTime)
                {
                    UIAPI.ShowMsgTip("赛事版本,该功能暂不开放");
                    return;
                }
            }
            UIEntryElement ele = null;

            mainPageEntrys.TryGetValue(btnDest, out ele);
            if (ele == null)
            {
                Debuger.Log("OnClickButton, btn:" + btnDest + ", not binding logic UIEntryElement");
                return;
            }
            // 新手引导通知
            if (btnDest != UIPlayerBar.BtnDestination.None)
            {
                KHUIManager.getInstance().dispatchClickToGuideEvent(ele.gameObject.tag);
            }
            // 如果未开启,则显示系统开启提示
            if (CheckShowNextOpenSysTipIfLock(btnDest))
            {
                return;
            }

            if (DefineExt.shieldSystemLst.Contains((uint)LockSysHash.StateBit_2_Excel[LockSysHash.BtnDestination_2_StateBit[btnDest]]))
            {
                UIAPI.ShowMsgTip("客户端不是最新版本,无法参加当前玩法,请更新版本后尝试");
                return;
            }
            if (KHLowDeviceManager.GetLowDeviceShield((uint)LockSysHash.StateBit_2_Excel[LockSysHash.BtnDestination_2_StateBit[btnDest]]))
            {
                return;
            }

            if (false && !playerEntity.GetOpenInfo(LockSysHash.BtnDestination_2_StateBit[btnDest]))
            {
                int configId             = LockSysHash.getConfigByBtnDestination(btnDest);
                FeatureUnlockConfig conf = null;
                GeneralTableConfig.getInstance().FeatureDefine.TryGetValue(configId, out conf);
                if (conf != null)
                {
                    UIAPI.ShowMsgTip(conf.tip);
                }
                else
                {
                    Debuger.LogWarning("未找到对应的解锁配置, Id = " + configId);
                }
            }
            switch (btnDest)
            {
            case UIPlayerBar.BtnDestination.None:
                break;

            case UIPlayerBar.BtnDestination.FullFood:
                KHPluginManager.Instance.SendMessage(FullFoodPlugin.NAME, "ShowView", new ShowViewArgument(UIDef.FULL_FOOD_MAIN_PANEL_VIEW));
                break;

            case UIPlayerBar.BtnDestination.CityShop:
                KHPluginManager.Instance.SendMessage("Shop", "ShowView", new ShowViewArgument(UIDef.SHOP_UI, true, 1u));
                break;

            case UIPlayerBar.BtnDestination.EliteLevel:

                KHPluginManager.Instance.SendMessage(LevelSelectPlugin.pluginName, "ShowView", new ShowViewArgument(UIDef.LEVEL_SELECT_CHAPTER, needBg: false, data: UILevelSelectMainView.LevelSelectMainViewTabEnum.Elite));
                break;

            case UIPlayerBar.BtnDestination.Talent:
                KHPluginManager.Instance.SendMessage("NewTalentPlugin", "OpenSystem");
                break;

            case UIPlayerBar.BtnDestination.MissonMode:
                UIAPI.ShowMsgTip("功能尚未开放");
                break;

            case UIPlayerBar.BtnDestination.SurvivalChallenge:
                //KHPluginManager.Instance.SendMessage(SurvivalChallPlugin.pluginName, SurvivalChallOperation.OperRequestEnter);
                KHPluginManager.Instance.SendMessage("Mirage", "ShowView",
                                                     new ShowViewArgument(UIDef.MIRAGE_PRACTICE_VIEW));
                break;

            case UIPlayerBar.BtnDestination.MirageMode:
                KHPluginManager.Instance.SendMessage("Mirage", "Mirage.GetMirageData");
                break;

            case UIPlayerBar.BtnDestination.NewPVPMode:
                KHPluginManager.Instance.SendMessage(PvPUIPlugin2.PluginName, "OpenSystem");
                break;

            case UIPlayerBar.BtnDestination.PVPRealTime:
                //KHPluginManager.Instance.SendMessage("ArenaPlugin", "OpenHomeView");
                KHUtil.GoToPvpMainView(null, true, true);
                break;

            case UIPlayerBar.BtnDestination.TeamPVE:
                KHPluginManager.Instance.SendMessage("TeamPVEUI", "ShowView", new ShowViewArgument(UIDef.TEAMPVE_MAIN_VIEW));
                break;

            case UIPlayerBar.BtnDestination.Guild:
                KHPluginManager.Instance.SendMessage(GuildPlugin.pluginName, GuildOperation.ClickGuild, false);

                //KHPluginManager.Instance.GetPluginByName("DramaPlugin").ShowView("UILua/Drama/DramaView", false);

                break;

            case UIPlayerBar.BtnDestination.RankingView:
                KHPluginManager.Instance.SendMessage(RankListPlugin.NAME, "ShowView", new ShowViewArgument(UIDef.RANK_LIST_VIEW));
                break;

            case UIPlayerBar.BtnDestination.NinjaTask:
                KHPluginManager.Instance.SendMessage(NinjaTaskPlugin.pluginName, NinjaTaskOperation.OpenNinjaTask);
                break;

            case UIPlayerBar.BtnDestination.TeamGroup:
                //KHPluginManager.Instance.SendMessage(GroupPlugin.pluginName, GroupOperation.ClickGroup);
                KHPluginManager.Instance.SendMessage("MysticalDuplicatePlugin", "OnOpen");
                break;

            case UIPlayerBar.BtnDestination.Match:
                if (KHVer.IsOfflineMatch)
                {
                    KHUtilForLua.SendMessageForLuaSystem("OfflineMatchPlugin", "OpenFirstView", null);
                }
                else
                {
                    LuaSystemPlugin sysPlugin = KHPluginManager.Instance.GetPluginByName("MatchMainEntrancePlugin") as LuaSystemPlugin;
                    sysPlugin.CallLuaFunctionToOperation("kihan.match.MatchMainEntranceOperation", "OpenSystem", null);
                }
                break;

            case UIPlayerBar.BtnDestination.KizunaContest:
                //KHPluginManager.Instance.SendMessage("KizunaContestEntrancePlugin", "TryEnter");
                break;

            case UIPlayerBar.BtnDestination.GuildHegemony:
                KHPluginManager.Instance.SendMessage("GuildHegemonyPlugin", "Query");
                break;

            case UIPlayerBar.BtnDestination.ZoneFightMatch:
                KHPluginManager.Instance.SendMessage(ZoneFightMatchPlugin.pluginName, ZoneFightMatchOperation.OpenEntranceView);
                break;

            case UIPlayerBar.BtnDestination.Main_NinjaFight:
                //KHPluginManager.Instance.SendMessage("MysticalDuplicatePlugin", "OnOpen");
                KHPluginManager.Instance.SendMessage(TeamPlugin.pluginName, TeamOperation.EnterTeamScene);
                break;

            case UIPlayerBar.BtnDestination.Drama:
                KHUIManager.Instance.ShowFlyNext(true, () => {
                    KHPluginManager.Instance.SendMessage("MainUI", "HideView", "MainUI");
                    KHPluginManager.Instance.SendMessage("MainUI", "HideView", "PlayerBarUI");
                    KHPluginManager.Instance.GetPluginByName("DramaPlugin").ShowView("UILua/Drama/DramaView", false);
                });
                break;

            default:
                break;
            }
        }