コード例 #1
0
ファイル: RemoteManger.cs プロジェクト: wjmBranch/mfq_unity
    public void StartMFQTcpClient(RunAtType runAtType, string remoteID, string inUserID)
    {
        string log = "开始连接讲盘服务器,请等待";

        GlobalDebug.Addline(log);
        Debug.Log(log);
        remoteGUI.DisplayHelpInfo();
        remoteGUI.SetHelpInfoString(log);

        if (runAtType == RunAtType.None)
        {
            return;
        }
        else if (runAtType == RunAtType.Master)
        {
            roomID = inUserID;
        }
        else if (runAtType == RunAtType.Slave)
        {
            roomID = remoteID;
        }

        userID = inUserID;

//        sendOnlinePastTime = 0;

        StartCoroutine(WaitingReceiveIE());
        RemoteGather.SetupRemoteGather();
        mfqTcpClient = new MFQTcpClient(this);
    }
コード例 #2
0
ファイル: ScaleImage.cs プロジェクト: wjmBranch/mfq_unity
    override protected void Start()
    {
        dpiScaleFactor = 100.0f / Screen.dpi;
        RecordOrginState();
        RecordLastState();

        RemoteGather.SetupRemoteGather();
        RemoteGather.AddSacleImageToGroup(this);
    }
コード例 #3
0
ファイル: ScrollMenu.cs プロジェクト: wjmBranch/mfq_unity
    public void CreateItemGroup(string[] btnGroupDisplayName, string[] btnGroupParameter)
    {
        nonStandFloor = new List <ScrollItem>();
        allScrollItem = new List <ScrollItem>();

        if (btnGroupParameter == null)
        {
            btnGroupParameter = btnGroupDisplayName;
        }

        ScrollItem[] lastScrollItem = scrollRect.content.GetComponentsInChildren <ScrollItem>();

//      Debug.Log(lastScrollItem.Length);

        for (int i = 0; i < lastScrollItem.Length; i++)
        {
            if (lastScrollItem[i] != null)
            {
                DestroyObject(lastScrollItem[i].gameObject);
            }
        }

        Vector2 startPos = itemSpace;

        for (int i = 0; i < btnGroupDisplayName.Length; i++)
        {
            ScrollItem sItem    = Instantiate(itemPrefab, new Vector3(0, 0, 0), new Quaternion(), scrollRect.content);
            Vector2    itemSize = sItem.SetupItem(btnGroupDisplayName[i], scroolItemHeight, startPos, scrollItemMinWidth, fontSize, paddingFactor);
            Vector2    iSpace   = Vector2.zero;

            //
            sItem.imageButton.btnNameForRemote = "B" + i.ToString() + "_" + this.gameObject.name + btnGroupParameter[i];
            sItem.imageButton.btnNameForRemote = Regex.Replace(sItem.imageButton.btnNameForRemote, @"[\u4e00-\u9fa5]", "");

            RemoteGather.AddImageToGroup(sItem.imageButton, true);

            sItem.imageButton.RecordOrginState();

            if (itemDirection == ItemDirection.水平)
            {
                itemSize = new Vector2(itemSize.x, 0);
                iSpace   = new Vector2(itemSpace.x, 0);
            }
            else
            {
                itemSize = new Vector2(0, -itemSize.y);
                iSpace   = new Vector2(0, itemSpace.y);
            }

//          if(i!= btnGroupDisplayName.Length-1)
            startPos += itemSize + iSpace;

            //设置item的按钮事件
            BaseEventDelegate itemTrue  = new BaseEventDelegate();
            BaseEventDelegate itemfalse = new BaseEventDelegate();

            itemTrue.parameterTargetSlot  = new int[] { 0, 3 };
            itemfalse.parameterTargetSlot = new int[] { 0, 3 };

            itemTrue.parameterList  = new EventParametar[2];
            itemfalse.parameterList = new EventParametar[2];

            itemTrue.parameterList[0].pObject = sItem;
            itemTrue.parameterList[1].pString = btnGroupParameter[i];

            itemfalse.parameterList[0].pObject = sItem;
            itemfalse.parameterList[1].pString = btnGroupParameter[i];

            itemTrue.excuteMethodName  = "ItemBtnExeTrue";
            itemfalse.excuteMethodName = "ItemBtnExeFalse";

            itemTrue.targetMono  = this;
            itemfalse.targetMono = this;

            itemTrue.currentEditorChooseFunName = "ScrollMenu/ItemBtnExeTrue";
            itemTrue.lastEditorChooseFunName    = "ScrollMenu/ItemBtnExeTrue";

            itemfalse.currentEditorChooseFunName = "ScrollMenu/ItemBtnExeTrue";
            itemfalse.lastEditorChooseFunName    = "ScrollMenu/ItemBtnExeTrue";

            sItem.imageButton.trueEventList.Add(itemTrue);
            sItem.imageButton.falseEventList.Add(itemfalse);

            allScrollItem.Add(sItem);

            //判断参数是否可以转成有效的数字,如果可以就是楼层
            int temp;
            if (!int.TryParse(btnGroupParameter[i].Replace("F", ""), out temp))
            {
                nonStandFloor.Add(sItem);
            }
        }

        if (itemDirection == ItemDirection.水平)
        {
            scrollRect.content.sizeDelta = new Vector2(startPos.x, scrollRect.GetComponent <RectTransform>().sizeDelta.y);

            //设置居中
            if (startPos.x < (scrollRect.GetComponent <RectTransform>().sizeDelta.x - 200))
            {
                Vector2 offset = new Vector2((scrollRect.GetComponent <RectTransform>().sizeDelta.x - 200 - startPos.x) * 0.5f, 0f);

//              Debug.Log(offset);

                foreach (ScrollItem s in scrollRect.content.GetComponentsInChildren <ScrollItem>())
                {
                    s.GetComponent <RectTransform>().anchoredPosition += offset;
                    s.imageButton.RecordOrginState();
                }
            }
        }
        else
        {
            scrollRect.content.sizeDelta = new Vector2(scrollRect.GetComponent <RectTransform>().sizeDelta.x, -startPos.y);
        }
    }
コード例 #4
0
ファイル: RemoteManger.cs プロジェクト: wjmBranch/mfq_unity
    void ProcessMessage(RemoteGather.RemoteMessage p)
    {
        switch (p.messageType)
        {
        //CameraStateMessage
        case 49:

            string log = "Process CameraStateMessage";
            Debug.Log(log);
            GlobalDebug.Addline(log, true);

            /*
             * foreach (float f in p.cameraStates)
             * {
             *  Debug.Log(f);
             * }
             */
            RemoteGather.currentCameraUniversal.SetCameraPositionAndXYZCount(p.cameraStates);
            RemoteGather.needProcessMessages.Remove(p);
            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(72).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(72));

            break;

        //BtnCtrlMessage
        case 50:
            string log2 = "Process BtnCtrlMessage";
            Debug.Log(log2);
            GlobalDebug.Addline(log2, true);

            RemoteGather.ProcessRemoteMessage(p.btnName, p.btnState == 65);
            RemoteGather.needProcessMessages.Remove(p);

            log2 = "Btn事件还有:" + RemoteGather.needSendBtnCtrlMessages.Count;
            Debug.Log(log2);
            GlobalDebug.Addline(log2);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(73).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(73));

            break;

        //AreYouReadyMessage
        case 51:
            string log3 = "Process AreYouReady Message";
            Debug.Log(log3);
            GlobalDebug.Addline(log3, true);

            isOtherSideOnline = true;
            RemoteGather.needProcessMessages.Remove(p);



            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(74).GetBytesData(), false);
//                RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));
            break;

        //ScaleImageMessage
        case 52:
            string log4 = "Process ScaleImage Message";
            Debug.Log(log4);
            GlobalDebug.Addline(log4, true);

            isOtherSideOnline = true;

//              Debug.Log(p.btnName);

            RemoteGather.allScaleImage[p.btnName].SetState(p.scaleImageStates);
            RemoteGather.needProcessMessages.Remove(p);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(75).GetBytesData(), false);
            //                RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));
            break;

        //对方断开连接

        case 106:
            string log5 = "Receive 对方主动断开连接";
            Debug.Log(log5);
            GlobalDebug.Addline(log5, true);
            isOtherSideOnline = false;
            RemoteGather.needProcessMessages.Remove(p);
            break;

        default:
            break;
        }
    }
コード例 #5
0
ファイル: RemoteManger.cs プロジェクト: wjmwjm119/mfq_unity
    void ProcessMessage(RemoteGather.RemoteMessage p)
    {
        switch (p.messageType)
        {
        //CameraStateMessage
        case 49:

            string log = "Process CameraStateMessage";
            Debug.Log(log);
            GlobalDebug.Addline(log, true);

            /*
             * foreach (float f in p.cameraStates)
             * {
             *  Debug.Log(f);
             * }
             */
            RemoteGather.currentCameraUniversal.SetCameraPositionAndXYZCount(p.cameraStates);
            RemoteGather.needProcessMessages.Remove(p);
            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(72).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(72));

            break;

        //BtnCtrlMessage
        case 50:
            string log2 = "Process BtnCtrlMessage";
            Debug.Log(log2);
            GlobalDebug.Addline(log2, true);

            RemoteGather.ProcessRemoteMessage(p.btnName, p.btnState == 65);
            RemoteGather.needProcessMessages.Remove(p);

            log2 = "Btn事件还有:" + RemoteGather.needSendBtnCtrlMessages.Count;
            Debug.Log(log2);
            GlobalDebug.Addline(log2);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(73).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(73));

            break;

        //AreYouReadyMessage
        case 51:
            string log3 = "Process AreYouReady Message";
            Debug.Log(log3);
            GlobalDebug.Addline(log3, true);

            RemoteGather.needProcessMessages.Remove(p);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(74).GetBytesData(), false);
            // RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));

            remoteGUI.SucessConnectGUI();

            break;

        //ScaleImageMessage
        case 52:
            string log4 = "Process ScaleImage Message";
            Debug.Log(log4);
            GlobalDebug.Addline(log4, true);

            Debug.Log(p.btnName);

            RemoteGather.allScaleImage[p.btnName].SetState(p.scaleImageStates);
            RemoteGather.needProcessMessages.Remove(p);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(75).GetBytesData(), false);
            //                RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));
            break;

        case 74:
            string log74 = "Process AreYouReady Ack";
            Debug.Log(log74);
            GlobalDebug.Addline(log74, true);
            RemoteGather.needProcessMessages.Remove(p);


            currentRetryCount = 0;
            remoteGUI.SucessConnectGUI();
            break;

        //StillOnlineMessage
        case 98:

            string log5 = "Process StillOnlineMessage";
            Debug.Log(log5);
            GlobalDebug.Addline(log5, true);
            RemoteGather.needProcessMessages.Remove(p);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(99).GetBytesData(), false);
            break;


        //服务器断线
        case 106:
            string log6 = "Receive 服务器断线,尝试重进房间";
            Debug.Log(log6);
            GlobalDebug.Addline(log6);
            RemoteGather.needProcessMessages.Remove(p);
            //服务器断线得重新再进房间
            ReEnterRoom();

            //remoteGUI.OKCloseOnLineTalk("服务器断线");

            break;



        //退出讲盘进入视频通话
        case 250:
            string log250 = "Receive 退出讲盘进入视频通话";
            Debug.Log(log250);
            GlobalDebug.Addline(log250);
            RemoteGather.needProcessMessages.Remove(p);

            SendCtrlMessage(new RemoteGather.RemoteMessage(251).GetBytesData(), true);
            remoteGUI.FinishGotoVediaoTalk();

            break;

        //退出讲盘进入视频通话Ack
        case 251:
            string log251 = "Receive 退出讲盘进入视频通话 Ack";
            Debug.Log(log251);
            GlobalDebug.Addline(log251);
            RemoteGather.needProcessMessages.Remove(p);

            remoteGUI.FinishGotoVediaoTalk();

            break;



        //退出讲盘
        case 252:
            string log7 = "Receive 退出讲盘";
            Debug.Log(log7);
            GlobalDebug.Addline(log7);
            RemoteGather.needProcessMessages.Remove(p);

            SendCtrlMessage(new RemoteGather.RemoteMessage(253).GetBytesData(), true);
            remoteGUI.FinishOnLineTalk("退出讲盘");

            break;

        //退出讲盘Ack
        case 253:
            string log253 = "Receive 退出讲盘 Ack";
            Debug.Log(log253);
            GlobalDebug.Addline(log253);
            RemoteGather.needProcessMessages.Remove(p);

//              SendCtrlMessage(new RemoteGather.RemoteMessage(253).GetBytesData(), false);
            ExitRoomMessageToServer();
            remoteGUI.FinishOnLineTalk("退出讲盘 Ack");

            //ExitRoom();
            break;

        //收到未知报头,给对方发送收到未知报头
        case 254:
            string log8 = "Receive 收到未知报头";
            Debug.Log(log8);
            GlobalDebug.Addline(log8, true);
            RemoteGather.needProcessMessages.Remove(p);

            //收到一个未知报头,也得给对方返回有一个消息,表示己方已收到消息但是不知道是什么消息,请重新发送最后一次消息 未知报头Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(255).GetBytesData(), false);

            break;


        default:
            break;
        }
    }