Ejemplo n.º 1
0
 private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_ChatMsg _msg)
 {
     switch ((EChatType)_msg.ChatType)
     {
     case EChatType.CHAT_HALL:
     case EChatType.CHAT_ROOM:
     case EChatType.CHAT_CLUB:
     case EChatType.CHAT_TRADE:
     {
         if (ChatInfo.ContainsKey(_msg.ChatType))
         {
             if (ChatInfo[_msg.ChatType].Count >= MaxChatCount)
             {
                 ChatInfo[_msg.ChatType].RemoveFirst();
             }
             ChatInfo[_msg.ChatType].AddLast(_msg);
         }
         else
         {
             LinkedList <GC_ChatMsg> chats = new LinkedList <GC_ChatMsg>();
             chats.AddLast(_msg);
             ChatInfo.Add(_msg.ChatType, chats);
         }
         SignalSystem.FireSignal(SignalId.Chat_ReceiveChat, _msg);
     }
     break;
     }
 }
Ejemplo n.º 2
0
        private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_LoginFailedMsg _msg)
        {
            switch ((GC_LoginFailedMsg.ReasonInfo)_msg.Reason)
            {
            case GC_LoginFailedMsg.ReasonInfo.RET_SUCCESS:
            case GC_LoginFailedMsg.ReasonInfo.RET_SUCCESS_WITH_ITEM:
                break;

            case GC_LoginFailedMsg.ReasonInfo.ERROR_HAS_LOGINED:
            {
                string tip = Locale.Instance[string.Format("Login@{0}", (GC_LoginFailedMsg.ReasonInfo)(_msg.Reason)).ToString()];
                NetManager.Instance.RequestDisConnect();
                UI_MessageBox.Show(tip, Locale.Instance["Common@Confirm"], Locale.Instance["Common@Cancel"], () =>
                    {
                        SignalSystem.FireSignal(SignalId.Login_ForceLogin);
                    });
            }
            break;

            default:
            {
                string tip = Locale.Instance[string.Format("Login@{0}", (GC_LoginFailedMsg.ReasonInfo)(_msg.Reason)).ToString()];
                if (tip == string.Empty)
                {
                    UI_MessageBox.Show(((GC_LoginFailedMsg.ReasonInfo)(_msg.Reason)).ToString());
                }
                else
                {
                    UI_MessageBox.Show(tip);
                }
            }
            break;
            }
            WaitForResponse.Release();
        }
Ejemplo n.º 3
0
    private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_UpdateSale _msg)
    {
        for (int i = 0; i < _msg.UpdateCount; i++)
        {
            int type = _msg.SaleItems[i].SaleType;
            switch (type)
            {
            case 0:
                UpdateSaleItem(_msg.SaleItems[i], 1);    //减损
                break;

            case 1:
                UpdateSaleItem(_msg.SaleItems[i], 0);    //加倍
                break;

            case 6:
                UpdateSaleItem(_msg.SaleItems[i], 2);    //宝箱
                break;

            default:
                UpdateSaleItem(_msg.SaleItems[i], 3);    //其他
                break;
            }
        }
        SignalSystem.FireSignal(SignalId.Shop_Update);
    }
Ejemplo n.º 4
0
    private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_UpdateItems _msg)
    {
        for (Int32 i = 0; i < _msg.PropItemsCount; i++)
        {
            if (m_items.Count == 0)
            {
                m_items.Add(_msg.PropItems[i]);
            }

            else
            {
                for (Int32 j = 0; j < m_items.Count; j++)
                {
                    if (m_items[j].PropID == _msg.PropItems[i].PropID)
                    {
                        m_items[j].Count += _msg.PropItems[i].Count;
                        if (m_items[j].Count <= 0)
                        {
                            m_items.RemoveAt(j);
                        }
                        break;
                    }
                    if (j + 1 == m_items.Count)
                    {
                        m_items.Add(_msg.PropItems[i]);
                        break;
                    }
                }
            }
        }
        SignalSystem.FireSignal(SignalId.Item_Update);
    }
Ejemplo n.º 5
0
            /// <summary>
            /// 用于时间同步的timer
            /// </summary>
            //private Timer m_timer_sync_time;


            public override void Enter()
            {
                NetManager.Instance.Register <DisconnectMsg>(_onConnectionClosed);
                //Entity.m_net_client_gamesrv.Register<DisconnectMsg>( DisconnectMsg.MyMessageId, _onConnectionClosed );
                //Entity.m_net_client_gamesrv.Register<Msg_gc_ConnectionClosed>( Msg_gc_ConnectionClosed.MyMessageId, _onGameSrvCloseConnection );
                //Entity.m_net_client_gamesrv.Register<Msg_gc_Heartbeat>( Msg_gc_Heartbeat.MyMessageId, _onHeartbeatReceived );
                Utility.Log.Info("成功登录GameSrv");
                SignalSystem.FireSignal(SignalId.NetworkState_EnterConnected);

                //Main.Instance.eventOnApplicationPause += _onApplicationPause;
                //_startSyncTime();
                //_sendHeartbeat();
                // 处理之前缓存的消息
                if (Entity.m_msg_buffer.Count == 0)
                {
                    return;
                }
                MessageBase msg = Entity.m_msg_buffer.Dequeue();

                while (true)
                {
                    Entity.SendMsg(msg);
                    if (Entity.m_msg_buffer.Count == 0)
                    {
                        break;
                    }
                    msg = Entity.m_msg_buffer.Dequeue();
                }
            }
Ejemplo n.º 6
0
 /// <summary>
 /// 购买失败
 /// </summary>
 /// <param name="_stream_id"></param>
 /// <param name="_packet_type"></param>
 /// <param name="_msg"></param>
 private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_Buy _msg)
 {
     m_buyRetItem_attr.Clear();
     for (int i = 0; i < _msg.BuyStatusCount; i++)
     {
         m_buyRetItem_attr.Add(_msg.BuyStatusItem[i]);
     }
     SignalSystem.FireSignal(SignalId.BuyFail_Update);
 }
Ejemplo n.º 7
0
        private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_LoginOK _msg)
        {
            WaitForResponse.Release();
            Log.Info("收到玩家数据");
            MainPlayer.Instance.InitializePlayerInfo(_msg.PlayerInfo);
            SignalSystem.FireSignal(SignalId.Login_Success);

            //登陆成功后更新本地配置中的账户名
            LocalConfigSystem.Instacne.UpdateCurAccount(CurAccount);
            LocalConfigSystem.Instacne.Update("CurrentPassword", CurPassword);
        }
Ejemplo n.º 8
0
 private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_UpdateDeltaGold _msg)
 {
     if (_msg.DeltaGold < 0)
     {
         UInt64 deltaMoney = Convert.ToUInt64(_msg.DeltaGold);
         if (PlayerInfo.Gold < deltaMoney)
         {
             PlayerInfo.Gold = 0;
         }
         else
         {
             PlayerInfo.Gold -= Convert.ToUInt32(_msg.DeltaGold);
         }
     }
     PlayerInfo.Gold += Convert.ToUInt32(_msg.DeltaGold);
     SignalSystem.FireSignal(SignalId.Gold_Update, PlayerInfo.Gold);
 }
Ejemplo n.º 9
0
 private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_UpdatePlayerLiveness _msg)
 {
     PlayerInfo.Liveness = Convert.ToUInt64(_msg.Liveness);
     SignalSystem.FireSignal(SignalId.Liveness_Update, PlayerInfo.Liveness);
 }
Ejemplo n.º 10
0
 private void _onPacketArrived(Int32 _stream_id, PacketType _packet_type, GC_UpdatePlayerMoney _msg)
 {
     PlayerInfo.Money = Convert.ToUInt64(_msg.GoldNow);
     SignalSystem.FireSignal(SignalId.Money_Update, PlayerInfo.Money);
 }