Esempio n. 1
0
    private void Update()
    {
        m_pressedButtonL = null;
        m_pressedButtonR = null;

        if (m_joycons == null || m_joycons.Count <= 0) return;

        //foreach (var button in m_buttons)
        //{
        //    if (m_joyconL.GetButton(button))
        //    {
        //        m_pressedButtonL = button;
        //    }
        //    if (m_joyconR.GetButton(button))
        //    {
        //        m_pressedButtonR = button;
        //    }
        //}

        if (Input.GetKeyDown(KeyCode.Z))
        {
            m_joyconL.SetRumble(160, 320, 0.6f, 200);
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            m_joyconR.SetRumble(160, 320, 0.6f, 200);
        }

        if(m_joyconR.GetButton(Joycon.Button.SHOULDER_2))
        {
            gameObject.transform.Translate(0, 0, 0.08f);
        }

        obj.transform.localRotation = new Quaternion(0, -m_joyconL.GetVector().z, 0, m_joyconL.GetVector().w);
    }
Esempio n. 2
0
 private void Update()
 {
     m_pressedButtonL = null;
     m_pressedButtonR = null;
     if (m_joycons == null || m_joycons.Count <= 0)
     {
         return;
     }
     foreach (var button in m_buttons)
     {
         if (m_joyconL.GetButton(button))
         {
             m_pressedButtonL = button;
         }
         if (m_joyconR.GetButton(button))
         {
             m_pressedButtonR = button;
         }
     }
     if (Input.GetKeyDown(KeyCode.Z))
     {
         m_joyconL.SetRumble(160, 320, 0.6f, 200);
     }
     if (Input.GetKeyDown(KeyCode.X))
     {
         m_joyconR.SetRumble(160, 320, 0.6f, 200);
     }
 }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        m_pressedButtonL = null;
        m_pressedButtonR = null;

        timer += 0.1f * Time.deltaTime;

        if (m_joyconL != null)
        {
            foreach (var button in m_buttons)
            {
                if (m_joyconL.GetButton(button))
                {
                    m_pressedButtonL = button;
                }
                if (m_joyconR.GetButton(button))
                {
                    m_pressedButtonR = button;
                }
            }

            SetJoyCon();
            JoyConAction();
        }

        //Debug.Log(joyconDec.button);
    }
Esempio n. 4
0
    private void Update()
    {
        //m_joyconL.SetRumble( 160, 320, 0.6f, 200 ); // 振動
        m_pressedButtonL = null;
        m_pressedButtonR = null;

        if (m_joyconL.GetButtonDown(Joycon.Button.DPAD_RIGHT))
        {
            //	number = Random.Range(0, Train.Length);

            Instantiate(Train[0], transform.position, transform.rotation);
            // 右ボタンが押された
            //	number = Random.Range(0, Train.Length);

            //Instantiate(Train[number], transform.position, transform.rotation);
        }

        if (m_joycons == null || m_joycons.Count <= 0)
        {
            return;
        }

        foreach (var button in m_buttons)
        {
            if (m_joyconL.GetButton(button))
            {
                m_pressedButtonL = button;
            }
            if (m_joyconR.GetButton(button))
            {
                m_pressedButtonR = button;
            }
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            m_joyconL.SetRumble(160, 320, 0.6f, 200);
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            m_joyconR.SetRumble(160, 320, 0.6f, 200);
        }
    }
Esempio n. 5
0
    private void Update()
    {
        m_pressedButtonL = null;
        m_pressedButtonR = null;

        if (m_joycons == null || m_joycons.Count <= 0)
        {
            return;
        }

        SetControllers();

        foreach (var button in m_buttons)
        {
            if (m_joyconL.GetButton(button))
            {
                m_pressedButtonL = button;
            }
            if (m_joyconR.GetButton(button))
            {
                m_pressedButtonR = button;
            }
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            m_joyconL.SetRumble(160, 320, 0.6f, 200);
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            m_joyconR.SetRumble(160, 320, 0.6f, 200);
        }

        for (int i = 0; i < isShake.Length; i++)
        {
            if (isShake[i])
            {
                SendDisturb(i);
            }
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        // left hand
        if (leftJoycon != null)
        {
            m_pressedButtonL = null;
            foreach (var button in m_buttons)
            {
                if (leftJoycon.GetButton(button))
                {
                    m_pressedButtonL = button;
                }
            }
            if (leftJoyconBase == Quaternion.identity)
            {
                leftJoyconBase = ConvertRot(leftJoycon.GetVector());
            }
            else if (m_pressedButtonL == Joycon.Button.SHOULDER_1)
            {
                leftJoyconBase = ConvertRot(leftJoycon.GetVector());
            }
            else
            {
                Quaternion prevRot = leftHand.transform.rotation;
                leftHand.transform.rotation = leftGusokuBase;
                Quaternion orientation = ConvertRot(leftJoycon.GetVector());
                Vector3    baseAxis    = (Quaternion.Inverse(leftJoyconBase) * orientation).eulerAngles;
                baseAxis = new Vector3(-baseAxis.x, baseAxis.y, -baseAxis.z);
                leftHand.transform.Rotate(baseAxis);
                leftHand.transform.rotation = Quaternion.Lerp(prevRot, leftHand.transform.rotation, 0.5f);
            }
        }
        // right hand
        if (rightJoycon != null)
        {
            m_pressedButtonR = null;
            foreach (var button in m_buttons)
            {
                if (rightJoycon.GetButton(button))
                {
                    m_pressedButtonR = button;
                }
            }
            if (rightJoyconBase == Quaternion.identity)
            {
                rightJoyconBase = ConvertRot(leftJoycon.GetVector());
                Debug.Log("right reset " + rightJoyconBase.eulerAngles);
            }
            else if (m_pressedButtonR == Joycon.Button.SHOULDER_1)
            {
                rightJoyconBase = ConvertRot(rightJoycon.GetVector());
            }
            else
            {
                Quaternion prevRot = rightHand.transform.rotation;
                rightHand.transform.rotation = rightGusokuBase;
                Quaternion orientation = ConvertRot(rightJoycon.GetVector());
                Debug.Log(orientation.eulerAngles);
                Vector3 baseAxis = (Quaternion.Inverse(rightJoyconBase) * orientation).eulerAngles;
                baseAxis = new Vector3(baseAxis.x, baseAxis.y, baseAxis.z);
                Debug.Log(orientation.eulerAngles.ToString() + " " + baseAxis);
                rightHand.transform.Rotate(baseAxis);
                rightHand.transform.rotation = Quaternion.Lerp(prevRot, rightHand.transform.rotation, 0.5f);
            }
        }

        // reset
        if (Input.GetKey(KeyCode.R))
        {
            StartCoroutine(DelayMethod(3.0f, () =>
            {
                leftJoyconBase  = Quaternion.identity;
                rightJoyconBase = Quaternion.identity;
            }));
        }
    }
Esempio n. 7
0
    private void FixedUpdate()
    {
        m_pressedButtonL = null;
        m_pressedButtonR = null;
        float motor    = 0.0f;
        float steering = 0.0f;

        if (m_joycons == null || m_joycons.Count > 0)
        {
            SetControllers();
            foreach (var button in m_buttons)
            {
                if (m_joyconL.GetButton(button))
                {
                    m_pressedButtonL = button;
                }
            }

            if (m_pressedButtonL == Joycon.Button.DPAD_DOWN)
            {
                motor = -1 * maxMotorTorque;
            }
            else if (m_pressedButtonL == Joycon.Button.DPAD_LEFT)
            {
                motor = maxMotorTorque;
            }
            steering = -1 * maxSteeringAngle * m_joycons[0].GetStick()[1];
        }
        else
        {
            motor    = -1 * maxMotorTorque * Input.GetAxis("Vertical");
            steering = maxSteeringAngle * Input.GetAxis("Horizontal");
        }

        AddDownForce();


        foreach (AxleInfo axleInfo in axleInfos)
        {
            if (axleInfo.steering)
            {
                axleInfo.leftWheel.steerAngle  = steering;
                axleInfo.rightWheel.steerAngle = steering;
            }

            if (axleInfo.motor)
            {
                //if (motor < 0)
                //{
                axleInfo.leftWheel.motorTorque  = motor;
                axleInfo.rightWheel.motorTorque = motor;
                //}
            }

            if (motor > 0)
            {
                axleInfo.leftWheel.brakeTorque  = breakTorque;
                axleInfo.rightWheel.brakeTorque = breakTorque;
            }
            else
            {
                axleInfo.leftWheel.brakeTorque  = 0;
                axleInfo.rightWheel.brakeTorque = 0;
            }
        }
    }
Esempio n. 8
0
    private void Update()
    {
        m_pressedButtonL = null;
        m_pressedButtonR = null;

        /* PC操作用
         *
         * if(Input.GetKeyDown(KeyCode.RightArrow)) {
         *      Vector2 pos = pointerRT.anchoredPosition;
         *      if(pos.x >= 850) return;
         *      pos.x += 40;
         *      pointerRT.anchoredPosition = pos;
         * }
         * if(Input.GetKeyDown(KeyCode.LeftArrow)) {
         *      Vector2 pos = pointerRT.anchoredPosition;
         *      if(pos.x <= 490) return;
         *      pos.x -= 40;
         *      pointerRT.anchoredPosition = pos;
         * }
         * if(Input.GetKeyDown(KeyCode.UpArrow)) {
         *      Vector2 pos = pointerRT.anchoredPosition;
         *      if(pos.y >= -97) return;
         *      pos.y += 40;
         *      pointerRT.anchoredPosition = pos;
         * }
         * if(Input.GetKeyDown(KeyCode.DownArrow)) {
         *      Vector2 pos = pointerRT.anchoredPosition;
         *      if(pos.y <= -457) return;
         *      pos.y -= 40;
         *      pointerRT.anchoredPosition = pos;
         * }
         *
         * if(Input.GetKeyDown(KeyCode.Space)) {
         *      setLamp_pc();
         * }
         *
         * PC操作用
         */

        if (m_joycons == null || m_joycons.Count <= 0)
        {
            return;
        }

        foreach (var button in m_buttons)
        {
            if (m_joyconL.GetButton(button))
            {
                m_pressedButtonL = button;
            }
            if (m_joyconR.GetButton(button))
            {
                m_pressedButtonR = button;
            }
        }

/*		if ( Input.GetKeyDown( KeyCode.Z ) )
 *              {
 *                      m_joyconL.SetRumble( 160, 320, 0.1f, 200 );
 *              }
 *              if ( Input.GetKeyDown( KeyCode.X ) )
 *              {
 *                      m_joyconL.SetRumble( 320, 640, 0.1f, 200 );
 *              }
 *
 *              if ( Input.GetKeyDown( KeyCode.P ) )
 *              {
 *                      m_joyconR.SetRumble( 160, 320, 0.1f, 200 );
 *              }
 */

        if (ashioto.isPlaying == true && Mathf.Abs(m_joyconL.GetStick() [0]) < 0.1f && Mathf.Abs(m_joyconL.GetStick() [1]) < 0.1f)
        {
            ashioto.Stop();
        }
        if (ashioto.isPlaying == false && (Mathf.Abs(m_joyconL.GetStick() [0]) > 0.1f || Mathf.Abs(m_joyconL.GetStick() [1]) > 0.1f))
        {
            ashioto.Play();
        }


        if (m_joyconL.GetStick()[0] > 0.1f)
        {
            Debug.Log("右");
            //this.transform.position += transform.right*0.1f*m_joyconL.GetStick ()[0];
            this.transform.position += transform.right * Speed * m_joyconL.GetStick()[0];
            //new Vector3 (m_joyconL.GetStick ()[0]*0.1f, 0, 0);
        }
        if (m_joyconL.GetStick()[0] < -0.1f)
        {
            Debug.Log("左");
            this.transform.position += transform.right * Speed * m_joyconL.GetStick()[0];
        }


        if (m_joyconL.GetStick()[1] > 0.1f)
        {
            Debug.Log("前");
            this.transform.position += transform.forward * Speed * m_joyconL.GetStick()[1];
        }
        if (m_joyconL.GetStick()[1] < -0.1f)
        {
            Debug.Log("後");
            this.transform.position += transform.forward * Speed * m_joyconL.GetStick()[1];
        }

        if ((m_joyconL.GetButtonDown(Joycon.Button.DPAD_RIGHT) ||
             m_joyconR.GetButtonDown(Joycon.Button.SHOULDER_2)) && RotateFlag == -1)
        {
            // 右ボタンが押された
            //RotateFlag=1;
            //transform.Rotate (new Vector3 (0, 1, 0), 90);
            mokuteki += 90f;
            if (mokuteki >= 360f)
            {
                mokuteki = 0f;
            }
            RotateFlag = 1;
        }
        if ((m_joyconL.GetButtonDown(Joycon.Button.DPAD_LEFT) ||
             m_joyconL.GetButtonDown(Joycon.Button.SHOULDER_2)) && RotateFlag == -1)
        {
            // 右ボタンが押された
            //RotateFlag=1;
            //transform.Rotate (new Vector3 (0, 1, 0), 90);
            mokuteki -= 90f;
            if (mokuteki <= -90f)
            {
                mokuteki = 270f;
            }
            RotateFlag = 2;
        }
        if (m_joyconL.GetButtonDown(Joycon.Button.DPAD_DOWN) && RotateFlag == -1)
        {
            // 右ボタンが押された
            //RotateFlag=1;
            //transform.Rotate (new Vector3 (0, 1, 0), 90);
            mokuteki += 180f;
            if (mokuteki >= 360f)
            {
                mokuteki -= 360f;
            }
            RotateFlag = 0;
        }


        /////JoyConR
        if (m_joyconR.GetButtonDown(Joycon.Button.DPAD_RIGHT))
        {
            // R右ボタンが押された(Y):赤
            // convertUI_to_World(1);
            Lamp1.color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 100.0f / 255.0f);
            setLamp(1);
        }

        if (m_joyconR.GetButtonDown(Joycon.Button.DPAD_UP))
        {
            // R上ボタンが押された(X):青
            // convertUI_to_World(2);
            Lamp2.color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 100.0f / 255.0f);
            setLamp(2);
        }

        if (m_joyconR.GetButtonDown(Joycon.Button.DPAD_LEFT))
        {
            // R左ボタンが押された(A):白
            // convertUI_to_World(0);
            Lamp0.color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 100.0f / 255.0f);
            setLamp(0);
        }

        joyR_pad_time++;
        joyR_pad_time_second++;
        if (m_joyconR.GetStick()[0] > 0.2f && joyR_pad_time > 8f)
        {
            joyR_pad_time = 0f;
            Debug.Log("右");
            joyR_leftright = true;
            // pointer.transform.position +=new Vector3 (m_joyconR.GetStick ()[0]*10f, 0, 0);
            Vector2 pos = pointerRT.anchoredPosition;
            if (pos.x >= 850)
            {
                return;
            }
            pos.x += 40;
            pointerRT.anchoredPosition = pos;
        }
        if (m_joyconR.GetStick()[0] < -0.2f && joyR_pad_time > 8f)
        {
            joyR_pad_time = 0f;
            Debug.Log("左");
            joyR_leftright = true;
            // pointer.transform.position +=new Vector3 (m_joyconR.GetStick ()[0]*10f, 0, 0);
            Vector2 pos = pointerRT.anchoredPosition;
            if (pos.x <= 490)
            {
                return;
            }
            pos.x -= 40;
            pointerRT.anchoredPosition = pos;
        }
        if (joyR_leftright == true && (m_joyconR.GetStick() [0] < 0.2f && m_joyconR.GetStick() [0] > -0.2f))
        {
            joyR_leftright = false;
        }

        if (m_joyconR.GetStick()[1] > 0.2f && joyR_pad_time_second > 8f)
        {
            joyR_pad_time_second = 0f;
            Debug.Log("前");
            // pointer.transform.position +=new Vector3 (0,m_joyconR.GetStick ()[1]*10f, 0);
            Vector2 pos = pointerRT.anchoredPosition;
            if (pos.y >= -97)
            {
                return;
            }
            pos.y += 40;
            pointerRT.anchoredPosition = pos;
        }
        if (m_joyconR.GetStick() [1] < -0.2f && joyR_pad_time_second > 8f)
        {
            joyR_pad_time_second = 0f;
            Debug.Log("後");
            // pointer.transform.position += new Vector3 (0,m_joyconR.GetStick () [1] * 10f, 0);
            Vector2 pos = pointerRT.anchoredPosition;
            if (pos.y <= -457)
            {
                return;
            }
            pos.y -= 40;
            pointerRT.anchoredPosition = pos;
        }

        if (RotateFlag >= 0)
        {
            PlayerRound(RotateFlag);
        }

        vibration_L(shindL_type, shind_L_kyori);
        vibration_R(shindR_type, shind_R_kyori);
    }