예제 #1
0
        public void ResetStatus()
        {
            Debug.Log("[ResetStatus]");
            Mahjong mj = null;

            for (int i = 0; i < transform.childCount; i++)
            {
                mj = transform.GetChild(i).gameObject.GetComponent <Mahjong>();
                if (mj.GetStatus() == Mahjong.Status.HoldingToThrow || mj.GetStatus() == Mahjong.Status.HoldingToGang)
                {
                    mj.SetStatus(Mahjong.Status.Holding);
                }
            }
        }
예제 #2
0
        public void OnPointUp()
        {
            MyTilesScript myMahjongs = GameObject.Find("MyTiles").GetComponent <MyTilesScript>() as MyTilesScript;

            switch (currentStatus)
            {
            case Status.Selecting:
            case Status.Closed:
                myMahjongs.ResetStatus();
                if (myMahjongs.CreateMahjongByValue(mahjongValue))
                {
                    SetStatus(Status.Gone);
                    return;     //如果被手里的牌接收了,则处理结束
                }
                NewFetchScript currentMahjong = GameObject.Find("NewFetched").GetComponent <NewFetchScript>() as NewFetchScript;
                if (currentMahjong.ReceiveMahjong(this.GetMahjongValue()))
                {
                    // GameObject.Destroy(this); // 已经被传给当前牌了,因为当前牌是复用,所以可以直接销毁被摸的牌
                    // transform.SetParent(null);
                    SetStatus(Status.Gone);
                    return;     // 摸牌的情况
                }

                break;

            case Status.Holding:
                SetStatus(Status.HoldingToThrow);
                break;

            case Status.HoldingToThrow:
                // 如果不是手里的牌,直接销毁
                if (!this.isMine)
                {
                    SetStatus(Status.Gone);
                }
                else
                {
                    // 如果是手里的牌,则需要把新抓的牌替代进去
                    GameObject currentMahjong2 = GameObject.Find("CurrentMahjong");
                    if (currentMahjong2 != null)
                    {
                        Mahjong to = currentMahjong2.GetComponent <Mahjong>() as Mahjong;
                        if (to.GetStatus() != Status.Gone)
                        {
                            myMahjongs.updateMahjong(this, to.GetMahjongValue());
                            to.SetStatus(Status.Gone);
                        }
                    }
                    else
                    {
                        // (未知错误的时候,通常不会发生)如果是手里的牌,但又没有摸牌,则恢复。
                        SetStatus(Status.Holding);
                    }
                }
                break;

            case Status.HoldingToGang:
                myMahjongs.OnMahjongSelectedToGang(mahjongValue);
                break;
            }
        }