예제 #1
0
    private void Awake()
    {
        MFUIMgr.Init();

        // 服务器做成一个可以选择的列表
#if UNITY_EDITOR
        if (!debug)
        {
            _netMgr.Init(new MFSocketClient("116.196.109.146", 8090));
        }
#else
        if (debug)
        {
            _netMgr.Init(new MFSocketClient("10.0.2.2", 8090));
        }
        else
        {
            _netMgr.Init(new MFSocketClient("116.196.109.146", 8090));
        }

        MFAgoraMgr.Init();
        ssdk = GetComponent <ShareSDK>();
#endif
        MFApplicationUtil.SetDebugMode(debug);

        MFServerAgentBase.Init();

        DontDestroyOnLoad(gameObject);

        if (debug)
        {
            MFLog.LogInfo("Debug Mode Start");
        }
    }
예제 #2
0
 public void OnStartGameRespond(MFRespondHeader header, MFStartGameRespond data)
 {
     if (header.result == 0)
     {
         MFLog.LogInfo("房主开始游戏");
     }
 }
예제 #3
0
    public void OnReadyToStartRespond(MFRespondHeader header, MFReadyToStartRespond data)
    {
        if (header.result == 0)
        {
            MFLog.LogInfo("玩家准备完成");
            RefreshPlayerList(data.userList);

            if (isRoomMaster() && AllPlayerReady())
            {
                uiBind.startBtn.enabled = true;
            }
        }
    }
예제 #4
0
 private void ConnectCallBack(IAsyncResult ar)
 {
     try {
         _socket.EndConnect(ar);
         MFLog.LogInfo("Connect Success");
         Receive();
     }
     catch (Exception e) {
         MFLog.LogError("Connect Faild");
         MFLog.LogError(e.ToString());
         //todo 加上异常处理
         //m_stateCallback((int)ESocketState.eST_Error);
     }
 }
예제 #5
0
    private void DispatchRespond(string data)
    {
        // 随便找个int当做具体类型 反正只需要header部分
        try {
            MFLog.LogInfo(data);
            MFRespondHeader rh = MFJsonSerialzator.DeSerialize <MFRespondProtocol <int> >(data).header;
            if (rh.result != 0)
            {
                MFLog.LogError(rh.result, rh.errMsg);
            }

            MFServerAgentBase.Receive(rh.protocolId, data);
        }
        catch (Exception e) {
            MFLog.LogError(e.ToString());
            MFLog.LogError(data);
        }
    }
예제 #6
0
    public void OnSendCharacterScriptRespond(MFRespondHeader header, MFSendCharacterScriptRespond data)
    {
        if (header.result == 0)
        {
            MFLog.LogInfo("发放成功");
            MFLog.LogInfo(data.script);

            if (isRoomMaster())
            {
                uiBind.sendScriptBtn.gameObject.SetActive(false);
                uiBind.sendScriptBtn.enabled = false;

                uiBind.startBtn.gameObject.SetActive(true);
                uiBind.startBtn.enabled = false;
            }
            else
            {
                uiBind.readyBtn.gameObject.SetActive(true);
                uiBind.readyBtn.enabled = true;
            }
        }
    }
예제 #7
0
 private static void OnHeartBeatRespond(string data)
 {
     MFLog.LogInfo("heartbeat");
 }
예제 #8
0
 public MFSocketClient(string ip, int port)
 {
     MFLog.LogInfo("ip", ip);
     _ip   = ip;
     _port = port;
 }
예제 #9
0
 // 预约房间
 private void OnReserverRoomBtnClick()
 {
     MFLog.LogInfo("OnReserverRoomBtnClick");
 }