Ejemplo n.º 1
0
 public void testMethod()
 {
     btSoc.getReceiveText((data) => { recvCnt = int.Parse(data); });
     btSoc.writeCharacteristic("#");
     cnt++;
     connectHint.text = "傳送資料次數:" + cnt.ToString() + " 回傳次數:" + recvCnt.ToString();
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        gunSetPos.transform.position = mainCamera.transform.position; //讓槍跟著鏡頭移動

        gunSetPos.transform.eulerAngles = new Vector3(                //調整槍枝讓其對準
            gunSetPos.transform.eulerAngles.x,
            mainCamera.transform.eulerAngles.y,
            gunSetPos.transform.eulerAngles.z);

        //---------使用鍵盤模擬輸入,測試用-----------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        /*if (Input.inputString.Length > 0 && oldState != Input.inputString.ToCharArray()[0])
         * {
         *      gunStateChangedEvt?.Invoke(this, Input.inputString.ToCharArray()[0]); //觸發事件,送出槍目前狀態
         *      oldState = Input.inputString.ToCharArray()[0];
         *      Debug.Log(Input.inputString);
         * }*/

        //-------------------------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        if (!BTsocket.isConnectedBLE(Constants.bleMicroBit))
        {
            return;
        }

        ble.getReceiveText((data) =>
        {
            gunMotionCtrl(data);
        });

        float deltaAngle = Mathf.Abs(mainCamera.transform.eulerAngles.y - cameraAngle);

        if (!(deltaAngle < 10 || deltaAngle > 350) && Mathf.Abs(mtData.angle) > 10)
        {
            cameraAngle = mainCamera.transform.eulerAngles.y; //reset
            set_stAngle();                                    //reset
        }
    }