示例#1
0
 void Update()
 {
     touchinfo = script.GetTouch();
     if (touchinfo == 2)
     {
         rightchange();
     }
     if (touchinfo == 1)
     {
         leftchange();
     }
     if (touchinfo == -1)
     {
         mannnakabutton();
     }
 }
示例#2
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (GameObject.Find("playerObjectUp").GetComponent <mainPlayerAnimation>().pauseTrigger == false)
        {
            elapsedTime += Time.deltaTime;
            sceneTime   += Time.deltaTime;
        }
        if (elapsedTime - lastTouchTime >= durationToHint)
        {
            int hintDir = GetComponent <movePlayer>().nextPredictedDirection;

            if (hintDir == 0)              //down
            {
                downHint.SetActive(true);
            }
            else if (hintDir == 1)              //left
            {
                leftHint.SetActive(true);
            }
            else if (hintDir == 2)              //up
            {
                upHint.SetActive(true);
            }
            else if (hintDir == 3)              //right
            {
                rightHint.SetActive(true);
            }
        }
        if (sceneTime >= 10f && (SceneManager.GetActiveScene().name == "Debug" || SceneManager.GetActiveScene().name == "RateMatch") && !bulbBool)
        {
            bulb.SetActive(true);
        }


        //Debug.Log(ret);
        this.acc = Input.acceleration;
        //画面の対角線を境にして重力による加速度のベクトルで判断
        float ru = Mathf.Atan2(1.0f, 1.0f);         //Mathf.Atan2(Screen.height / 2.0f, Screen.width / 2.0f);
        float lu = Mathf.Atan2(1.0f, -1.0f);        //Mathf.Atan2(Screen.height / 2.0f, -Screen.width / 2.0f);
        float ld = Mathf.Atan2(-1.0f, -1.0f);       //Mathf.Atan2(-Screen.height / 2.0f, -Screen.width / 2.0f);
        float rd = Mathf.Atan2(-1.0f, 1.0f);        //Mathf.Atan2(-Screen.height / 2.0f, Screen.width / 2.0f);

        float d = Mathf.Atan2(acc.y, acc.x);


        //Debug.Log(touchScript);
        if (0 <= touchScript.GetTouch())
        {
            lastTouch = touchScript.GetTouch();
        }
        bool trigger  = GetComponent <mainPlayerAnimation>().moveTrigger;
        bool isPaused = GetComponent <mainPlayerAnimation>().pauseTrigger;

        if (GameObject.Find("pointsText").GetComponent <timeCounter>().timeCntFirst < 3f)
        {
            isPaused = true;
        }


        //PC操作時はここをコメントアウト

        if (lastTouch == 4)
        {
            ret = 0;
        }                                       //もし、下向きなら!
        if (lastTouch == 1)
        {
            ret = 1;
        }                                       //右
        if (lastTouch == 3)
        {
            ret = 2;
        }                                       //上
        if (lastTouch == 2)
        {
            ret = 3;
        }                                       //左
        if (lastTouch == 0)
        {
            ret = 5;
        }

        if (ret == 0 && !trigger && ret != beforeDirection && !isPaused)          //down
        {
            lastTouchTime = Time.time;
            handCount++;
            int flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 0;
            ifInput(ret);

            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (ret == 2 && !trigger && ret != beforeDirection && !isPaused)          //up
        {
            lastTouchTime = Time.time;
            handCount++; int flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 2;

            ifInput(ret);
            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (ret == 1 && !trigger && ret != beforeDirection && !isPaused)
        {
            lastTouchTime = Time.time;
            handCount++; int flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string           sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 1; ifInput(ret);
            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (ret == 3 && !trigger && ret != beforeDirection && !isPaused)
        {
            lastTouchTime = Time.time;
            handCount++; int flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string           sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 3;
            ifInput(ret);
            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90.0f));
        }
        //

        if (Input.GetKeyDown(KeyCode.DownArrow) && !trigger && 0 != beforeDirection && !isPaused)
        {
            lastTouchTime = elapsedTime;
            handCount++;
            int    flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();

            ret = beforeDirection = 0;
            ifInput(ret);


            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (Input.GetKeyDown(KeyCode.UpArrow) && !trigger && 2 != beforeDirection && !isPaused)
        {
            lastTouchTime = elapsedTime;
            handCount++;
            int    flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 2; ifInput(ret);


            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow) && !trigger && 1 != beforeDirection && !isPaused)
        {
            lastTouchTime = elapsedTime;
            handCount++;
            int    flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 1; ifInput(ret);

            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) && !trigger && 3 != beforeDirection && !isPaused)
        {
            lastTouchTime = elapsedTime;
            handCount++;
            int    flagnum = int.Parse(GameObject.Find("flagNum").GetComponent <Text>().text);
            string sub;
            handCountSeperate(handCount, flagnum);

            GameObject.Find("handNum").GetComponent <Text>().text = handCount.ToString();
            ret = beforeDirection = 3; ifInput(ret);

            moveAnimUp.transform.rotation   = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            moveAnimDown.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 90.0f));
            //moveAnimDown.GetComponent<Image>().color = randColor();
            //moveAnimUp.GetComponent<Image>().color = randColor();
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(ret);
        this.acc = Input.acceleration;
        //画面の対角線を境にして重力による加速度のベクトルで判断
        float ru = Mathf.Atan2(1.0f, 1.0f);         //Mathf.Atan2(Screen.height / 2.0f, Screen.width / 2.0f);
        float lu = Mathf.Atan2(1.0f, -1.0f);        //Mathf.Atan2(Screen.height / 2.0f, -Screen.width / 2.0f);
        float ld = Mathf.Atan2(-1.0f, -1.0f);       //Mathf.Atan2(-Screen.height / 2.0f, -Screen.width / 2.0f);
        float rd = Mathf.Atan2(-1.0f, 1.0f);        //Mathf.Atan2(-Screen.height / 2.0f, Screen.width / 2.0f);

        float d = Mathf.Atan2(acc.y, acc.x);

        if (!Config.ctrlCfg)
        {
            ret = 3;
            if (rd <= d && d < ru)
            {
                ret = 1;
            }
            else if (ru <= d && d < lu)
            {
                ret = 2;
            }
            else if (ld <= d && d < 0)
            {
                ret = 0;
            }
        }
        else
        {
            //Debug.Log(touchScript);
            if (0 < touchScript.GetTouch())
            {
                lastTouch = touchScript.GetTouch();
            }
            //Debug.Log (lastTouch);
            if (lastTouch == 4)
            {
                ret = 0;
            }                                       //もし、下向きなら!
            if (lastTouch == 1)
            {
                ret = 1;
            }                                        //右!
            if (lastTouch == 3)
            {
                ret = 2;
            }                                         //上!!
            if (lastTouch == 2)
            {
                ret = 3;
            }                                        //左!!
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            ret = 0;
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            ret = 2;
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            ret = 1;
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            ret = 3;
        }
    }