Esempio n. 1
0
    public void ChuPai(int pai, Action cb)
    {
        GameObject   ob   = currentObj;
        HandCardItem item = null;

        int  id   = pai % 100;
        bool ting = pai > 100;

        if (ob != null)
        {
            item = GetHandCardItemByObj(ob);

            if (item != null && item.checkId(id))
            {
                item.setTing(ting);

                item.setCB(cb);
                chuPaiEvent(item, true);
                currentObj = null;
                return;
            }
            else if (item == null)
            {
                Debug.LogError("id not found");
            }
            else
            {
                Debug.LogError("id wrong");
            }
        }

        currentObj = null;

        bool valid = isHoldsValid();

        if (valid)
        {
            item = GetHandCardItemById(id);
        }
        else
        {
            item = GetRandomHandCardItem(id);
        }

        if (item != null)
        {
            item.setTing(ting);

            item.setCB(cb);
            chuPaiEvent(item, true);
            return;
        }

        Debug.LogError("chupai not found: " + id);
    }