Exemplo n.º 1
0
        private IEnumerator TinAction(LikeOrNope lNState, bool isButtonAnimation = false, bool isSuperLikePop = false)
        {
            if (_controlObject != null && _tinMax >= _tinCounter && _isEventPopUp == false)
            {
                _controlObject.GetComponent <BoxCollider2D> ().enabled = false;

                // ボタン操作の動き
                if (isButtonAnimation == true)
                {
                    if (lNState == LikeOrNope.Nope)
                    {
                        _nope.SetActive(true);

                        if (_controlObject != null)
                        {
                            _controlObject.GetComponent <uTweenRotation> ().to      = new Vector3(0, 0, 90f);
                            _controlObject.GetComponent <uTweenRotation> ().enabled = true;
                            _controlObject.GetComponent <RectTransform> ().pivot    = Vector2.zero;

                            while (_controlObject.GetComponent <RectTransform> ().localEulerAngles.z < 90)
                            {
                                if (_controlObject == null)
                                {
                                    yield break;
                                }

                                yield return(_controlObject.GetComponent <RectTransform> ().localEulerAngles.z >= 90);
                            }
                        }
                    }
                    else if (lNState == LikeOrNope.Like)
                    {
                        _like.SetActive(true);
                        if (_tinCounter < _usersCache.Count)
                        {
                            yield return(StartCoroutine(CallSetUserLike(_usersCache [_tinCounter - 1].id, "0")));
                        }


                        if (_controlObject != null)
                        {
                            _controlObject.GetComponent <uTweenRotation> ().to      = new Vector3(0, 0, -90f);
                            _controlObject.GetComponent <uTweenRotation> ().enabled = true;

                            /*
                             * while (_controlObject.GetComponent<RectTransform> ().localEulerAngles.z > -90)
                             * {
                             *      if (_controlObject == null)
                             *      {
                             *              yield break;
                             *      }
                             *      yield return (_controlObject.GetComponent<RectTransform> ().localEulerAngles.z <= -90);
                             * }
                             */
                        }
                    }
                    else if (lNState == LikeOrNope.SuperLike)
                    {
                        _superLike.SetActive(true);
                        if (isSuperLikePop == false)
                        {
                            if (LocalFileHandler.GetBool(LocalFileConstants.FIRST_SUPER_LIKE) == false)
                            {
                                MatchingEventManager.Instance.PopUpPanelOpen(_panelPopupSuperLikeLimit.gameObject);
                                //LocalFileHandler.SetBool (LocalFileConstants.FIRST_SUPER_LIKE, true);
                                yield break;
                            }
                        }
                        else
                        {
                            LocalFileHandler.SetBool(LocalFileConstants.FIRST_SUPER_LIKE, false);
                            if (_controlObject != null)
                            {
                                _controlObject.GetComponent <BoxCollider2D> ().enabled = true;
                            }
                        }

                        if (_tinCounter < _usersCache.Count)
                        {
                            //pt 減算通知用リクエスト
                            yield return(StartCoroutine(CallSetUserLike(_usersCache [_tinCounter - 1].id, "1")));
                        }

                        if (_controlObject != null)
                        {
                            _controlObject.GetComponent <uTweenRotation> ().to      = new Vector3(0, 90, 90f);
                            _controlObject.GetComponent <uTweenRotation> ().enabled = true;

                            while (_controlObject.GetComponent <RectTransform> ().localEulerAngles.z < 40)
                            {
                                if (_controlObject == null)
                                {
                                    yield break;
                                }
                                yield return(_controlObject.GetComponent <RectTransform> ().localEulerAngles.z >= 40);
                            }
                        }
                    }
                    else if (lNState == LikeOrNope.Back)
                    {
                        if (_controlObject != null)
                        {
                            _controlObject.GetComponent <uTweenRotation> ().to      = new Vector3(0, 0, 90f);
                            _controlObject.GetComponent <uTweenRotation> ().enabled = true;
                            _controlObject.GetComponent <RectTransform> ().pivot    = Vector2.zero;

                            while (_controlObject.GetComponent <RectTransform> ().localEulerAngles.z < 90)
                            {
                                if (_controlObject == null)
                                {
                                    yield break;
                                }
                                yield return(_controlObject.GetComponent <RectTransform> ().localEulerAngles.z >= 90);
                            }
                        }
                    }
                }

                Debug.Log(" ボタンアニメーション以外。 ここから");

                // タップ操作で引っ張ってからの続き
                if (lNState == LikeOrNope.Nope)
                {
                    if (isButtonAnimation)
                    {
                        _controlObject.GetComponent <uTweenPosition> ().from    = _controlObject.transform.localPosition;
                        _controlObject.GetComponent <uTweenPosition> ().to      = new Vector3(-750f, 0f, 0f);
                        _controlObject.GetComponent <uTweenPosition> ().enabled = true;
                    }
                    else
                    {
                        while (_controlObject.transform.localPosition.x >= -375)
                        {
                            if (_controlObject == null)
                            {
                                yield break;
                            }

                            Vector3 pos = _controlObject.transform.localPosition;
                            pos.x += _releaseDirection.x;
                            pos.y += _releaseDirection.y;
                            _controlObject.transform.localPosition = pos;

                            yield return(_controlObject.transform.localPosition.x >= -750);
                        }
                    }

                    if (_controlObject != null)
                    {
                        Destroy(_controlObject);
                        while (_controlObject != null)
                        {
                            yield return(_controlObject == null);
                        }
                    }
                }
                else if (lNState == LikeOrNope.Like)
                {
                    if (isButtonAnimation == false)
                    {
                        yield return(StartCoroutine(CallSetUserLike(_usersCache [_tinCounter - 1].id, "0")));
                    }

                    if (isButtonAnimation)
                    {
                        _controlObject.GetComponent <uTweenPosition> ().from    = _controlObject.transform.localPosition;
                        _controlObject.GetComponent <uTweenPosition> ().to      = new Vector3(750f, 0f, 0f);
                        _controlObject.GetComponent <uTweenPosition> ().enabled = true;

                        while (_controlObject.transform.localPosition.x < 375)
                        {
                            if (_controlObject == null)
                            {
                                yield break;
                            }

                            yield return(_controlObject.transform.localPosition.x >= 375);
                        }
                    }
                    else
                    {
                        while (_controlObject.transform.localPosition.x <= 375)
                        {
                            if (_controlObject == null)
                            {
                                yield break;
                            }

                            Vector3 pos = _controlObject.transform.localPosition;
                            pos.x += _releaseDirection.x;
                            pos.y += _releaseDirection.y;
                            _controlObject.transform.localPosition = pos;

                            yield return(_controlObject.transform.localPosition.x >= 375);
                        }
                    }

                    if (_controlObject != null)
                    {
                        Destroy(_controlObject);
                        while (_controlObject != null)
                        {
                            yield return(_controlObject == null);
                        }
                    }
                }
                else if (lNState == LikeOrNope.SuperLike)
                {
                    if (isSuperLikePop == false)
                    {
                        if (LocalFileHandler.GetBool(LocalFileConstants.FIRST_SUPER_LIKE) == false)
                        {
                            MatchingEventManager.Instance.PopUpPanelOpen(_panelPopupSuperLikeLimit.gameObject);
                            //LocalFileHandler.SetBool (LocalFileConstants.FIRST_SUPER_LIKE, true);
                            yield break;
                        }
                    }
                    else
                    {
                        LocalFileHandler.SetBool(LocalFileConstants.FIRST_SUPER_LIKE, false);

                        if (_controlObject != null)
                        {
                            _controlObject.GetComponent <BoxCollider2D> ().enabled = true;
                        }
                    }

                    if (isButtonAnimation == false && _tinMax > _tinCounter)
                    {
                        if (_tinMax == _tinCounter)
                        {
                            Debug.Log("スーパーいいね前の、_tinCounterの減算している。");
                            _tinCounter--;
                        }

                        Debug.Log(_usersCache [_tinCounter].id + " < スーパーいいねした時のユーザーのID、確認用 tincounter:" + _tinCounter);
                        yield return(StartCoroutine(CallSetUserLike(_usersCache [_tinCounter - 1].id, "1")));
                    }

                    if (isButtonAnimation)
                    {
                        _controlObject.GetComponent <uTweenPosition> ().from    = _controlObject.transform.localPosition;
                        _controlObject.GetComponent <uTweenPosition> ().to      = new Vector3(0f, 1000f, 0f);
                        _controlObject.GetComponent <uTweenPosition> ().enabled = true;
                    }
                    else
                    {
                        while (_controlObject.transform.localPosition.y <= 500)
                        {
                            if (_controlObject == null)
                            {
                                yield break;
                            }

                            Vector3 pos = _controlObject.transform.localPosition;
                            pos.x += _releaseDirection.x;
                            pos.y += _releaseDirection.y;
                            _controlObject.transform.localPosition = pos;

                            yield return(_controlObject.transform.localPosition.y >= 500);
                        }
                    }

                    if (_controlObject != null)
                    {
                        Destroy(_controlObject);
                        while (_controlObject != null)
                        {
                            yield return(_controlObject == null);
                        }
                    }
                }
                else if (lNState == LikeOrNope.Back)
                {
                    if (isButtonAnimation)
                    {
                        _controlObject.GetComponent <uTweenPosition> ().from    = _controlObject.transform.localPosition;
                        _controlObject.GetComponent <uTweenPosition> ().to      = new Vector3(-750f, 0f, 0f);
                        _controlObject.GetComponent <uTweenPosition> ().enabled = true;
                    }
                    else
                    {
                        while (_controlObject.transform.localPosition.x >= -375)
                        {
                            if (_controlObject == null)
                            {
                                yield break;
                            }
                            yield return(_controlObject.transform.localPosition.x >= -375);
                        }
                    }

                    if (_controlObject != null)
                    {
                        Destroy(_controlObject);
                        while (_controlObject != null)
                        {
                            yield return(_controlObject == null);
                        }
                    }
                }
                else if (lNState == LikeOrNope.None)
                {
                    if (_controlObject == null)
                    {
                        //yield break;
                    }

                    // 少しだけビヨンビヨンする
                    float length = BASEPOSITION_ADJUST;
                    _controlObject.transform.rotation = Quaternion.identity;
                    while (length > 1)
                    {
                        Vector2 nowpos, basepos;
                        nowpos.x  = _controlObject.transform.localPosition.x;
                        nowpos.y  = _controlObject.transform.localPosition.y;
                        basepos.x = _baseControlObjectPosition.x;
                        basepos.y = _baseControlObjectPosition.y + BASEPOSITION_ADJUST;
                        Vector2 lengthvector = basepos - nowpos;
                        length        = lengthvector.magnitude;
                        lengthvector *= 0.5f;

                        Vector3 pos = _controlObject.transform.localPosition;
                        pos.x += lengthvector.x;
                        pos.y += lengthvector.y;
                        _controlObject.transform.localPosition = pos;

                        yield return(length < 1);
                    }

                    _tapReleasePosition = Vector2.zero;
                    _nowPosition        = Vector2.zero;
                    _springDirection    = Vector2.zero;
                    _isTin = true;

                    _controlObject.GetComponent <RectTransform> ().anchoredPosition = Vector2.zero;
                    _controlObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
                    _controlObject.GetComponent <BoxCollider2D> ().enabled = true;
                    yield break;
                }


                if (_tinCounter < _tinMax)
                {
                    _backloadCount++;
                    _tinCounter++;
                }

                if (_tinCounter == _tinMax)
                {
                    string alertTin = LocalMsgConst.ALERT_TINDER;
                    PopupPanel.Instance.PopMessageInsert(
                        alertTin,
                        LocalMsgConst.OK,
                        AlertOK
                        );

                    MatchingEventManager.Instance.PanelPopupAnimate(PopupPanel.Instance.gameObject);
                    yield break;
                }

                if (_tinCounter < _tinMax)
                {
                    // 下に控える画像の読み込み
                    GameObject go = Instantiate(Resources.Load(CommonConstants.TINDER_PANEL)) as GameObject;
                    go.GetComponent <TinderImage> ().Init(_usersCache[_tinCounter]);
                    go.transform.SetParent(_imageParent.transform, false);
                    _controlObject = _nextControlObject;

                    _nextControlObject = go;
                    SetObj(_controlObject);

                    _nextControlObject.GetComponent <BoxCollider2D> ().enabled = false;
                    _controlObject.GetComponent <BoxCollider2D> ().enabled     = true;
                }
                else
                {
                    _controlObject = _nextControlObject;

                    if (_controlObject != null)
                    {
                        SetObj(_controlObject);
                        _controlObject.GetComponent <BoxCollider2D> ().enabled = true;
                    }
                }

                // 描画順から一番したに持って行きたいから
                if (_controlObject != null)
                {
                    _controlObject.transform.SetAsLastSibling();
                }

                _tapReleasePosition = Vector2.zero;
                _nowPosition        = Vector2.zero;
                _springDirection    = Vector2.zero;
                _isTin = true;

                //追加がある場合
                if (lNState != LikeOrNope.Back)
                {
                    if (_tinCounter == _tinMax - 5)
                    {
                        int nPage = int.Parse(_nowPage) + 1;
                        _nowPage = nPage.ToString();
                        yield return(StartCoroutine(AddCacheData(nPage.ToString())));

                        yield break;
                    }
                }
            }
            else
            {
                Debug.Log("ここ異常系");
            }

            yield break;
        }
Exemplo n.º 2
0
        void FixedUpdate()
        {
            // ダイアログ開いているときはジェスチャー無効にしたい
            if (_loadingOverLay.activeSelf || _panelPopupLikeLimit.transform.localScale.x > 0 || _panelPopupSuperLikeLimit.transform.localScale.x > 0)
            {
                MatchingEventManager.Instance.SetFingerGestureEnable(false);
            }
            else
            {
                MatchingEventManager.Instance.SetFingerGestureEnable(true);
            }

            //アニメーションの慣性の処理。
            _springFrequency += 0.14f;
            _time            -= 0.06f;


            // ドラッグ中の状態表示
            if (_controlObject != null && _like != null && _nope != null && _superLike != null && _isGesture == true && _isEventPopUp == false)
            {
                if (_nowPosition.y > 220f)
                {
                    LNState = LikeOrNope.SuperLike;
                    _like.SetActive(false);
                    _nope.SetActive(false);
                    _superLike.SetActive(true);
                }
                else if (_nowPosition.x < 0 && _controlObject != null)
                {
                    //_controlObject.transform.localRotation = Quaternion.Euler (new Vector3(0,0, -3.5f));
                    LNState = LikeOrNope.Nope;
                    _like.SetActive(false);
                    _nope.SetActive(true);
                    _superLike.SetActive(false);
                }
                else if (_nowPosition.x > 0 && _controlObject != null)
                {
                    //_controlObject.transform.localRotation = Quaternion.Euler (new Vector3(0,0, 3.5f));
                    LNState = LikeOrNope.Like;
                    _nope.SetActive(false);
                    _like.SetActive(true);
                    _superLike.SetActive(false);
                }

                if (_isTin == true || LNState != LikeOrNope.None && LNState != LikeOrNope.SuperLike && (_nowPosition.x < 60 && _nowPosition.x > -60))
                {
                    LNState = LikeOrNope.None;
                    _nope.SetActive(false);
                    _like.SetActive(false);
                    _superLike.SetActive(false);

                    /*
                     *          _controlObject.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
                     *          _controlObject.transform.localRotation = Quaternion.Euler (Vector3.zero);
                     */
                    if (_isTin == true)
                    {
                        //_controlObject.transform.localPosition = _cacheTransform;
                        _isTin = false;
                    }
                }
            }
        }