Esempio n. 1
0
    public void OnEndDrag(PointerEventData e)
    {
        flgDrag = false;
        Object.Destroy(sd);
        sd = null;
        Object.Destroy(ol);
        ol = null;

        int pageoffset = 0;

        if (minReceiveParentNum > 23)
        {
            pageoffset = 0;
        }
        else
        {
            pageoffset = GameManager.currentPage;                               // 何ページ目かを計算する  page0:0~7    page1:8~15   page2:16~23
        }
//		Debug.Log (" position num on page   min[" + minReceiveParentNum +"]  +  ["+ pageoffset * -8+"]");

        GameManager.posPlayerOfRegDate(myRegDate);
        float dis;

        dis = Vector3.Distance(receiveParentPosition[minReceiveParentNum], playerPos);

        bool existChild = true;

        if (receiveParentTransform [minReceiveParentNum + pageoffset * -8].childCount == 0 || minReceiveParentNum == 24 || minReceiveParentNum == 25)
        {
            existChild = false;                                 // 指定枠に選手はいないので配置できる
        }
        bool   enptyPairPsition    = false;
        string myPairRegDate       = PairManager.getPairRegDate(myRegDate);
        int    iPairPositionOffset = 0;

        if (myPairRegDate != null)
        {
            if (minReceiveParentNum == GameManager.PLACE_WAIT || minReceiveParentNum == GameManager.PLACE_BREAK)
            {
                enptyPairPsition = true;                                        // 自分はPair設定されていているが、待機中または休憩中への移動
            }
            else
            {
                iPairPositionOffset = minReceiveParentNum % SettingManager.form == 0 ? 1 : -1;                                          // 自分の位置からPairの位置のOffsetを計算
                if (GameManager.getPlaceOfPlayer(minReceiveParentNum + iPairPositionOffset) == null)
                {
                    enptyPairPsition = true;                                    // 自分はPair設定されており、Pair枠に選手はいない
                }
            }
        }
        else
        {
            enptyPairPsition = true;                                            // 自分はPair設定されていていない
        }
        bool courtLock = false;

        if (minReceiveParentNum != GameManager.PLACE_WAIT && minReceiveParentNum != GameManager.PLACE_BREAK)            // 待機中、休憩中以外
        {
            int iCourtStat = GameManager.chkCourtLockOfPosition(minReceiveParentNum + pageoffset * -8);
            if (iCourtStat == GameManager.LOCK || iCourtStat == -1)
            {
                courtLock = true;                               // Lockされているコートには配置できない
            }
        }

        if (dis < limtDistance && !existChild && enptyPairPsition && !courtLock)
        {
            this.transform.parent.SetParent(receiveParentTransform[minReceiveParentNum + pageoffset * -8]);
            this.transform.parent.position = receiveParentPosition[minReceiveParentNum];
            GameManager.placeStat          = minReceiveParentNum + pageoffset * -8;
            if (myPairRegDate != null)
            {
                GameManager.posPlayerOfRegDate(myPairRegDate);                                  //Pairのワーク移動
                if (minReceiveParentNum == GameManager.PLACE_WAIT || minReceiveParentNum == GameManager.PLACE_BREAK)
                {
                    iPairPositionOffset = 0;
                }

                GameManager.trsPlayer.SetParent(receiveParentTransform[minReceiveParentNum + pageoffset * -8 + iPairPositionOffset]);
                GameManager.trsPlayer.position = receiveParentPosition[minReceiveParentNum + iPairPositionOffset];
                GameManager.placeStat          = minReceiveParentNum + pageoffset * -8 + iPairPositionOffset;
                //Ring
                if (iPairPositionOffset == 0)                           // 0 のときは待機中か休憩中への移動
                {
                    this.transform.parent.FindChild("Ring").gameObject.SetActive(false);
                    GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                    GameManager.trsPlayer.SetAsLastSibling();
                }
                else if (iPairPositionOffset == 1)
                {
                    this.transform.parent.FindChild("Ring").gameObject.SetActive(false);
                    GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                }
                else
                {
                    this.transform.parent.FindChild("Ring").gameObject.SetActive(true);
                    GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(false);
                }
            }
        }
        else
        {
            this.transform.parent.SetParent(tfOrignParent);
            this.transform.parent.position = tfOrignParent.position;
            if (myPairRegDate != null)
            {
                GameManager.posPlayerOfRegDate(myPairRegDate);                                  //Pairのワーク移動
                int iOriginPlace = GameManager.getPlayerPlace(myPairRegDate);
                if (iOriginPlace == GameManager.PLACE_WAIT || iOriginPlace == GameManager.PLACE_BREAK)
                {
                    this.transform.parent.FindChild("Ring").gameObject.SetActive(false);
                    GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                    GameManager.trsPlayer.SetAsLastSibling();
                }
            }
        }

        scriptGameView.loadView();
        //		Debug.Log ("["+minReceiveParentNum+"]  Minname  - > " + receiveParentTransform[minReceiveParentNum].name +"   "+dis);
    }
Esempio n. 2
0
    public void OnEndDrag(PointerEventData e)
    {
        flgDrag = false;

        if (longPressFlg)
        {
            Object.Destroy(sd);
            sd = null;
            Object.Destroy(ol);
            ol = null;

            int pageoffset      = 0;                            // 0:1page  -1:2page  -2:3page
            int MAXPLAYEROFPAGE = 8;
            if (minReceiveParentNum > 23)
            {
                pageoffset = 0;
            }
            else
            {
                pageoffset = GameManager.currentPage * (-1);                                    // 何ページ目かを計算する  page0:0~7    page1:8~15   page2:16~23
            }
            //			Debug.Log (" position num on page   min[" + minReceiveParentNum +"]  +  ["+ pageoffset * -8+"]  pageoffst:" + pageoffset);

            /// 各種移動前に可能か判定
            GameManager.posPlayerOfRegDate(myRegDate);
            // 最小となる移動先までの距離 (離れすぎていると移動しないように)
            float dis;
            dis = Vector3.Distance(receiveParentPosition [minReceiveParentNum], playerPos);


            // 入れ替え用変更
            // pairの有無 (pairがいる場合は、ダブルスであることが保証されていること)
            bool   toWaitBreak    = false;
            bool   courtLock      = false;
            bool   flgYouPair     = false;
            int    YouLock        = GameManager.UNLOCK;
            int    YouPairLock    = GameManager.UNLOCK;
            string youRegDate     = null;
            string youPairRegDate = null;
            int    youPosNum;
            int    iYouPairPositionOffset = 0;
            bool   flgMyPair  = false;
            int    myPairLock = GameManager.UNLOCK;
            string myPairRegDate;
            int    myPosNum;
            int    iMyPairPositionOffset = 0;


            // 自選手とpair位置にいる選手の存在有無と、pair判定、2人のLockの状況
            myPosNum      = GameManager.getPlayerPlace(myRegDate);
            myPairRegDate = PairManager.getPairRegDate(myRegDate);
            if (myPairRegDate != null)
            {
                flgMyPair = true;
            }
            else
            {
                flgMyPair = false;
            }

            if (myPosNum != GameManager.PLACE_WAIT && myPosNum != GameManager.PLACE_BREAK)               // 自分は待機、休憩中ではない コートでのpair位置にいる選手
            {
                iMyPairPositionOffset = myPosNum % SettingManager.form == 0 ? 1 : -1;                    // 自分の位置からPairの位置のOffset   上枠にpair 1:下枠にpair
                myPairRegDate         = GameManager.getPlaceOfPlayer(myPosNum + iMyPairPositionOffset);
                myPairLock            = GameManager.chkLock(myPairRegDate);
            }

            // 移動先の選手とpair位置にいる選手の存在有無と、pair判定、2人のLockの状況
            if (minReceiveParentNum != GameManager.PLACE_WAIT && minReceiveParentNum != GameManager.PLACE_BREAK)
            {
                toWaitBreak = false;

                // 移動先にいる選手とpair位置にいる選手の存在有無と、pair判定、2人のLockの状況
                youPosNum = minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE;
                iYouPairPositionOffset = youPosNum % SettingManager.form == 0 ? 1 : -1; // 相手の位置からPairの位置のOffset  -1:上枠にpair 1:下枠にpair
                youRegDate             = GameManager.getPlaceOfPlayer(youPosNum);
                if (youRegDate != null)                                                 // 移動先に選手がいる
                {
                    YouLock        = GameManager.chkLock(youRegDate);
                    youPairRegDate = PairManager.getPairRegDate(youRegDate);
                    if (youPairRegDate != null)                       // 相手にpairがいる
                    {
                        flgYouPair  = true;
                        YouPairLock = YouLock;
                    }
                    else                                                               // 相手にpairがいない
                    {
                        flgYouPair     = false;
                        youPairRegDate = GameManager.getPlaceOfPlayer(youPosNum + iYouPairPositionOffset);
                        if (youPairRegDate != null)                         // 相手にpairはいないが選手がいる
                        {
                            YouPairLock = GameManager.chkLock(youPairRegDate);
                        }
                    }
                }
                else                                                              // 移動先に選手がいない
                {
                    flgYouPair     = false;
                    youPairRegDate = GameManager.getPlaceOfPlayer(youPosNum + iYouPairPositionOffset);
                    if (youPairRegDate != null)                     // 移動先に選手がいないがpair枠に選手がいる
                    {
                        YouPairLock = GameManager.chkLock(youPairRegDate);
                    }
                }

                // Lockされているコートには配置できない
                int iCourtStat = GameManager.chkCourtLockOfPosition(minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE);
                if (iCourtStat == GameManager.LOCK || iCourtStat == -1)
                {
                    courtLock = true;
                }

                // 自分がPairのとき、移動先とPair枠の選手のLock状態を判定して、どちらかでもLockされているなら移動できない
                if (flgMyPair)
                {
                    if (YouLock == GameManager.LOCK || YouPairLock == GameManager.LOCK)
                    {
                        courtLock = true;
                    }
                }
                else
                {
                    if (YouLock == GameManager.LOCK)
                    {
                        courtLock = true;
                    }
                }
                if (flgYouPair)
                {
                    if (myPairLock == GameManager.LOCK)
                    {
                        courtLock = true;
                    }
                }
            }
            else
            {
                // 移動先が休憩中か待機中 (無条件で移動できる)
                toWaitBreak = true;
            }

            // 選手の移動
            if (dis < limtDistance && !courtLock)           // 必ず移動できることが保証されていること
            {
                if (toWaitBreak)                            // 待機中と休憩中へは無条件で移動 minReceiveParentNum=24,25
                {
                    this.transform.SetParent(receiveParentTransform[minReceiveParentNum]);
                    this.transform.position = receiveParentPosition[minReceiveParentNum];
                    GameManager.placeStat   = minReceiveParentNum;
                    if (flgMyPair)
                    {
                        GameManager.posPlayerOfRegDate(myPairRegDate);                                  //Pairのワーク移動
                        GameManager.trsPlayer.SetParent(receiveParentTransform[minReceiveParentNum]);
                        GameManager.trsPlayer.position = receiveParentPosition[minReceiveParentNum];
                        GameManager.placeStat          = minReceiveParentNum;
                        //Ring
                        this.transform.FindChild("Ring").gameObject.SetActive(false);
                        GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                        GameManager.trsPlayer.SetAsLastSibling();
                    }
                }
                else
                {
                    // 自分達の移動
                    this.transform.SetParent(receiveParentTransform[minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE]);
                    this.transform.position = receiveParentPosition[minReceiveParentNum];
                    GameManager.placeStat   = minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE;
                    if (flgMyPair || flgYouPair)
                    {
                        if (myPairRegDate != null)
                        {
                            GameManager.posPlayerOfRegDate(myPairRegDate);                                      //Pairのワーク移動
                            GameManager.trsPlayer.SetParent(receiveParentTransform[minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE + iYouPairPositionOffset]);
                            GameManager.trsPlayer.position = receiveParentPosition[minReceiveParentNum + iYouPairPositionOffset];
                            GameManager.placeStat          = minReceiveParentNum + pageoffset * MAXPLAYEROFPAGE + iYouPairPositionOffset;
                        }
                        //Ring
                        if (flgMyPair && iYouPairPositionOffset == 1)
                        {
                            this.transform.FindChild("Ring").gameObject.SetActive(false);
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                        }
                        else if (flgMyPair && iYouPairPositionOffset == -1)
                        {
                            this.transform.FindChild("Ring").gameObject.SetActive(true);
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(false);
                        }
                    }
                    // 相手達の移動
                    if (youRegDate != null)
                    {
                        GameManager.posPlayerOfRegDate(youRegDate);                                  //相手選手のワーク移動
                        GameManager.trsPlayer.SetParent(receiveParentTransform[myPosNum]);
                        GameManager.trsPlayer.position = receiveParentPosition[myPosNum - pageoffset * MAXPLAYEROFPAGE];
                        GameManager.placeStat          = myPosNum;
                    }
                    if (flgMyPair || flgYouPair)
                    {
                        if (youPairRegDate != null)
                        {
                            GameManager.posPlayerOfRegDate(youPairRegDate);                                      //相手Pairのワーク移動
                            GameManager.trsPlayer.SetParent(receiveParentTransform[myPosNum + iMyPairPositionOffset]);
                            GameManager.trsPlayer.position = receiveParentPosition[myPosNum - pageoffset * MAXPLAYEROFPAGE + iMyPairPositionOffset];
                            GameManager.placeStat          = myPosNum + iMyPairPositionOffset;
                        }
                        //Ring
                        if (flgYouPair && (myPosNum == GameManager.PLACE_WAIT || myPosNum == GameManager.PLACE_BREAK)) //相手選手を待機中、休憩中への移動
                        {
                            GameManager.posPlayerOfRegDate(youRegDate);                                                //相手選手のワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(false);
                            GameManager.posPlayerOfRegDate(youPairRegDate);                                            //相手Pairのワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                            GameManager.trsPlayer.SetAsLastSibling();
                        }
                        else if (flgYouPair && iMyPairPositionOffset == 1)
                        {
                            GameManager.posPlayerOfRegDate(youRegDate);                                      //相手選手のワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(false);
                            GameManager.posPlayerOfRegDate(youPairRegDate);                                  //相手Pairのワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                        }
                        else if (flgYouPair && iMyPairPositionOffset == -1)
                        {
                            GameManager.posPlayerOfRegDate(youRegDate);                                      //相手選手のワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                            GameManager.posPlayerOfRegDate(youPairRegDate);                                  //相手Pairのワーク移動
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(false);
                        }
                    }
                }
            }
            else                                // 移動できない
            {
                this.transform.SetParent(tfOrignParent);
                this.transform.position = tfOrignParent.position;
                if (flgMyPair)
                {
                    GameManager.posPlayerOfRegDate(myPairRegDate);                              //Pairのワーク移動
                    int iOriginPlace = GameManager.getPlayerPlace(myPairRegDate);
                    if (iOriginPlace == GameManager.PLACE_WAIT || iOriginPlace == GameManager.PLACE_BREAK)
                    {
                        this.transform.FindChild("Ring").gameObject.SetActive(false);
                        GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                        GameManager.trsPlayer.SetAsLastSibling();
                    }
                    else
                    {
                        if (flgMyPariMk)
                        {
                            this.transform.FindChild("Ring").gameObject.SetActive(true);
                        }
                        else
                        {
                            GameManager.trsPlayer.FindChild("Ring").gameObject.SetActive(true);
                        }
                    }
                }
            }
            rcvParentTfmWait.vertical  = true;                  // scrollRsctの再開
            rcvParentTfmBreak.vertical = true;                  // scrollRsctの再開
            longPressFlg = false;
            rcvParentTfmWait.verticalNormalizedPosition  = 1;
            rcvParentTfmBreak.verticalNormalizedPosition = 1;
            scriptGameView.loadView();
        }

        int iPlaceNum = GameManager.getPlayerPlace(myRegDate);

        if (iPlaceNum == GameManager.PLACE_WAIT)
        {
            transform.DoParentEventSystemHandler <IBeginDragHandler> ((parent) => { rcvParentTfmWait.OnEndDrag(e); });
        }
        else if (iPlaceNum == GameManager.PLACE_BREAK)
        {
            transform.DoParentEventSystemHandler <IBeginDragHandler> ((parent) => { rcvParentTfmBreak.OnEndDrag(e); });
        }
        else
        {
            transform.DoParentEventSystemHandler <IBeginDragHandler>((parent) => { pageScrollRect.OnEndDrag(e); });
        }
        eventLP.enableLongPress = true;
    }