Example #1
0
 // Update is called once per frame
 private void scanBLEstate()
 {
     state.rectTransform.position = Vector3.zero;
     if (BTsocket.isConnectedBLE(Constants.bleMicroBit))
     {
         state.color = Color.green;
     }
     else
     {
         state.color = Color.red;
     }
 }
Example #2
0
    public IEnumerator waitLoop(System.Action connectedAct)
    {
        while (!BTsocket.isConnectedBLE(Constants.bleMicroBit))
        {
            yield return(0);
        }
        btSoc.subscribe();
        disConnectedBtn.gameObject.SetActive(true);
        connectedAct();
        //----------------------------

        /*cnt = 0;
         * recvCnt = 0;
         * InvokeRepeating("testMethod", 2f, 1f);*/
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        if (BTsocket.isConnectedBLE(Constants.bleMicroBit))
        {
            btSoc            = BTsocket.getBTsocket(Constants.bleMicroBit);
            connectHint.text = btSoc.bleLinkData.address;
            disConnectedBtn.gameObject.SetActive(true);
        }
        else
        {
            linkButtonPos   = -50;
            linkBtnFragment = 100;
            btSoc           = BTsocket.getNewBTsocket(Constants.bleMicroBit, new BTprofile(Constants.bleMicroBit, true));
            Invoke("delayScan", 2f);
        }

        //BLEStateUICtrl.addBLEstateUI(BTsocket.getBTsocket(Constants.bleMicroBit).gameObject);
    }
Example #4
0
    private void OnClick()
    {
        //GameObject.Find(Constants.bleMicroBit).GetComponent<BTsocket>().connect(address);
        //-----測試功能-----
        if (!BTsocket.isConnectedBLE(Constants.bleMicroBit))
        {
            GameObject.Find("EventSystem").GetComponent <BTManager>().connectAct(this,
                                                                                 () =>
            {
                this.GetComponentInChildren <Text>().color = Color.blue;
                BLEStateUICtrl.addBLEstateUI(BTsocket.getBTsocket(Constants.bleMicroBit).gameObject);
            });
        }
        else
        {
            GameObject.Find("EventSystem").GetComponent <BTManager>().disConnected();
            this.GetComponentInChildren <Text>().color = Color.black;
        }
        //this.GetComponentInChildren<Text>().color = Color.blue;

        //PlayerPrefs.SetString("preConnectMAC", address);
    }
Example #5
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
        }
    }
Example #6
0
    // Start is called before the first frame update
    void Start()
    {
        if (XRSettings.loadedDeviceName != XRSettings.supportedDevices[1])
        {
            XRSettings.LoadDeviceByName(XRSettings.supportedDevices[1]);
        }
        if (XRSettings.loadedDeviceName == XRSettings.supportedDevices[1])
        {
            XRSettings.enabled = false;
        }
        Screen.fullScreen           = false;
        Screen.autorotateToPortrait = true;
        Screen.orientation          = ScreenOrientation.Portrait;

        if (!debugMode)
        {
            foreach (var btn in gameBtn)
            {
                btn.interactable = BTsocket.isConnectedBLE(Constants.bleMicroBit);
            }
        }

        NetworkManager.Shutdown();
    }