Esempio n. 1
0
 void Update()
 {
     if (TouchUtil.CheckSwipe(collider, shutdownMode))
     {
         TurnOff();
     }
 }
Esempio n. 2
0
    void Update()
    {
        obj.transform.Rotate(new Vector3(0, -30 * tx / 1.2f, 0), Space.Self);
        tx /= 1.2f;

        if (TouchUtil.GetTouchPosition() != Vector3.zero)
        {
            TouchInfo info = TouchUtil.GetTouch();
            if (info == TouchInfo.Began)
            {
                sPos = TouchUtil.GetTouchPosition();
                sRot = obj.transform.rotation;
            }
            else if (info == TouchInfo.Moved)
            {
                tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid;
                ty = (TouchUtil.GetTouchPosition().y - sPos.y) / hei;

                obj.transform.rotation = sRot;
                obj.transform.Rotate(new Vector3(0, -90 * tx, 0), Space.Self);
            }
        }
        else
        {
            if (!(Mathf.Abs(tx) > 0.01f))
            {
                tx = -0.01f;
            }
        }
    }
Esempio n. 3
0
 void Update()
 {
     if (Input.touchCount > 1 && target != null)
     {
         var arr = GetTouchedFingers(Input.touches);
         if (arr.Count > 1)
         {
             if (simulator != null && simulator.isActiveAndEnabled)
             {
                 simulator.SwitchTouch(RGSimulator.TouchType.Pinch);
             }
             var dist = TouchUtil.GetScreenDistance(arr);
             CheckPinch(dist);
             if (callAction != null)
             {
                 callAction.Invoke(dist);
             }
         }
     }
     else
     {
         if (simulator != null && simulator.isActiveAndEnabled)
         {
             simulator.SwitchTouch(RGSimulator.TouchType.Empty);
         }
     }
 }
Esempio n. 4
0
    void Update()
    {
        //Revisar si la moneda fue tocada
        if (TouchUtil.CheckTouched(collider))
        {
            FindObjectOfType <PlayManager>().collectedCoins++;
            Destroy(gameObject);
        }

        rollDirection      = rollDirection.normalized;
        transform.position = transform.position + rollDirection * rollSpeed * Time.deltaTime;
    }
Esempio n. 5
0
    void Update()
    {
        //Mover la caja hasta su posicion deseada
        transform.position = Vector3.MoveTowards(transform.position, desiredPosition, speed * Time.deltaTime);

        //Si se toca la caja, subir de nivel y destruirla
        if (TouchUtil.CheckTouched(collider))
        {
            FindObjectOfType <PlayManager>().NextLevel();
            Destroy(gameObject);
        }
    }
Esempio n. 6
0
    void Update()
    {
        Vector3 touchPos = TouchUtil.GetTouchWorldPosition();

        touchPos.z = 0;
        float magnitude = (touchPos - this.transform.position).magnitude;

        if (TouchUtil.GetTouch_Bool() && magnitude < TouchRadius)
        {
            OnTouch();
        }
    }
Esempio n. 7
0
 //==============================================================================================================================================
 //タップエフェクト
 //==============================================================================================================================================
 //タップした位置にエフェクトを生成する
 private void TapEffect()
 {
     if (TouchUtil.GetTouch() == TouchUtil.TouchInfo.Began)
     {
         Camera cam = GameObject.FindGameObjectsWithTag("MainCamera")[0].GetComponent <Camera>();
         if (cam != null)
         {
             Vector3 touchPosition = TouchUtil.GetTouchWorldPosition(cam);
             CreateTapEffect(new Vector3(touchPosition.x, touchPosition.y, 0));
             //Debug.Log(TouchUtil.GetTouchWorldPosition(cam));
         }
     }
 }
Esempio n. 8
0
    //=============================================================
    private void RoutineTitle()
    {
        if (TouchUtil.GetTouch() == TouchUtil.TouchInfo.Began)
        {
            JumpSceneTitleToHome();
        }

        //タイトルが出現したら
        if (isTitleAppeared)
        {
            text_tapToStart.SetActive(true);
            text_tokyoBTeam.SetActive(true);
        }
    }
Esempio n. 9
0
    void Update()
    {
        Input.simulateMouseWithTouches = false;

        //Revisar si se está tocando la pantalla
        if (Input.touchCount > 0)
        {
            //Si el toque va empezando, guardar como posicion inicial
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                startingTouchPos = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
                Debug.Log(startingTouchPos);
            }
        }

        //Revisar si se hizo clic en la pantalla
        if (Input.GetMouseButtonDown(0))
        {
            startingTouchPos = TouchUtil.TouchOnPlane(launcherPlane);
        }

        if (Input.GetMouseButton(0))
        {
            currentTouchPos = TouchUtil.TouchOnPlane(launcherPlane);

            //Mostrar la flecha de lanzamiento
            launchArrow.SetActive(true);
            launchArrow.transform.position   = transform.position + Vector3.up * 0.05f;
            launchArrow.transform.localScale = new Vector3(1f, 1f, Mathf.Clamp((currentTouchPos - startingTouchPos).magnitude, 0f, maxForce));
            launchArrow.transform.LookAt(transform.position + currentTouchPos - startingTouchPos);
            //launchArrow.transform.localRotation = Quaternion.Euler(new Vector3(0f, launchArrow.transform.localRotation.y, launchArrow.transform.localRotation.z));
        }
        else
        {
            //Ocultar la flecha de lanzamiento
            launchArrow.SetActive(false);
        }

        //Revisar si se levantó el clic de la pantalla y patear la pelota
        if (Input.GetMouseButtonUp(0))
        {
            touchFinalDelta = TouchUtil.TouchOnPlane(launcherPlane) - startingTouchPos;
            Launch(touchFinalDelta.normalized, Mathf.Clamp(touchFinalDelta.magnitude, 0f, maxForce));
            FindObjectOfType <PlayManager>().playInProgress = true;
            this.enabled = false;
        }
    }
Esempio n. 10
0
    void Update()
    {
        if (Input.touchCount == 1 || active)
        {
            //移動
            //Touch t1 = Input.GetTouch(0);
            TouchInfo info = TouchUtil.GetTouch();
            if (info == TouchInfo.Began)
            {
                sPos = TouchUtil.GetTouchPosition();
                sRot = obj.transform.position;
            }
            else if (info == TouchInfo.Moved || info == TouchInfo.Stationary)
            {
                tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid; //横移動量(-1<tx<1)
                ty = (TouchUtil.GetTouchPosition().y - sPos.y) / hei; //縦移動量(-1<ty<1)
                obj.transform.position = sRot + new Vector3(kando * tx, kando * ty, 0);
                //obj.transform.Rotate(new Vector3(90 * ty, -90 * tx, 0), Space.World);
            }
        }

        /*
         * else if (Input.touchCount >= 2)
         * {
         *  //ピンチイン ピンチアウト
         *  Touch t1 = Input.GetTouch(0);
         *  Touch t2 = Input.GetTouch(1);
         *  if (t2.phase == TouchPhase.Began)
         *  {
         *      sDist = Vector2.Distance(t1.position, t2.position);
         *  }
         *  else if ((t1.phase == TouchPhase.Moved || t1.phase == TouchPhase.Stationary) &&
         *           (t2.phase == TouchPhase.Moved || t2.phase == TouchPhase.Stationary))
         *  {
         *      nDist = Vector2.Distance(t1.position, t2.position);
         *      v = v + (nDist - sDist) / diag;
         *      sDist = nDist;
         *      if (v > vMax) v = vMax;
         *      if (v < vMin) v = vMin;
         *      obj.transform.localScale = initScale * v;
         *  }
         * }*/
    }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        if (moveActive)
        {
            //移動
            TouchInfo info = TouchUtil.GetTouch();
            if (info == TouchInfo.Began)
            {
                sPos = TouchUtil.GetTouchPosition();
                sRot = camera.transform.position;
            }
            else if (info == TouchInfo.Moved || info == TouchInfo.Stationary)
            {
                tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid; //横移動量(-1<tx<1)
                ty = (TouchUtil.GetTouchPosition().y - sPos.y) / hei; //縦移動量(-1<ty<1)

                camera.transform.position = sRot + new Vector3(kando * tx, 0, kando * ty);
            }
        }
    }
Esempio n. 12
0
 void Update()
 {
     if (Input.touchCount == 1 || active)
     {
         //移動
         //Touch t1 = Input.GetTouch(0);
         TouchInfo info = TouchUtil.GetTouch();
         if (info == TouchInfo.Began)
         {
             sPos = TouchUtil.GetTouchPosition();
             sRot = obj.transform.position;
         }
         else if (info == TouchInfo.Moved || info == TouchInfo.Stationary)
         {
             tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid; //横移動量(-1<tx<1)
             ty = (TouchUtil.GetTouchPosition().y - sPos.y) / hei; //縦移動量(-1<ty<1)
             obj.transform.position = sRot + new Vector3(obj.transform.localScale.x * kando * kando * tx, obj.transform.localScale.x * kando * kando * ty, 0);
             //obj.transform.Rotate(new Vector3(90 * ty, -90 * tx, 0), Space.World);
         }
     }
     if (Input.touchCount >= 2)
     {
         //Debug.Log("a");
         //ピンチイン ピンチアウト
         Touch t1 = Input.GetTouch(0);
         Touch t2 = Input.GetTouch(1);
         if (t2.phase == TouchPhase.Began)
         {
             sDist = Vector2.Distance(t1.position, t2.position);
         }
         else if ((t1.phase == TouchPhase.Moved || t1.phase == TouchPhase.Stationary) &&
                  (t2.phase == TouchPhase.Moved || t2.phase == TouchPhase.Stationary))
         {
             nDist = Vector2.Distance(t1.position, t2.position);
             v     = v + (nDist - sDist) / diag;
             sDist = nDist;
             obj.transform.localScale = initScale * v * 3;
         }
     }
 }
Esempio n. 13
0
    void Update()
    {
        if (Input.touchCount == 1 || active)
        {
            //回転
            //Touch t1 = Input.GetTouch(0);
            TouchInfo info = TouchUtil.GetTouch();
            if (info == TouchInfo.Began)
            {
                sPos = TouchUtil.GetTouchPosition();
                sRot = obj.transform.rotation;
                cRot = cameraMaster.transform.rotation;
            }
            else if (info == TouchInfo.Moved || info == TouchInfo.Stationary)
            {
                tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid;
                ty = (TouchUtil.GetTouchPosition().y - sPos.y) / hei;


                obj.transform.rotation          = sRot;
                cameraMaster.transform.rotation = cRot;
                obj.transform.Rotate(new Vector3(0, -90 * tx, 0), Space.World);

                cameraMaster.transform.Rotate(new Vector3(-90 * ty, 0), Space.World);

                if ((cameraMaster.transform.localEulerAngles.x > 85) ||
                    (cameraMaster.transform.localEulerAngles.x < 5) ||
                    cameraMaster.transform.localEulerAngles.y > 90)
                {
                    cameraMaster.transform.rotation = beforeRotation;
                }

                Debug.Log(obj.transform.localEulerAngles.y);


                beforeRotation = cameraMaster.transform.rotation;
            }
        }
    }
Esempio n. 14
0
 //=============================================================
 //タッチの位置を取得する
 public static Vector3 GetTouchPosition()
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         if (Input.touchCount > 0)
         {
             Touch touch = Input.GetTouch(0);
             TouchPosition.x = touch.position.x;
             TouchPosition.y = touch.position.y;
             return(TouchPosition);
         }
     }
     else
     {
         TouchInfo touch = TouchUtil.GetTouch();
         if (touch != TouchInfo.None)
         {
             return(Input.mousePosition);
         }
     }
     return(Vector3.zero);
 }
Esempio n. 15
0
    void Update()
    {
        if (TouchUtil.GetTouch() == TouchInfo.Began)
        {
            var touchPosition = TouchUtil.GetTouchPosition();
            if (touchPosition != Vector3.zero)
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(touchPosition);
                if (Physics.Raycast(ray, out hit))
                {
                    // hit.transform.GetComponent<Renderer>().material.color = Color.red;
                    switch (hit.transform.name)
                    {
                    case "Spotify": Application.OpenURL("https://open.spotify.com/track/5HkOHdVwSVKawkkypYnZaZ?si=PDgpAfkPR0yPoqIG7Eo_XA"); break;

                    case "iTunes": Application.OpenURL("https://geo.itunes.apple.com/jp/album/reason/583843024?i=583843096&app=itunes"); break;
                    }
                }
            }
        }
    }
Esempio n. 16
0
    public void Move()
    {
        //UI選択中は動かさない
        if (TouchUtil.IsGetTouch())
        {
            return;
        }

        seq = DOTween.Sequence();
        Vector3 move = TouchUtil.GetTouchWorldPosition(Camera.main) - Camera.main.transform.position;

        //移動制限
        //move.x = Mathf.Clamp(move.x, -5.75f, 5.75f);
        seq.Append(rb2d.DOMove(move * speed, 2.0f));

        Vector3 dir = transform.position - move;

        if (Mathf.Abs(dir.x) > 0.8f) //誤差が0.8以上のときだけ移動する方向に向く
        {
            seq.Join(rb2d.DORotate(Mathf.Sign(dir.x) * 45, 0.5f));
            seq.Append(rb2d.DORotate(0, 0.5f));
        }
    }
Esempio n. 17
0
    void Update()
    {
        //移動処理
        TouchInfo touchInfo = TouchUtil.GetTouch();

        if (touchInfo == TouchInfo.Began && !PlayerStatus.Instance.IsDamage)
        {
            Move();
        }

        //弾丸処理
        if (poolController.IsCreate())
        {
            poolController.CreateObj(poolController.AttachPoint.position, poolController.AttachPoint.rotation);
            SoundController.Instance.PlaySE(PlayerSE, 2);
        }

        //死亡処理
        if (PlayerStatus.Instance.PlayerHp.Value <= 0.0f)
        {
            Death();
        }
    }
Esempio n. 18
0
    private void Update()
    {
        //画面タッチ状態ならフラグをon
        if (TouchUtil.GetTouch() == TouchUtil.TouchInfo.Moved)
        {
            isTouched = true;
        }
        else
        {
            isTouched = false;
        }

        //画面タッチの状態に応じてキャラクターやボタンの状態を変える
        if (isTouched)
        {
            //前フレームとタッチした場所の座標が違うなら
            if (beforeFrameTouchPosition != GetTouchPosition())
            {
                characterImageL.GetComponent <RectTransform>().position += new Vector3((GetTouchPosition().x - beforeFrameTouchPosition.x), 0, 0);
                characterImageC.GetComponent <RectTransform>().position += new Vector3((GetTouchPosition().x - beforeFrameTouchPosition.x), 0, 0);
                characterImageR.GetComponent <RectTransform>().position += new Vector3((GetTouchPosition().x - beforeFrameTouchPosition.x), 0, 0);

                //ボタンのアクティブを切る
                leftButton.SetActive(false);
                rightButton.SetActive(false);
            }

            easingTime = 0;
        }
        else
        {
            easingTime += Time.deltaTime * shiftLerpSpeed;

            //左に移動させるかどうかの判定
            if (!characterShiftFlagL)
            {
                if (characterImageC.GetComponent <RectTransform>().position.x <= -_camera.orthographicSize / 4)
                {
                    selectSE.PlayOneShot(selectSE.clip);
                    characterShiftFlagL = true;
                }
            }

            //左に移動させたときの動作
            if (characterShiftFlagL)
            {
                characterImageC.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageC.GetComponent <RectTransform>().localPosition,
                    iniPos[0],
                    easingTime
                    );

                characterImageR.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageR.GetComponent <RectTransform>().localPosition,
                    iniPos[1],
                    easingTime
                    );

                //一定時間が経過したら
                if (easingTime >= 1)
                {
                    easingTime          = 0;
                    characterShiftFlagL = false;

                    //フォーカスするキャラクターのシフト
                    ShiftFocusCharacter(1);
                    //位置の初期化
                    characterImageL.GetComponent <RectTransform>().localPosition = iniPos[0];
                    characterImageC.GetComponent <RectTransform>().localPosition = iniPos[1];
                    characterImageR.GetComponent <RectTransform>().localPosition = iniPos[2];
                }
            }

            //右に移動させるかどうかの判定
            if (!characterShiftFlagR)
            {
                if (characterImageC.GetComponent <RectTransform>().position.x >= _camera.orthographicSize / 4)
                {
                    selectSE.PlayOneShot(selectSE.clip);
                    characterShiftFlagR = true;
                }
            }

            //右に移動させたときの動作
            if (characterShiftFlagR)
            {
                characterImageC.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageC.GetComponent <RectTransform>().localPosition,
                    iniPos[2],
                    easingTime
                    );

                characterImageL.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageL.GetComponent <RectTransform>().localPosition,
                    iniPos[1],
                    easingTime
                    );

                //一定時間が経過したら
                if (easingTime >= 1)
                {
                    easingTime          = 0;
                    characterShiftFlagR = false;

                    //フォーカスするキャラクターのシフト
                    ShiftFocusCharacter(-1);
                    //位置の初期化
                    characterImageL.GetComponent <RectTransform>().localPosition = iniPos[0];
                    characterImageC.GetComponent <RectTransform>().localPosition = iniPos[1];
                    characterImageR.GetComponent <RectTransform>().localPosition = iniPos[2];
                }
            }

            //通常動作
            if (!(characterShiftFlagL || characterShiftFlagR))
            {
                characterImageL.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageL.GetComponent <RectTransform>().localPosition,
                    iniPos[0],
                    easingTime
                    );

                characterImageC.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageC.GetComponent <RectTransform>().localPosition,
                    iniPos[1],
                    easingTime
                    );

                characterImageR.GetComponent <RectTransform>().localPosition = Vector3.Lerp(
                    characterImageR.GetComponent <RectTransform>().localPosition,
                    iniPos[2],
                    easingTime
                    );

                //ボタンのアクティブ化
                leftButton.SetActive(true);
                rightButton.SetActive(true);
            }
        }

        beforeFrameTouchPosition = GetTouchPosition();
    }
Esempio n. 19
0
 void Start()
 {
     s_instance = this;
 }
Esempio n. 20
0
 //=============================================================
 //現在のタッチしたポジションを取得する
 private Vector3 GetTouchPosition()
 {
     return(TouchUtil.GetTouchWorldPosition(_camera));
 }
Esempio n. 21
0
    // Update is called once per frame
    void Update()
    {
        if (TouchUtil.GetTouch() != TouchInfo.None)
        {
            //回転
            TouchInfo info = TouchUtil.GetTouch();
            if (info == TouchInfo.Began)
            {
                sPos = TouchUtil.GetTouchPosition();
                sRot = obj.transform.rotation;
            }
            else if (info == TouchInfo.Moved)
            {
                tx = (TouchUtil.GetTouchPosition().x - sPos.x) / wid;

                if (sPos.x < 30)
                {
                    //Debug.Log(tx);
                    float buf = wid * 2 * tx;
                    if (buf > 900f)
                    {
                        buf = 900f;
                    }
                    obj.transform.localPosition = deffalt + new Vector3(buf, 0, 0);
                    if (wid * 2 * tx > 100)
                    {
                        enable = true;
                    }
                }
            }
        }
        else
        {
            if (lastSwitch != enable)
            {
                if (enable == false)
                {
                    if (transform.localPosition.x > deffalt.x)
                    {
                        transform.localPosition = new Vector3(transform.localPosition.x - 2500f * Time.deltaTime, 0f, 0f);
                    }
                    else
                    {
                        transform.localPosition = new Vector3(deffalt.x, 0f, 0f);
                        lastSwitch = enable;
                    }
                    back.gameObject.SetActive(false);
                }
                else
                {
                    if (transform.localPosition.x < deffalt.x + 800f)
                    {
                        transform.localPosition = new Vector3(transform.localPosition.x + 2500f * Time.deltaTime, 0f, 0f);
                    }
                    else
                    {
                        transform.localPosition = new Vector3(deffalt.x + 900f, 0f, 0f);
                        lastSwitch = enable;
                    }
                    back.gameObject.SetActive(true);
                }
            }
        }
    }