Пример #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 enter()
 {
     mTuple = parent.getElement(MyTouchInput.getTouch(parent.mCamera)[0].position);
     if (mTuple == null)//要素がない部分をタップした
     {
         parent.changeState(new MyScrollViewDragScrollState(parent));
         return;
     }
     mTuple.element.push();
 }
Пример #4
0
    //要素の表示更新
    private void updateElement()
    {
        List <int> tDisplayIndex  = getDisplayIndex();
        int        tFirstIndex    = tDisplayIndex.First <int>();
        int        tLastIndex     = tDisplayIndex.Last <int>();
        int        tListTopIndex  = mElements.First <ElementTuple>().index;
        int        tListTailIndex = mElements.Last <ElementTuple>().index;

        //先頭側修正
        if (tFirstIndex <= tListTopIndex)//先頭追加
        {
            for (int i = tListTopIndex - 1; tFirstIndex <= i; i--)
            {
                createElement(i);
            }
        }
        else  //先頭削除
        {
            while (true)
            {
                if (mElements.Count == 0)
                {
                    break;
                }
                ElementTuple tTuple = mElements.First <ElementTuple>();
                if (tFirstIndex <= tTuple.index)
                {
                    break;
                }
                mElements.Remove(tTuple);
                tTuple.element.delete();
            }
        }
        //末尾側修正
        if (tListTailIndex <= tLastIndex)//末尾追加
        {
            for (int i = Math.Max(tListTailIndex + 1, tFirstIndex); i <= tLastIndex; i++)
            {
                createElement(i);
            }
        }
        else  //末尾削除
        {
            while (true)
            {
                ElementTuple tTuple = mElements.Last <ElementTuple>();
                if (tTuple.index <= tLastIndex)
                {
                    break;
                }
                mElements.Remove(tTuple);
                tTuple.element.delete();
            }
        }
    }
 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;
     }
 }
Пример #6
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();
 }
Пример #7
0
    //要素を生成
    private ElementTuple createElement(int aIndex)
    {
        if (aIndex < topElementIndex)
        {
            return(null);
        }
        if (tailElementIndex < aIndex)
        {
            return(null);
        }
        int?tNum = indexToNum(aIndex);

        if (tNum == null)
        {
            return(null);
        }
        int tElementNum = (int)tNum;
        //要素生成
        ElementTuple tTuple = new ElementTuple(aIndex, tElementNum, mDataList.createElement(tElementNum));

        tTuple.element.name = "myScrollViewElement " + aIndex.ToString();
        //シーンに追加
        tTuple.element.transform.parent = mContent.transform;
        tTuple.element.transform.SetParent(mContent.transform, false);
        tTuple.element.position = calculateElementPosition(aIndex);
        //リストの先頭か末尾に追加
        if (mElements.Count == 0)
        {
            mElements.Add(tTuple);
        }
        else if (tTuple.index < mElements.First <ElementTuple>().index)
        {
            mElements.Insert(0, tTuple);
        }
        else
        {
            mElements.Add(tTuple);
        }

        return(tTuple);
    }
        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;
            }
        }
Пример #9
0
    //要素を並び替える(データの順番のみで表示はそのまま)
    private void sortElement(int aIndex1, int aIndex2, out ElementTuple oNewTupleOfIndex1, out ElementTuple oNewTupleOfIndex2)
    {
        int tIndexOfElements1 = -1;
        int tIndexOfElements2 = -1;

        for (int i = 0; i < mElements.Count; i++)
        {
            ElementTuple tTuple = mElements[i];
            if (tTuple.index == aIndex1)
            {
                tIndexOfElements1 = i;
                continue;
            }
            if (tTuple.index == aIndex2)
            {
                tIndexOfElements2 = i;
                continue;
            }
        }
        if (tIndexOfElements1 < 0 || tIndexOfElements2 < 0)//並び替える要素が見つからなかった
        {
            oNewTupleOfIndex1 = null;
            oNewTupleOfIndex2 = null;
            return;
        }
        //並び替え
        mDataList.sort(aIndex1, aIndex2);
        ElementTuple tTuple1 = mElements[tIndexOfElements1];
        ElementTuple tTuple2 = mElements[tIndexOfElements2];

        mElements[tIndexOfElements1] = new ElementTuple(tTuple1.index, tTuple1.elementNumber, tTuple2.element);
        mElements[tIndexOfElements2] = new ElementTuple(tTuple2.index, tTuple2.elementNumber, tTuple1.element);
        oNewTupleOfIndex1            = mElements[tIndexOfElements2];
        oNewTupleOfIndex2            = mElements[tIndexOfElements1];
        return;
    }
Пример #10
0
 //要素を正しい位置へ移動
 private void moveToCorrectPosition(ElementTuple aTuple)
 {
     aTuple.element.moveBy(calculateElementPosition(aTuple.index) - aTuple.element.position, 0.1f);
 }