Ejemplo n.º 1
0
    //void OnGUI()
    //{
    //    if (GUI.Button(new Rect(100, 100, 300, 100), "qte"))
    //    {
    //        StartQte(this.QTEInputCallback);
    //    }
    //}


    public void StartQte(QteInputResult qir)
    {
        //if (qteFlag)
        //    return;
        //else
        //    qteFlag = true;
        AllowMove = false;
        StartCoroutine(this.OnQTE(qir));
    }
Ejemplo n.º 2
0
    IEnumerator OnQTE(QteInputResult qir)
    {
        Time.timeScale = 0.1f;
        float inputtime   = 0.2f;
        float sumtime     = 0;
        bool  qteinputok  = false;
        float inputMaxDis = Screen.height / 5;

        Vector2 touchPos = Vector2.zero;

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                touchPos = Input.GetTouch(0).position;
            }
            else
            {
                touchPos = Vector2.zero;
            }
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            if (Input.GetMouseButton(0))
            {
                touchPos = Input.mousePosition;
            }
            else
            {
                touchPos = Vector2.zero;
            }
        }
        //MainUI.Instance.QteArrowShow ();//原开界面
        //start ui notice

        while (sumtime < inputtime)
        {
            sumtime += Time.deltaTime;

            if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
            {
                if (Input.touchCount > 0)
                {
                    if (Input.GetTouch(0).phase == TouchPhase.Began)
                    {
                        touchPos = Input.GetTouch(0).position;
                    }
                    else if (Input.GetTouch(0).phase == TouchPhase.Moved)
                    {
                        if ((Input.GetTouch(0).position.y - touchPos.y) > inputMaxDis)
                        {
                            qteinputok = true;
                            sumtime    = inputtime;
                            //MainUI.Instance.QteArrowHide();//原开界面
                            //on qte ok: stop ui notice
                            ////////////////
                        }
                    }
                }
            }
            else if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    touchPos = Input.mousePosition;
                }
                else if (Input.GetMouseButton(0))
                {
                    if ((Input.mousePosition.y - touchPos.y) > inputMaxDis)
                    {
                        qteinputok = true;
                        sumtime    = inputtime;
                        //MainUI.Instance.QteArrowHide();//原开界面
                        //on qte ok: stop ui notice
                        ////////////////
                    }
                }
            }

            yield return(null);
        }



        if (!qteinputok)
        {
            //MainUI.Instance.QteArrowHide();//原开界面
            //on qte fail: stop ui notice
            ////////////////////////////////
            Time.timeScale = 1f;
            AllowMove      = true;
            qir(false);
        }
        else
        {
            float moveUpTime       = 0.4f;
            float moveDownTime     = 0.6f;
            float moveUpSpeed      = 150f;
            float moveUpSumTime    = 0f;
            float moveUpAccSpeed   = 375f;
            float moveDownAccSpeed = 166.7f;
            float frameDeltaPos    = 0f;

            Vector3 moveUpTargetPos = cm.transform.position - new Vector3(0, 10, 0);
            Vector3 movetot         = (moveUpTargetPos - trDragon.position).normalized;
            Vector3 movetos         = (trDragon.position - moveUpTargetPos).normalized;

            Time.timeScale = 0.6f;
            while (moveUpSumTime < moveUpTime)
            {
                moveUpSumTime     += Time.deltaTime;
                frameDeltaPos      = moveUpSpeed * Time.deltaTime;
                moveUpSpeed       -= Time.deltaTime * moveUpAccSpeed;
                trDragon.position += movetot * frameDeltaPos;
                yield return(null);
            }

            moveUpSumTime = 0;
            while (moveUpSumTime < moveDownTime)
            {
                moveUpSumTime     += Time.deltaTime;
                frameDeltaPos      = moveUpSpeed * Time.deltaTime;
                moveUpSpeed       += Time.deltaTime * moveDownAccSpeed;
                trDragon.position += movetos * frameDeltaPos;
                yield return(null);
            }
            trDragon.localPosition = new Vector3(0, 0, 0);
            Time.timeScale         = 1f;
            AllowMove = true;
            qir(true);
        }
        //qteFlag = false;
    }