Пример #1
0
    public void OnClick_Pon()
    {
        if (isMenuEnable(EActionType.Pon))
        {
            //Debug.Log("+ OnClick_Pon()");

            PlayerAction.Response = EResponse.Pon;

            NotifyHide();
            OwnerPlayer.OnPlayerInputFinished();
        }
    }
Пример #2
0
    public void OnClick_Agari()
    {
        if (isMenuEnable(EActionType.Ron) || isMenuEnable(EActionType.Tsumo))
        {
            //Debug.Log("+ OnClick_Agari()");

            if (PlayerAction.IsValidTsumo)
            {
                PlayerAction.Response = EResponse.Tsumo_Agari;
            }
            else
            {
                PlayerAction.Response = EResponse.Ron_Agari;
            }

            NotifyHide();
            OwnerPlayer.OnPlayerInputFinished();
        }
    }
Пример #3
0
    public void Onclick_Nagashi()
    {
        if (isMenuEnable(EActionType.Nagashi) || isMenuEnable(EActionType.RyuuKyoku))
        {
            //Debug.Log("+ Onclick_Nagashi()");

            if (PlayerAction.State == EActionState.Select_Kan)  // enable Ankan after Reach.
            {
                PlayerAction.Response     = EResponse.SuteHai;
                PlayerAction.SutehaiIndex = OwnerPlayer.Tehai.getJyunTehaiCount();
            }
            else
            {
                PlayerAction.Response = EResponse.Nagashi;
            }

            NotifyHide();
            OwnerPlayer.OnPlayerInputFinished();
        }
    }
Пример #4
0
    void OnClickMahjong()
    {
        //Debug.Log ("OnClickMahjong()");
        int index = tehaiList.IndexOf(MahjongPai.current);

        //int index = 0;
        //Debug.Log("OnClickMahjong(" + index.ToString()+")");
        //index = OwnerPlayer.Tehai.getJyunTehaiCount() - 1; // Test: the last one.

        switch (PlayerAction.State)
        {
        case EActionState.Select_Agari:
        case EActionState.Select_Sutehai:
        {    //丟牌
            PlayerAction.Response     = EResponse.SuteHai;
            PlayerAction.SutehaiIndex = index;

            EventManager.Instance.RpcSendEvent(UIEventType.HideMenuList);
            OwnerPlayer.OnPlayerInputFinished();
        }
        break;

        case EActionState.Select_Reach:
        {    //聽牌
            PlayerAction.Response         = EResponse.Reach;
            PlayerAction.ReachSelectIndex = PlayerAction.ReachHaiIndexList.FindIndex(i => i == index);

            SetEnableStateColor(true);
            EventManager.Instance.RpcSendEvent(UIEventType.HideMenuList);
            OwnerPlayer.OnPlayerInputFinished();
        }
        break;

        case EActionState.Select_Kan:
        {    //槓
            Hai kanHai = new Hai(MahjongPai.current.ID);
            //Hai kanHai = new Hai( 0);

            if (OwnerPlayer.Tehai.validKaKan(kanHai))
            {
                PlayerAction.Response = EResponse.Kakan;
            }
            else
            {
                PlayerAction.Response = EResponse.Ankan;
            }

            PlayerAction.KanSelectIndex = PlayerAction.TsumoKanHaiList.FindIndex(h => h.ID == kanHai.ID);

            SetEnableStateColor(true);
            EventManager.Instance.RpcSendEvent(UIEventType.HideMenuList);
            OwnerPlayer.OnPlayerInputFinished();
        }
        break;

        case EActionState.Select_Chii:
        {    //吃
            MahjongPai curSelect = MahjongPai.current;
            //MahjongPai curSelect = new MahjongPai();

            if (chiiPaiSelectList.Contains(curSelect))
            {
                chiiPaiSelectList.Remove(curSelect);
                curSelect.transform.localPosition -= SelectStatePosOffset;

                // check to enable select other chii type pai.
                List <int> enableIndexList = new List <int>();
                Hai[]      jyunTehais      = OwnerPlayer.Tehai.getJyunTehai();

                for (int i = 0; i < PlayerAction.AllSarashiHais.Count; i++)
                {
                    for (int j = 0; j < jyunTehais.Length; j++)
                    {
                        if (jyunTehais[j].ID == PlayerAction.AllSarashiHais[i].ID)
                        {
                            enableIndexList.Add(j);
                        }
                    }
                }

                EnableInput(enableIndexList);
            }
            else
            {
                chiiPaiSelectList.Add(curSelect);
                if (curSelect)
                {
                    curSelect.transform.localPosition += SelectStatePosOffset;
                }

                if (chiiPaiSelectList.Count >= 2)      // confirm Chii.
                {
                    chiiPaiSelectList.Sort(MahjongPaiCompare);

                    if (PlayerAction.SarashiHaiRight.Count >= 2)
                    {
                        PlayerAction.SarashiHaiRight.Sort(Tehai.Compare);
                        if (chiiPaiSelectList[0].ID == PlayerAction.SarashiHaiRight[0].ID &&
                            chiiPaiSelectList[1].ID == PlayerAction.SarashiHaiRight[1].ID)
                        {
                            PlayerAction.Response       = EResponse.Chii_Right;
                            PlayerAction.ChiiSelectType = PlayerAction.Chii_Select_Right;
                            Debug.Log("Chii type is Chii_Right");
                        }
                    }

                    if (PlayerAction.SarashiHaiCenter.Count >= 2)
                    {
                        PlayerAction.SarashiHaiCenter.Sort(Tehai.Compare);
                        if (chiiPaiSelectList[0].ID == PlayerAction.SarashiHaiCenter[0].ID &&
                            chiiPaiSelectList[1].ID == PlayerAction.SarashiHaiCenter[1].ID)
                        {
                            PlayerAction.Response       = EResponse.Chii_Center;
                            PlayerAction.ChiiSelectType = PlayerAction.Chii_Select_Center;
                            Debug.Log("Chii type is Chii_Center");
                        }
                    }

                    if (PlayerAction.SarashiHaiLeft.Count >= 2)
                    {
                        PlayerAction.SarashiHaiLeft.Sort(Tehai.Compare);
                        if (chiiPaiSelectList[0].ID == PlayerAction.SarashiHaiLeft[0].ID &&
                            chiiPaiSelectList[1].ID == PlayerAction.SarashiHaiLeft[1].ID)
                        {
                            PlayerAction.Response       = EResponse.Chii_Left;
                            PlayerAction.ChiiSelectType = PlayerAction.Chii_Select_Left;
                            Debug.Log("Chii type is Chii_Left");
                        }
                    }

                    EventManager.Instance.RpcSendEvent(UIEventType.HideMenuList);
                    OwnerPlayer.OnPlayerInputFinished();

                    chiiPaiSelectList.Clear();
                }
                else     // check to disable select other chii type pai.
                {
                    List <int> enableIndexList = new List <int>();
                    Hai[]      jyunTehais      = OwnerPlayer.Tehai.getJyunTehai();

                    int curSelectID = chiiPaiSelectList[0].ID;
                    enableIndexList.Add(index);

                    if (PlayerAction.SarashiHaiRight.Exists(h => h.ID == curSelectID))
                    {
                        Hai otherHai = PlayerAction.SarashiHaiRight.Find(h => h.ID != curSelectID);

                        for (int i = 0; i < jyunTehais.Length; i++)
                        {
                            if (jyunTehais[i].ID == otherHai.ID && !enableIndexList.Contains(i))
                            {
                                enableIndexList.Add(i);
                            }
                        }
                    }

                    if (PlayerAction.SarashiHaiCenter.Exists(h => h.ID == curSelectID))
                    {
                        Hai otherHai = PlayerAction.SarashiHaiCenter.Find(h => h.ID != curSelectID);

                        for (int i = 0; i < jyunTehais.Length; i++)
                        {
                            if (jyunTehais[i].ID == otherHai.ID && !enableIndexList.Contains(i))
                            {
                                enableIndexList.Add(i);
                            }
                        }
                    }

                    if (PlayerAction.SarashiHaiLeft.Exists(h => h.ID == curSelectID))
                    {
                        Hai otherHai = PlayerAction.SarashiHaiLeft.Find(h => h.ID != curSelectID);

                        for (int i = 0; i < jyunTehais.Length; i++)
                        {
                            if (jyunTehais[i].ID == otherHai.ID && !enableIndexList.Contains(i))
                            {
                                enableIndexList.Add(i);
                            }
                        }
                    }

                    EnableInput(enableIndexList);
                }
            }
        }
        break;
        }
    }
Пример #5
0
    public void OnClick_Kan()
    {
        if (isMenuEnable(EActionType.Kan))
        {
            //Debug.Log("+ OnClick_Kan()");

            if (PlayerAction.IsValidTsumoKan)
            {
                if (PlayerAction.TsumoKanHaiList.Count > 1)
                {
                    if (PlayerAction.State == EActionState.Select_Kan)    // cancel reach.
                    {
                        PlayerAction.State = EActionState.Select_Sutehai; // set state to Select_SuteHai

                        playerUI.Tehai.EnableInput(true);

                        //btn_Kan.SetTag( ResManager.getString("button_kan") );

                        // refresh other menu buttons
                        RefreshMenuButtons();
                    }
                    else
                    {
                        PlayerAction.State = EActionState.Select_Kan;

                        // list kan hai selection.
                        List <int> enableIndexList = new List <int>();
                        Hai[]      jyunTehais      = OwnerPlayer.Tehai.getJyunTehai();

                        for (int i = 0; i < PlayerAction.TsumoKanHaiList.Count; i++)
                        {
                            for (int j = 0; j < jyunTehais.Length; j++)
                            {
                                if (jyunTehais[j].ID == PlayerAction.TsumoKanHaiList[i].ID)
                                {
                                    enableIndexList.Add(j);
                                }
                            }
                        }

                        Hai tsumoHai = GameAgent.Instance.getTsumoHai();
                        for (int i = 0; i < PlayerAction.TsumoKanHaiList.Count; i++)
                        {
                            if (tsumoHai.ID == PlayerAction.TsumoKanHaiList[i].ID)
                            {
                                enableIndexList.Add(OwnerPlayer.Tehai.getJyunTehaiCount());
                            }
                        }

                        playerUI.Tehai.EnableInput(enableIndexList);

                        //btn_Kan.SetTag( ResManager.getString("button_cancel") );

                        // disable other menu buttons.
                        DisableButtonsExcept(EActionType.Kan);
                    }
                }
                else
                {
                    Hai kanHai = PlayerAction.TsumoKanHaiList[0];
                    OwnerPlayer.Action.KanSelectIndex = 0;

                    if (OwnerPlayer.Tehai.validKaKan(kanHai))
                    {
                        PlayerAction.Response = EResponse.Kakan;
                    }
                    else
                    {
                        PlayerAction.Response = EResponse.Ankan;
                    }

                    NotifyHide();
                    OwnerPlayer.OnPlayerInputFinished();
                }
            }
            else
            {
                PlayerAction.Response = EResponse.DaiMinKan;

                NotifyHide();
                OwnerPlayer.OnPlayerInputFinished();
            }
        }
    }
Пример #6
0
    public void OnClick_Chii()
    {
        if (isMenuEnable(EActionType.Chii))
        {
            //Debug.Log("+ OnClick_Chii()");

            if (PlayerAction.AllSarashiHais.Count > 2)
            {
                if (PlayerAction.State == EActionState.Select_Chii) // cancel reach.
                {
                    PlayerAction.State = EActionState.None;         // set state to Select_SuteHai

                    playerUI.Tehai.EnableInput(true);

                    //btn_Chii.SetTag( ResManager.getString("button_chii") );

                    // refresh other menu buttons
                    RefreshMenuButtons();
                }
                else
                {
                    PlayerAction.State = EActionState.Select_Chii;

                    // list chii hai selection.
                    List <int> enableIndexList = new List <int>();
                    Hai[]      jyunTehais      = OwnerPlayer.Tehai.getJyunTehai();

                    for (int i = 0; i < PlayerAction.AllSarashiHais.Count; i++)
                    {
                        for (int j = 0; j < jyunTehais.Length; j++)
                        {
                            if (jyunTehais[j].ID == PlayerAction.AllSarashiHais[i].ID)
                            {
                                enableIndexList.Add(j);
                            }
                        }
                    }

                    playerUI.Tehai.EnableInput(enableIndexList);

                    //btn_Chii.SetTag( ResManager.getString("button_cancel") );

                    // disable other menu buttons.
                    DisableButtonsExcept(EActionType.Chii);
                }
            }
            else
            {
                // check Chii type.
                if (PlayerAction.IsValidChiiLeft)
                {
                    PlayerAction.Response = EResponse.Chii_Left;
                }
                else if (PlayerAction.IsValidChiiCenter)
                {
                    PlayerAction.Response = EResponse.Chii_Center;
                }
                else
                {
                    PlayerAction.Response = EResponse.Chii_Right;
                }

                PlayerAction.ChiiSelectType = 0;

                NotifyHide();
                OwnerPlayer.OnPlayerInputFinished();
            }
        }
    }