Ejemplo n.º 1
0
  // Update is called once per frame
  void Update()
  {
      bool afb = b;

      setnum();
      setpoint();
      byte[] test = new byte[1];
      if (Input.GetKey(KeyCode.W))
      {
          byWrite(true);
          SerialMain.Write(test);
      }
      else if (Input.GetKey(KeyCode.Q))
      {
          byWrite(false);
          SerialMain.Write(test);
      }
      if (b && !afb)
      {
          boolB = true;
      }
      else
      {
          boolB = false;
      }
      if (afb && !b)
      {
          rostB = true;
      }
      else
      {
          rostB = false;
      }
      //Debug.Log("onbool;"+boolB+"onrost;"+rostB);
  }
Ejemplo n.º 2
0
 static public void byWrite(bool t_f)
 {
     byte[] test = new byte[1];
     if (t_f)
     {
         test[0] = (byte)'1';
         SerialMain.Write(test);
     }
     else
     {
         test[0] = (byte)'0';
         SerialMain.Write(test);
     }
 }
Ejemplo n.º 3
0
    private IEnumerator Moving(float dx, float dz)
    {
        flag = nekojarashi.idou_flag;
        Debug.Log(Mathf.Abs(Mathf.Sqrt(Mathf.Pow((direction_vector_x), 2) + Mathf.Pow((direction_vector_z), 2))) + " " + direction_vector_x + " " + direction_vector_z);

        if (Mathf.Abs(Mathf.Sqrt(Mathf.Pow((direction_vector_x), 2) + Mathf.Pow((direction_vector_z), 2))) >= hanni)
        {
            if (flag)
            {
                transform.position += transform.forward * speed;
                animator.SetBool(anim_name[0], true);
            }
            else
            {
                animator.SetBool(anim_name[0], false);
            }
        }
        else if (Mathf.Abs(Mathf.Sqrt(Mathf.Pow((direction_vector_x), 2) + Mathf.Pow((direction_vector_z), 2))) < hanni)
        {
            animator.SetBool(anim_name[0], false);
            SE_flag = se_con.SE_flag;
            if (once_flag)
            {
                SE_flag   = true;
                once_flag = false;
            }
            if (SE_flag)
            {
                if (flag)
                {
                    var i = Random.Range(1, 4);
                    animator.SetTrigger(anim_name[i]);
                    byte[] data = new byte[1];
                    data[0] = 0x61; //aを送信
                    serial.Write(data);
                }
            }
        }
        yield return(new WaitForSeconds(0.5f));
    }
Ejemplo n.º 4
0
 public void OnPushed()
 {
     byte[] data = new byte[1];
     data[0] = 0x61; //aを送信
     serial.Write(data);
 }