コード例 #1
0
    public void RegisterHost(string name)
    {
        RegisterHostMessage msg = new RegisterHostMessage();

        msg.gameName          = name;
        msg.comment           = "test";
        msg.passwordProtected = false;

        client.Send(RegisterHostMsgId, msg);
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        RegisterHostMessage msg = new RegisterHostMessage();

        msg.gameName          = name;
        msg.comment           = "test";
        msg.passwordProtected = false;

        myClient.Send(RegisterHostMsgId, msg);
    }
コード例 #3
0
ファイル: Client.cs プロジェクト: Amathlog/UnityGyro
    public void SendRegisterHostMessage(NetworkMessage netMsg)
    {
        RegisterHostMessage msg = new RegisterHostMessage();

        msg.deviceId   = getConnectionId();
        msg.deviceName = SystemInfo.deviceName;
        msg.version    = SystemInfo.deviceModel;
        msg.accelerometerCompatible = SystemInfo.supportsAccelerometer;
        SendMessage(RegisterHostMessage.id, msg);
    }
コード例 #4
0
ファイル: Server.cs プロジェクト: Amathlog/UnityGyro
    private void OnReceivedRegisterHostMessage(NetworkMessage netMsg)
    {
        RegisterHostMessage msg = netMsg.ReadMessage <RegisterHostMessage>();

        Debug.Log("Message received : ");
        Debug.Log(msg.ToString());

        DeviceInfo newDevice = new DeviceInfo(netMsg.conn.connectionId, msg.deviceName, msg.accelerometerCompatible);

        Debug.Log("ConnectionID : " + newDevice.id);
        Debug.Log(getNumberRegisteredDevices());
        this.registeredDevices.Add(newDevice.id, newDevice);
        Debug.Log(getNumberRegisteredDevices());
    }
コード例 #5
0
    private void ClientReciveMessage(NetworkMessage netmsg)
    {
        //Debug.Log("ClientReciveMessage");
        //JObject json = new JObject
        //    {
        //        { "commMode", 1},                               // 新增通讯模式字段,0表示单播,1表示组播
        //        { "stageId", panelID},                           // 正在哪个panel
        //        { "gId", groupID},                              // 组ID: 0~3表示四个组
        //        { "uId", userID},                               // 用户ID:0或1, 0表示大将,1表示 马
        //        { "joystickAvailable", joystickAvailable},      // 当前摇杆是否可以操控,0表示不行,1表示可以
        //        { "coolingTime", coolingTime}                   //剩余冷却时间
        //    };
        msg = netmsg.ReadMessage <RegisterHostMessage>();
        Debug.Log(msg.m_Comment);
        JObject ServerMessage = JObject.Parse(msg.m_Comment);

        commMode          = (int)ServerMessage["commMode"];
        panelID           = (int)ServerMessage["stageId"]; // 场景ID 场景状态机由此切换
        joystickAvailable = (int)ServerMessage["joystickAvailable"];
        coolingTime       = (int)ServerMessage["coolingTime"];

        int temp_gId = (int)ServerMessage["gId"];
        int temp_uId = (int)ServerMessage["uId"];

        if (commMode == 1 && panelID == 0)               // 场景0时的组播为选人确认组播
        {
            // 此处将按键对应失能
            //buttons[temp_gId * 2 + temp_uId].interactable = false;
            if (temp_gId == groupID && temp_uId == userID && flagButtonPressed == true)
            {
                foreach (Button button in buttons)
                {
                    button.interactable = false;
                }
            }
            else
            {
                buttons[temp_gId * 2 + temp_uId].interactable = false;
            }
        }
    }
コード例 #6
0
 public void ReceiveMessage(NetworkMessage networkMessage)
 {
     RegisterHostMessage hostMessage = networkMessage.ReadMessage <RegisterHostMessage>();
     string receivedName             = hostMessage.m_Name;
 }
コード例 #7
0
 void EditMessage(string myName)
 {
     m_Message        = new RegisterHostMessage();
     m_Message.m_Name = myName;
 }
コード例 #8
0
ファイル: serv.cs プロジェクト: devil304/BialJam2018
    public void messrecived(NetworkMessage netMsg)
    {
        RegisterHostMessage rhm  = netMsg.ReadMessage <RegisterHostMessage>();
        Vector3             tmp  = rhm.rotaterate;
        Vector3             tmpx = rhm.accel;

        if (tmpx.y > tess[0])
        {
            tess[0] = tmpx.y;
        }
        else if (tmpx.y < tess[1])
        {
            tess[1] = tmpx.y;
        }
        //Debug.Log(tmp+" # "+tmpx);
        for (int ti = 0; ti < ids.Length; ti++)
        {
            if (ids[ti] == netMsg.conn.connectionId)
            {
                if (rhm.tc.Length == 1)
                {
                    switch (rhm.tc[0].phase)
                    {
                    case 0:
                        startpost[ti]  = rhm.tc[0].pos;
                        wektorpada[ti] = new Vector2(0, 0);
                        break;

                    case 1:
                        if ((rhm.tc[0].pos - startpost[ti]).magnitude >= 150)
                        {
                            wektorpada[ti] = new Vector2((rhm.tc[0].pos - startpost[ti]).x, (rhm.tc[0].pos - startpost[ti]).y);
                        }
                        break;
                    }
                    if (rhm.tc[0].phase != 3 && rhm.tc[0].phase != 4 && rhm.tc[0].phase != 0)
                    {
                        if (!archerrr[ti])
                        {
                            Debug.Log("nodziała");
                            tix = ti;
                        }
                        else
                        {
                            animki[ti].SetInteger("animka", 0);
                            dcien = wektorpada[ti].magnitude;
                        }
                    }
                    else if (rhm.tc[0].phase == 3 || rhm.tc[0].phase == 4)
                    {
                        wektorpada[ti] = new Vector2(0, 0);
                        animki[ti].SetInteger("animka", 0);
                    }
                }
                //Debug.Log(wektorpada[ti]);
                if (ti == 0)
                {
                    if (tests && tmpx.y < -0.75)
                    {
                        dzig[ti] = true;
                        tests    = false;
                    }
                    if (tmpx.y > 3)
                    {
                        tests = true;
                    }
                    if (rt[ti].anchoredPosition.y < -450)
                    {
                        if (tmp.x * lolnope > 0 && rt[ti].anchoredPosition.y > -500)
                        {
                            rt[ti].transform.Translate(Vector3.up * tmp.x * lolnope);
                        }
                        if (tmp.x * lolnope > 0 && camwych[ti] > -40)
                        {
                            cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * (lolnope * 80));
                            camwych[ti] -= (lolnope * 80);
                        }
                        else if (rt[ti].anchoredPosition.y <= -500)
                        {
                            rt[ti].transform.Translate(Vector3.up * tmp.x * lolnope);
                        }
                        else if (tmp.x * lolnope < 0 && camwych[ti] > -40)
                        {
                            cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * ((lolnope * 80) - (tmp.x)));
                            camwych[ti] -= (lolnope * 80) - (tmp.x);
                        }
                    }
                    else if (rt[ti].anchoredPosition.y > 450)
                    {
                        if (tmp.x * lolnope < 0 && rt[ti].anchoredPosition.y < 500)
                        {
                            rt[ti].transform.Translate(Vector3.up * tmp.x * lolnope);
                        }
                        if (tmp.x * lolnope < 0 && camwych[ti] < 50)
                        {
                            cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * (-lolnope * 80));
                            camwych[ti] -= (-lolnope * 80);
                        }
                        else if (rt[ti].anchoredPosition.y >= 500)
                        {
                            rt[ti].transform.Translate(Vector3.up * tmp.x * lolnope);
                        }
                        else if (tmp.x * lolnope > 0 && camwych[ti] < 50)
                        {
                            cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * ((-lolnope * 60) - (tmp.x)));
                            camwych[ti] -= (-lolnope * 80) - (tmp.x);
                        }
                    }
                    else
                    {
                        rt[ti].transform.Translate(Vector3.up * tmp.x * lolnope);
                    }
                    if (rt[ti].anchoredPosition.y >= 600)
                    {
                        rt[ti].anchoredPosition = new Vector2(rt[ti].anchoredPosition.x, 490);
                    }
                    else if (rt[ti].anchoredPosition.y <= -600)
                    {
                        rt[ti].anchoredPosition = new Vector2(rt[ti].anchoredPosition.x, -490);
                    }
                    if (rt[ti].anchoredPosition.x >= 500)
                    {
                        rt[ti].anchoredPosition = new Vector2(390, rt[ti].anchoredPosition.y);
                    }
                    else if (rt[ti].anchoredPosition.x <= -500)
                    {
                        rt[ti].anchoredPosition = new Vector2(-390, rt[ti].anchoredPosition.y);
                    }


                    if (rt[ti].anchoredPosition.x < -350)
                    {
                        if (-tmp.z * lolnope > 0 && rt[ti].anchoredPosition.x > -400)
                        {
                            rt[ti].transform.Translate(Vector3.right * -tmp.z * lolnope);
                        }
                        if (-tmp.z * lolnope > 0)
                        {
                            cbs[ti].transform.Rotate(-Vector3.up * (lolnope * 80));
                        }
                        else if (rt[ti].anchoredPosition.x <= -400)
                        {
                            rt[ti].transform.Translate(Vector3.right * -tmp.z * lolnope);
                        }
                        else if (-tmp.z * lolnope < 0)
                        {
                            cbs[ti].transform.Rotate(-Vector3.up * ((lolnope * 80) - (-tmp.z)));
                        }
                    }
                    else if (rt[ti].anchoredPosition.x > 350)
                    {
                        if (-tmp.z * lolnope < 0 && rt[ti].anchoredPosition.x < 400)
                        {
                            rt[ti].transform.Translate(Vector3.right * -tmp.z * lolnope);
                        }
                        if (-tmp.z * lolnope < 0)
                        {
                            cbs[ti].transform.Rotate(-Vector3.up * (-lolnope * 80));
                        }
                        else if (rt[ti].anchoredPosition.x >= 400)
                        {
                            rt[ti].transform.Translate(Vector3.right * -tmp.z * lolnope);
                        }
                        else if (-tmp.z * lolnope > 0)
                        {
                            cbs[ti].transform.Rotate(-Vector3.up * ((-lolnope * 80) - (-tmp.z)));
                        }
                    }
                    else
                    {
                        rt[ti].transform.Translate(Vector3.right * -tmp.z * lolnope);
                    }
                    trranstest[ti]  = Vector3.forward * tmp.x * lolnope;
                    trranstest[ti] += Vector3.right * tmp.z * lolnope;
                    rt[ti].Rotate(Vector3.forward * -tmp.y);
                    cube[ti].Rotate(Vector3.up * -tmp.y);
                }
                else
                {
                    if (upcorrect == -100 && leftcor == -100 && forcorr == -100)
                    {
                        if (tmpxx == -100 && tmpy == -100 && tmpz == -100 && (tmp.x != 0 && tmp.z != 0 && tmp.y != 0))
                        {
                            tmpxx = tmp.x;
                            tmpy  = tmp.y;
                            tmpz  = tmp.z;
                        }
                        if (tmpxx < 0 && tmp.x < tmpxx && tmp.x != 0)
                        {
                            tmpxx = tmp.x;
                        }
                        else if (tmpxx > 0 && tmp.x > tmpxx && tmp.x != 0)
                        {
                            tmpxx = tmp.x;
                        }
                        if (tmpy < 0 && tmp.y < tmpy && tmp.y != 0)
                        {
                            tmpy = tmp.y;
                        }
                        else if (tmpy > 0 && tmp.y > tmpy && tmp.y != 0)
                        {
                            tmpy = tmp.y;
                        }
                        if (tmpz < 0 && tmp.z < tmpz && tmp.z != 0)
                        {
                            tmpz = tmp.z;
                        }
                        else if (tmpz > 0 && tmp.z > tmpz && tmp.z != 0)
                        {
                            tmpz = tmp.z;
                        }
                        StartCoroutine(corrpls());
                    }
                    else
                    {
                        if (tests && tmpx.y < -1)
                        {
                            dzig[ti] = true;
                            tests    = false;
                        }
                        if (tmpx.y > 1.9)
                        {
                            tests = true;
                        }
                        float corrx = tmp.x - upcorrect;
                        float corrz = tmp.z - leftcor;
                        float corry = tmp.y - forcorr;
                        if (rt[ti].anchoredPosition.y < -450)
                        {
                            if (corrx * lolnope > 0 && rt[ti].anchoredPosition.y > -500)
                            {
                                rt[ti].transform.Translate(Vector3.up * corrx * lolnope);
                            }
                            if (corrx * lolnope > 0 && camwych[ti] > -40)
                            {
                                cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * (lolnope * 80));
                                camwych[ti] -= (lolnope * 80);
                            }
                            else if (rt[ti].anchoredPosition.y <= -500)
                            {
                                rt[ti].transform.Translate(Vector3.up * corrx * lolnope);
                            }
                            else if (corrx * lolnope < 0 && camwych[ti] > -40)
                            {
                                cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * ((lolnope * 80) - (corrx)));
                                camwych[ti] -= ((lolnope * 80) - (corrx));
                            }
                        }
                        else if (rt[ti].anchoredPosition.y > 450)
                        {
                            if (corrx * lolnope < 0 && rt[ti].anchoredPosition.y < 500)
                            {
                                rt[ti].transform.Translate(Vector3.up * corrx * lolnope);
                            }
                            if (corrx * lolnope < 0 && camwych[ti] < 50)
                            {
                                cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * (-lolnope * 80));
                                camwych[ti] -= (-lolnope * 80);
                            }
                            else if (rt[ti].anchoredPosition.y >= 500)
                            {
                                rt[ti].transform.Translate(Vector3.up * corrx * lolnope);
                            }
                            else if (corrx * lolnope > 0 && camwych[ti] < 50)
                            {
                                cameras[ti].transform.parent.transform.parent.transform.Rotate(Vector3.right * ((-lolnope * 80) - (corrx)));
                                camwych[ti] -= (-lolnope * 80) - (corrx);
                            }
                        }
                        else
                        {
                            rt[ti].transform.Translate(Vector3.up * corrx * lolnope);
                        }
                        if (rt[ti].anchoredPosition.y >= 600)
                        {
                            rt[ti].anchoredPosition = new Vector2(rt[ti].anchoredPosition.x, 490);
                        }
                        else if (rt[ti].anchoredPosition.y <= -600)
                        {
                            rt[ti].anchoredPosition = new Vector2(rt[ti].anchoredPosition.x, -490);
                        }
                        if (rt[ti].anchoredPosition.x >= 500)
                        {
                            rt[ti].anchoredPosition = new Vector2(390, rt[ti].anchoredPosition.y);
                        }
                        else if (rt[ti].anchoredPosition.x <= -500)
                        {
                            rt[ti].anchoredPosition = new Vector2(-390, rt[ti].anchoredPosition.y);
                        }


                        if (rt[ti].anchoredPosition.x < -350)
                        {
                            if (-corrz * lolnope > 0 && rt[ti].anchoredPosition.x > -400)
                            {
                                rt[ti].transform.Translate(Vector3.right * -corrz * lolnope);
                            }
                            if (-corrz * lolnope > 0)
                            {
                                cbs[ti].transform.Rotate(-Vector3.up * (lolnope * 80));
                            }
                            else if (rt[ti].anchoredPosition.x <= -400)
                            {
                                rt[ti].transform.Translate(Vector3.right * -corrz * lolnope);
                            }
                            else if (-corrz * lolnope < 0)
                            {
                                cbs[ti].transform.Rotate(-Vector3.up * ((lolnope * 80) - (-corrz)));
                            }
                        }
                        else if (rt[ti].anchoredPosition.x > 350)
                        {
                            if (-corrz * lolnope < 0 && rt[ti].anchoredPosition.x < 400)
                            {
                                rt[ti].transform.Translate(Vector3.right * -corrz * lolnope);
                            }
                            if (-corrz * lolnope < 0)
                            {
                                cbs[ti].transform.Rotate(-Vector3.up * (-lolnope * 80));
                            }
                            else if (rt[ti].anchoredPosition.x >= 400)
                            {
                                rt[ti].transform.Translate(Vector3.right * -corrz * lolnope);
                            }
                            else if (-corrz * lolnope > 0)
                            {
                                cbs[ti].transform.Rotate(-Vector3.up * ((-lolnope * 80) - (-corrz)));
                            }
                        }
                        else
                        {
                            rt[ti].transform.Translate(Vector3.right * -corrz * lolnope);
                        }
                        trranstest[ti]  = Vector3.forward * corrx * lolnope;
                        trranstest[ti] += Vector3.right * corrz * lolnope;
                        rt[ti].Rotate(Vector3.forward * -corry);
                        cube[ti].Rotate(Vector3.up * -corry);
                    }
                }
                if (rhm.tc.Length == 1)
                {
                    if (rhm.tc[0].phase == 1)
                    {
                        notmoved[ti] = false;
                    }
                    else if (rhm.tc[0].phase == 0)
                    {
                        notmoved[ti] = true;
                    }
                    if (rhm.tc[0].phase == 3 && rhm.tc[0].tc == 2 && notmoved[ti])
                    {
                        Debug.Log("wtf");
                        Transform tmpp = handstart[ti].parent;
                        handstart[ti].parent        = cube[ti].transform.parent;
                        cube[ti].transform.position = handstart[ti].position;
                        handstart[ti].parent        = tmpp;
                        rt[ti].anchoredPosition     = startrttr[ti];
                        cube[ti].transform.rotation = handstart[ti].rotation;
                        rt[ti].localRotation        = startrtrot[ti];
                        if (archerrr[ti] && tmpx.x >= 0.8)
                        {
                            cube[ti].transform.Rotate(Vector3.up * 90);
                            rt[ti].Rotate(Vector3.forward * -90);
                        }
                        else if (archerrr[ti] && tmpx.x <= -0.8)
                        {
                            cube[ti].transform.Rotate(Vector3.up * -90);
                            rt[ti].Rotate(Vector3.forward * 90);
                        }
                    }
                    else if (archerrr[ti] && rhm.tc[0].phase == 3 && rhm.tc[0].tc == 3 && notmoved[ti])
                    {
                        archerrr[ti] = false;
                    }
                    else if (!archerrr[ti] && rhm.tc[0].phase == 3 && rhm.tc[0].tc == 3 && notmoved[ti] && (tmpx.x >= 0.9 || tmpx.x <= -0.9))
                    {
                        archerrr[ti] = true;
                    }
                    lastphase[ti] = rhm.tc[0].phase;
                }
            }
        }
    }