Ejemplo n.º 1
0
 protected override void ChangeTouchStatusCanceledPlatformPc(TouchInfo.TouchStatus beforeStatus)
 {
     dragBefore1FramePosition = dragCurrentPosition;
     base.ChangeTouchStatusCanceledPlatformPc(beforeStatus);
     dragEndPosition     = touchInfo[kCurrentFrame].position;
     dragCurrentPosition = touchInfo[kCurrentFrame].position;
 }
Ejemplo n.º 2
0
 protected override void ChangeTouchStatusBeganPlatformPc(TouchInfo.TouchStatus beforeStatus)
 {
     base.ChangeTouchStatusBeganPlatformPc(beforeStatus);
     dragStartPosition        = touchInfo[kCurrentFrame].position;
     dragCurrentPosition      = touchInfo[kCurrentFrame].position;
     dragBefore1FramePosition = touchInfo[kCurrentFrame].position;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// ドラッグ中かどうか
 /// </summary>
 /// <returns>ドラッグ中ならtrue</returns>
 bool ISingleTouchDragActionable.IsDragging()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchDragActionPc::IsDragging touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchDragActionPc::IsDragging touchInfo[kCurrentFrame] null");
     TouchInfo.TouchStatus status = touchInfo[kCurrentFrame].status;
     if ((status == TouchInfo.TouchStatus.kBegan) || (status == TouchInfo.TouchStatus.kMoved) || (status == TouchInfo.TouchStatus.kStationary))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
    /// <summary>
    /// システムから取得した情報から現在の情報を設定
    /// </summary>
    protected virtual void SetTouchInfoPc()
    {
        MhCommon.Assert(touchInfo != null, "SingleTouchActionBase::SetTouchInfoPc touchInfo null");
        MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionBase::SetTouchInfoPc touchInfo[kCurrentFrame] null");
        MhCommon.Assert(touchInfo[kBefore1Frame] != null, "SingleTouchActionBase::SetTouchInfoPc touchInfo[kBefore1Frame] null");

        // 前の状態を保存
        touchInfo[kBefore1Frame].Copy(touchInfo[kCurrentFrame]);

        TouchInfo.TouchStatus status       = touchInfo[kCurrentFrame].status;
        TouchInfo.TouchStatus beforeStatus = touchInfo[kBefore1Frame].status;
        switch (status)
        {
        case TouchInfo.TouchStatus.kNone:
            // 押したりしていない状態で押されたらBeganへ移行
            if (Input.GetMouseButtonDown(0) == true)
            {
                touchInfo[kCurrentFrame].touchId  = 0;
                touchInfo[kCurrentFrame].position = Input.mousePosition;
                touchInfo[kCurrentFrame].status   = TouchInfo.TouchStatus.kBegan;
                ChangeTouchStatusBeganPlatformPc(beforeStatus);
                OnTouchStatusBeganPlatformPc();
            }
            else
            {
                // デフォルト
                touchInfo[kCurrentFrame].Clear();
                OnTouchStatusNonePlatformPc();
            }
            break;

        case TouchInfo.TouchStatus.kBegan:
            // 位置を設定
            touchInfo[kCurrentFrame].position = Input.mousePosition;
            if (Input.GetMouseButton(0) == true)
            {
                if (touchInfo[kCurrentFrame].IsPositionEquals(touchInfo[kBefore1Frame]) == true)
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kStationary;
                    ChangeTouchStatusStationaryPlatformPc(beforeStatus);
                    OnTouchStatusStationaryPlatformPc();
                }
                else
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kMoved;
                    ChangeTouchStatusMovedPlatformPc(beforeStatus);
                    OnTouchStatusMovedPlatformPc();
                }
            }
            else
            {
                // 持ち上げられたのでkEndedへ
                touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kEnded;
                ChangeTouchStatusEndedPlatformPc(beforeStatus);
                OnTouchStatusEndedPlatformPc();
            }
            break;

        case TouchInfo.TouchStatus.kMoved:
            touchInfo[kCurrentFrame].position = Input.mousePosition;
            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kEnded;
                ChangeTouchStatusEndedPlatformPc(beforeStatus);
                OnTouchStatusEndedPlatformPc();
            }
            else
            {
                // 移動してないならkStationary 移動していたらkMoved
                if (touchInfo[kCurrentFrame].IsPositionEquals(touchInfo[kBefore1Frame]) == true)
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kStationary;
                    ChangeTouchStatusStationaryPlatformPc(beforeStatus);
                    OnTouchStatusStationaryPlatformPc();
                }
                else
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kMoved;
                    //ChangeTouchStatusMovedPlatformPc(beforeStatus);
                    OnTouchStatusMovedPlatformPc();
                }
            }
            break;

        case TouchInfo.TouchStatus.kStationary:
            touchInfo[kCurrentFrame].position = Input.mousePosition;
            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kEnded;
                ChangeTouchStatusEndedPlatformPc(beforeStatus);
                OnTouchStatusEndedPlatformPc();
            }
            else
            {
                // 移動してないならkStationary 移動していたらkMoved
                if (touchInfo[kCurrentFrame].IsPositionEquals(touchInfo[kBefore1Frame]) == true)
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kStationary;
                    //ChangeTouchStatusStationaryPlatformPc(beforeStatus);
                    OnTouchStatusStationaryPlatformPc();
                }
                else
                {
                    touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kMoved;
                    ChangeTouchStatusMovedPlatformPc(beforeStatus);
                    OnTouchStatusMovedPlatformPc();
                }
            }
            break;

        case TouchInfo.TouchStatus.kEnded:
        case TouchInfo.TouchStatus.kCanceled:
            // 終わった後に押されたらkBeganへ移行
            if (Input.GetMouseButton(0) == false)
            {
                // デフォルト状態に戻す
                touchInfo[kCurrentFrame].Clear();
                ChangeTouchStatusNonePlatformPc(beforeStatus);
                OnTouchStatusNonePlatformPc();
            }
            else
            {
                // タッチIDは0固定
                touchInfo[kCurrentFrame].touchId = 0;
                // 位置
                touchInfo[kCurrentFrame].position = Input.mousePosition;
                touchInfo[kCurrentFrame].status   = TouchInfo.TouchStatus.kBegan;
                ChangeTouchStatusBeganPlatformPc(beforeStatus);
                OnTouchStatusBeganPlatformPc();
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 5
0
    protected virtual void SetTouchInfoSmartPhone()
    {
        MhCommon.Assert(touchInfo != null, "SingleTouchActionBase::SetTouchInfoSmartPhone touchInfo null");
        MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionBase::SetTouchInfoSmartPhone touchInfo[kCurrentFrame] null");
        MhCommon.Assert(touchInfo[kBefore1Frame] != null, "SingleTouchActionBase::SetTouchInfoSmartPhone touchInfo[kBefore1Frame] null");

        // 前の状態を保存
        touchInfo[kBefore1Frame].Copy(touchInfo[kCurrentFrame]);

        int id         = touchInfo[kCurrentFrame].touchId;
        int touchCount = Input.touchCount;

        TouchInfo.TouchStatus beforeStatus = touchInfo[kBefore1Frame].status;
        // 情報をリセット
        touchInfo[kCurrentFrame].Clear();

        if (touchCount <= 0)
        {
            // タッチ情報なし
            if (touchInfo[kBefore1Frame].status != TouchInfo.TouchStatus.kNone)
            {
                // タッチ情報なしに切り替わった
                ChangeTouchStatusNonePlatformSmartPhone(beforeStatus);
            }
            return;
        }

        // タッチIDが有効なので前回と同じタッチIDを探す
        if (TouchInfo.IsTouchIdInvalid(id) == false)
        {
            for (int i = 0; i < touchCount; ++i)
            {
                if (id == Input.GetTouch(i).fingerId)
                {
                    // 情報をセット
                    SetCurrentInfoByTouch(Input.GetTouch(i));
                    if (touchInfo[kBefore1Frame].status != touchInfo[kCurrentFrame].status)
                    {
                        if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kBegan)
                        {
                            ChangeTouchStatusBeganPlatformSmartPhone(beforeStatus);
                        }
                        else if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kMoved)
                        {
                            ChangeTouchStatusMovedPlatformSmartPhone(beforeStatus);
                        }
                        else if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kStationary)
                        {
                            ChangeTouchStatusStationaryPlatformSmartPhone(beforeStatus);
                        }
                        else if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kEnded)
                        {
                            ChangeTouchStatusEndedPlatformSmartPhone(beforeStatus);
                        }
                        else if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kCanceled)
                        {
                            ChangeTouchStatusCanceledPlatformSmartPhone(beforeStatus);
                        }
                    }
                    return;
                }
            }
        }
        else
        {
            // 既存のタッチがないので新規のタッチがあったら情報をセット
            // 普通はBeganになるはず
            // 逆にいきなり変なステータスになっているのを適用したら不自然と思うのでやらない
            // (特定の機種のみ異常な動作になる可能性も考慮)
            // 将来的には検証して有りにするは可能性あり
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                SetCurrentInfoByTouch(Input.GetTouch(0));
                ChangeTouchStatusBeganPlatformSmartPhone(beforeStatus);
            }
        }
    }
Ejemplo n.º 6
0
 protected virtual void ChangeTouchStatusCanceledPlatformSmartPhone(TouchInfo.TouchStatus beforeStatus)
 {
 }
Ejemplo n.º 7
0
 protected virtual void ChangeTouchStatusStationaryPlatformSmartPhone(TouchInfo.TouchStatus beforeStatus)
 {
 }
Ejemplo n.º 8
0
 protected virtual void ChangeTouchStatusEndedPlatformPc(TouchInfo.TouchStatus beforeStatus)
 {
 }
Ejemplo n.º 9
0
 protected override void ChangeTouchStatusMovedPlatformPc(TouchInfo.TouchStatus beforeStatus)
 {
     base.ChangeTouchStatusMovedPlatformPc(beforeStatus);
 }
Ejemplo n.º 10
0
    // PC系のプラットフォームにTouchInfoを設定
    private void SetTouchInfoForPC()
    {
        // 前の状態を保存
        past_touch_info_.Copy(current_info_);

        TouchInfo.TouchStatus status = current_info_.status_;
        switch (status)
        {
        case TouchInfo.TouchStatus.kNone:
            // 押したりしていない状態で押されたらBeganへ移行
            if (Input.GetMouseButtonDown(0) == true)
            {
                // タッチidは0固定
                current_info_.touch_id_ = 0;
                // 位置
                current_info_.position_ = Input.mousePosition;
                current_info_.status_   = TouchInfo.TouchStatus.kBegan;
            }
            else
            {
                // デフォルトの値
                current_info_.Clear();
            }
            break;

        case TouchInfo.TouchStatus.kBegan:
            // 位置を設定
            current_info_.position_ = Input.mousePosition;
            if (Input.GetMouseButton(0) == true)
            {
                // 押しっぱなしなのでMovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            else
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            break;

        case TouchInfo.TouchStatus.kMoved:
            current_info_.position_ = Input.mousePosition;
            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            else
            {
                // MovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            break;

        case TouchInfo.TouchStatus.kStationary:

            current_info_.position_ = Input.mousePosition;
            MhCommon.Print("x " + current_info_.position_.x + " y " + current_info_.position_.y + " z " + current_info_.position_.z);

            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            else
            {
                // MovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            break;

        case TouchInfo.TouchStatus.kEnded:
        case TouchInfo.TouchStatus.kCanceled:
            // kEndedになった瞬間に押されたらkBeganへ移行
            if (Input.GetMouseButton(0) == true)
            {
                // タッチidは0固定
                current_info_.touch_id_ = 0;
                // 位置
                current_info_.position_ = Input.mousePosition;
                current_info_.status_   = TouchInfo.TouchStatus.kBegan;
            }
            else
            {
                // デフォルト状態に戻す
                current_info_.Clear();
            }
            break;

        default:
            break;
        }
    }