Пример #1
0
    public void chapai()
    {
        oldIndex = GetOldIndex();
        if (oldIndex == -2)
        {
            Debug.LogError("oldindex error");
            return;
        }

        HandCardItem item = null;

        if (oldIndex != -1)
        {
            item = _handCardList[oldIndex];
        }
        else
        {
            item = _MoHand;
        }

        if (isPeng)     //碰牌以后,直接打牌,不需要摸牌,也不能插牌
        {
            if (oldIndex != -1)
            {
                _handCardList.RemoveAt(oldIndex);
            }
            else
            {
                _MoHand = null;
            }

            isPeng = false;
            UpdateHandCard();

            item.invoke();
        }
        else if (oldIndex != -1 && _MoHand != null)           //如果需要插牌,则执行插牌
        {
            newIndex = isHoldsValid() ? GetIndexByItem(_MoHand) : GetRandomIndex();
            if (newIndex > oldIndex)
            {
                newIndex--;
            }

            if (newIndex == oldIndex && newIndex == 13)
            {
                newIndex--;
            }

            item.invoke();
            ChaPai(newIndex, _MoHand.getObj());
        }
        else if (oldIndex == -1)
        {
            _MoHand = null;

            item.invoke();
        }
        else
        {
            _handCardList.RemoveAt(oldIndex);
            UpdateHandCard();

            item.invoke();
        }
    }