Esempio n. 1
0
 public override void update()
 {
     MyTouchInfo[] tTouches = MyTouchInput.getTouch(parent.mCamera);
     if (tTouches.Length == 0)//タッチ操作なし
     {
         parent.changeState(new MyScrollViewWaitState(parent));
         return;
     }
     mSortingElement.element.position = parent.worldPositionToContentPosition(tTouches[0].position);
     if (tTouches[0].state == MyTouchState.stationary) //タッチ状態変化なし
     {
         return;
     }
     if (tTouches[0].state == MyTouchState.moved)//ドラッグ移動
     {
         ElementTuple tTuple = parent.getElement(tTouches[0].position);
         if (tTuple == null)
         {
             return;
         }
         if (mSortingElement.element == tTuple.element)
         {
             return;                                           //並び替え相手として自分を選択
         }
         if (!parent.mDataList.isCanSort(tTuple.elementNumber))
         {
             return;                                                   //並び替え不可の要素
         }
         //並び替える
         parent.sortElement(mSortingElement.index, tTuple.index, out mSortingElement, out tTuple);
         parent.moveToCorrectPosition(tTuple);
         return;
     }
     parent.changeState(new MyScrollViewWaitState(parent));
 }
        public override void update()
        {
            MyTouchInfo[] tTouches = MyTouchInput.getTouch(parent.mCamera);
            if (tTouches.Length == 0)//タッチ操作なし
            {
                return;
            }

            //並び替え相手選択
            if (tTouches[0].state == MyTouchState.ended)
            {
                ElementTuple tTuple = parent.getElement(tTouches[0].position);
                if (tTuple == null || tTuple.element == mSortingElement.element)//選択した要素なし or 相手として自分を選択
                {
                    endSort();
                    return;
                }
                if (!parent.mDataList.isCanSort(tTuple.elementNumber))//並び替え不可の要素
                {
                    endSort();
                    return;
                }
                //並び替え
                parent.sortElement(mSortingElement.index, tTuple.index, out mSortingElement, out tTuple);
                parent.moveToCorrectPosition(mSortingElement);
                parent.moveToCorrectPosition(tTuple);
                endSort();
            }
        }
        public override void update()
        {
            MyTouchInfo tTouch = MyTouchInput.getTouch()[0];

            if (tTouch.state == MyTouchState.moved)//ドラッグ開始
            {
                parent.changeState(new MyScrollViewDragScrollState(parent));
                return;
            }
            if (tTouch.state == MyTouchState.stationary)//長押し判定
            {
                if (!parent.mOption.sortable)
                {
                    return;                          //ソート機能offの場合はreturn
                }
                mTappingTime += Time.deltaTime;
                if (parent.mOption.longTapTime < mTappingTime)
                {
                    parent.changeState(new MyScrollViewDragSortState(parent));
                }
                return;
            }
            //タップ終了
            endTap();
        }
    //2dのシーンのオブジェクトにpushイベントを転送(転送できたらtrue)
    private bool transmissionTo2d(Camera aCamera)
    {
        MyTouchInfo[] tInfo = MyTouchInput.getTouch(aCamera);
        if (tInfo.Length == 0)
        {
            return(false);
        }
        Collider2D[] tColliders = Physics2D.OverlapPointAll(tInfo[0].position);
        if (tColliders.Length == 0)
        {
            return(false);
        }
        bool tFound = false;

        foreach (Collider2D tCollider in tColliders)
        {
            if (tFound)
            {
                transmission(tCollider.gameObject);
                return(true);
            }
            if (tCollider.gameObject == this.gameObject)
            {
                tFound = true;
            }
        }
        return(false);
    }
 public override void enter()
 {
     mTuple = parent.getElement(MyTouchInput.getTouch(parent.mCamera)[0].position);
     if (mTuple == null)//要素がない部分をタップした
     {
         parent.changeState(new MyScrollViewDragScrollState(parent));
         return;
     }
     mTuple.element.push();
 }
 public override void update()
 {
     if (MyTouchInput.getTouch()[0].state == MyTouchState.ended)//終了判定
     {
         parent.changeState(new MyScrollViewWaitState(parent));
         return;
     }
     //ドラッグスクロール
     parent.scrollByDrag();
     parent.remediateScrollPosition();
     parent.updateElement();
 }
 //ドラッグによるスクロール
 private void scrollByDrag()
 {
     MyTouchInfo[] tInfos = MyTouchInput.getTouch(mCamera);
     if (tInfos.Count() == 0)
     {
         return;
     }
     if (tInfos[0].state != MyTouchState.moved)
     {
         return;
     }
     //ドラッグ操作した時のみ適用
     scrollPositionVector += new Vector2(-tInfos[0].deltaPosition.x, tInfos[0].deltaPosition.y);
 }
 public override void enter()
 {
     mTuple = parent.getElement(MyTouchInput.getTouch(parent.mCamera)[0].position);
     if (mTuple == null)//要素がない部分をタップした
     {
         parent.changeState(new MyScrollViewWaitState(parent));
         return;
     }
     if (!parent.mOption.doubleTap) //ダブルタップ機能offならすぐに状態遷移
     {
         tappedElement();           //要素をタップした
         return;
     }
 }
Esempio n. 9
0
 public override void enter()
 {
     mSortingElement = parent.getElement(MyTouchInput.getTouch(parent.mCamera)[0].position);
     if (mSortingElement == null)//並び替える要素がない
     {
         parent.changeState(new MyScrollViewWaitState(parent));
         return;
     }
     if (!parent.mDataList.isCanSort(mSortingElement.elementNumber))//並び替え不可の要素
     {
         mSortingElement = null;
         parent.changeState(new MyScrollViewWaitState(parent));
         return;
     }
     mSortingElement.element.grab();
 }
 public override void update()
 {
     MyTouchInfo[] tTouches = MyTouchInput.getTouch(parent.mCamera);
     if (tTouches.Length == 0) //タッチ操作なし
     {
         parent.scrollByWheel();
         parent.remediateScrollPosition();
         parent.updateElement();
         return;
     }
     //タッチ操作開始
     if (tTouches[0].state != MyTouchState.begin)
     {
         return;
     }
     if (!parent.targeting(tTouches[0].position))
     {
         return;
     }
     parent.changeState(new MyScrollViewLongTapState(parent));
 }
        public override void update()
        {
            MyTouchInfo[] tTouches = MyTouchInput.getTouch(parent.mCamera);
            if (tTouches.Length == 0) //タッチ操作なし
            {
                mAloneTime += Time.deltaTime;
                if (parent.mOption.doubleTapTime < mAloneTime) //ダブルタップ判定終了
                {
                    tappedElement();                           //要素をタップした
                    return;
                }
                base.update();
                return;
            }
            //ダブルタップ判定
            if (tTouches[0].state != MyTouchState.begin)
            {
                return;
            }
            if (!parent.targeting(tTouches[0].position))
            {
                return;
            }
            ElementTuple tTuple = parent.getElement(tTouches[0].position);

            if (mTuple.index == tTuple.index)
            {
                //1回目と2回目で同じ要素をタップ
                parent.changeState(new MyScrollViewSecondLongTapState(parent));
                return;
            }
            else
            {
                //1回目と2回目で違う要素をタップ
                parent.changeState(new MyScrollViewImmediatelyAfterClickingState(parent));
                return;
            }
        }