Пример #1
0
    void OnGUI()
    {
        if (GUILayout.Button("1", GUILayout.Width(200f), GUILayout.Height(60f)))
        {
            // 文字列nを送信
            _serialPort.Write("1");
        }

        if (GUILayout.Button("f", GUILayout.Width(200f), GUILayout.Height(60f)))
        {
            // 文字列fを送信
            _serialPort.Write("f");
        }
    }
Пример #2
0
 void Update()
 {
     p = (int)Input.mousePosition.x / 4;
     if (Input.GetMouseButton(0))
     {
         Debug.Log(p);
         s = p.ToString();
         _serialPort.Write(s);
     }
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("up"))
        {
            Debug.Log("up");
            transform.position += new Vector3(0, 0.1f, 0);
        }
        if (Input.GetKey("down"))
        {
            Debug.Log("down");
            transform.position += new Vector3(0, -0.1f, 0);
        }
        if (Input.GetKey("right"))
        {
            Debug.Log("right");
            transform.position += new Vector3(0.1f, 0, 0);
        }
        if (Input.GetKey("left"))
        {
            Debug.Log("left");
            transform.position += new Vector3(-0.1f, 0, 0);
        }

        //Debug.Log("desu"+maincontroller.f);



        if (hasamari)
        {
            timecount += 0.1;
            Debug.Log("かぞえてるのは" + timecount + "roadsellは" + maincontroller.f);
            if (maincontroller.f >= 1.0f && timecount >= 5.0)
            {
                Debug.Log("jは" + j + "," + maincontroller.f);

                _serialPort.Write("4");

                timecount = 0.0;

                hasamari = false;
            }
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("up"))
        {
            Debug.Log("up");
            transform.position += new Vector3(0, 0.1f, 0);
        }
        if (Input.GetKey("down"))
        {
            Debug.Log("down");
            transform.position += new Vector3(0, -0.1f, 0);
        }
        if (Input.GetKey("right"))
        {
            Debug.Log("right");
            transform.position += new Vector3(0.1f, 0, 0);
        }
        if (Input.GetKey("left"))
        {
            Debug.Log("left");
            transform.position += new Vector3(-0.1f, 0, 0);
        }

        //Debug.Log("desu"+maincontroller.f);
        //Debug.Log("aaaは"+maincontroller2.aaa);
        //Debug.Log("jは" + j);


        if (int.Parse(maincontroller2.aaa) != j)
        {
            Debug.Log("------------------ダメージに" + (j + 1) + "ヒット目-------------------");

            /*
             * if (hasamari)
             * {
             *  hasamari = false;
             * }
             *
             */

            //次の木のobjectを有効にする
            kusabi_objects[int.Parse(maincontroller2.aaa)].gameObject.SetActive(true);
            //今の木のobjectを無効にする
            kusabi_objects[j].gameObject.SetActive(false);

            j = int.Parse(maincontroller2.aaa);


            hitpos = this.transform.position;
            emitParams.position = hitpos;
            hitpos_axetip       = axeTip.transform.position;
            //Debug.Log("hitposは"+hitpos);
            //Debug.Log("axetipは"+axeTip.transform.position);
            Invoke("DoEmit", 0f);



            // 文字列nを送信
            if (j > 1 && j <= 8)
            {
                Debug.Log("挟まり感!!jは、" + j);
                _serialPort.Write("1");
                hasamari = true;
            }


            //最後の木なら終了のメッセージを出す
            if (j == 10)
            {
                Debug.Log("終了");
                //挟まり感、衝撃感ブレーキ解除
                _serialPort.Write("2");
                _serialPort.Write("4");
                kusabi_Destroy.gameObject.SetActive(false);
            }



            if (timecountAudio >= 1.0)
            {
                //斧が木に触れたときに呼び出される
                //play sound effect
                //GetComponent<AudioSource>().Play();  // 効果音を
                audioSource      = gameObject.GetComponent <AudioSource>();
                audioSource.clip = audioClip2;
                audioSource.Play();
                timecountAudio = 0.0;
                otonari        = true;
            }
        }

        if (otonari)
        {
            timecountAudio += 0.1;
            if (timecountAudio >= 1.0)
            {
                timecountAudio = 1.0;
                otonari        = false;
            }
        }



        if (hasamari)
        {
            timecount += 0.1;
            //Debug.Log("かぞえてるのは" + timecount + "roadsellは" + maincontroller.f);
            if (maincontroller.f >= 6.0f && timecount >= 5.0)
            {
                Debug.Log("挟まり感終了!!jは、" + j);
                Debug.Log("jは" + j + "," + maincontroller.f);

                _serialPort.Write("4");

                timecount = 0.0;

                hasamari = false;
            }
        }
    }
Пример #5
0
 void Send()
 {
     // micro:bitに送信する任意の文字列
     _serialPortWrapper.Write("hoge:");
 }