Exemplo n.º 1
0
    void showWin()
    {
        var trans = _transWin;
        var iLen  = trans.childCount;

        if (iLen >= 13)
        {
            int        iCount  = 0;
            bool       bWin    = true;
            CardSpider preCard = null;
            for (var i = iLen - 1; i >= 0; i--)
            {
                var card = trans.GetChild(i).GetComponent <CardSpider> ();
                if (card.getBShowBg() == true)
                {
                    break;
                }
                if (i == iLen - 1)
                {
                    if (card.getCardNum() == 1)
                    {
                        iCount++;
                    }
                    else
                    {
                        bWin = false;
                    }
                }
                else
                {
                    if (preCard.getCardType() == card.getCardType() && preCard.getCardNum() + 1 == card.getCardNum())
                    {
                        iCount++;
                    }
                    else
                    {
                        bWin = false;
                    }
                }
                if (bWin == false)
                {
                    break;
                }
                preCard = card;
            }
            if (iCount == 13)
            {
                adMgr.PlaySound("score");
                _transWin = trans;
                lDesStep.Add(_iStep);
                lDesRow.Add(trans.GetSiblingIndex());
                setTouchable(false);
                Invoke("playWin", 0.5f);
                //}
            }
        }
    }
Exemplo n.º 2
0
    void showUpCardRotate(CardSpider card)
    {
        var iPos   = 0;
        var transP = tTrans[iPos];

        //优先同色
        for (var i = 0; i < transP.childCount; i++)
        {
            if (card.getPos() == 0 && card.getRow() == i)
            {
                continue;
            }
            var rect = transP.GetChild(i);
            if (rect.childCount > 0)
            {
                var cardUp = rect.GetChild(rect.childCount - 1).gameObject.GetComponent <CardSpider>();
                if (cardUp.getCardType() == card.getCardType() && cardUp.getCardNum() - card.getCardNum() == 1)
                {
                    StopCoroutine(playTipsCard());
                    cardUpTips = cardUp;
                    StartCoroutine(playTipsCard());
                    break;
                }
            }
        }
        //再异色
        for (var i = 0; i < transP.childCount; i++)
        {
            if (card.getPos() == 0 && card.getRow() == i)
            {
                continue;
            }
            var rect = transP.GetChild(i);
            if (rect.childCount > 0)
            {
                var cardUp = rect.GetChild(rect.childCount - 1).gameObject.GetComponent <CardSpider>();
                if (cardUp.getCardNum() - card.getCardNum() == 1)
                {
                    StopCoroutine(playTipsCard());
                    cardUpTips = cardUp;
                    StartCoroutine(playTipsCard());
                    break;
                }
            }
        }
    }
Exemplo n.º 3
0
    public bool getBMoveToCard(CardSpider card, bool bMove)
    {
        var iPos   = 0;
        var transP = tTrans [iPos];

        //优先同色
        for (var i = 0; i < transP.childCount; i++)
        {
            if (card.getPos() == 0 && card.getRow() == i)
            {
                continue;
            }
            var rect = transP.GetChild(i);
            if (rect.childCount > 0)
            {
                var cardUp = rect.GetChild(rect.childCount - 1).gameObject.GetComponent <CardSpider> ();
                if (cardUp.getCardType() == card.getCardType() && cardUp.getCardNum() - card.getCardNum() == 1)
                {
                    if (bMove == true)
                    {
                        onCardMove(card, iPos, i);
                    }
                    return(true);
                }
            }
        }
        //再异色
        for (var i = 0; i < transP.childCount; i++)
        {
            if (card.getPos() == 0 && card.getRow() == i)
            {
                continue;
            }
            var rect = transP.GetChild(i);
            if (rect.childCount > 0)
            {
                var cardUp = rect.GetChild(rect.childCount - 1).gameObject.GetComponent <CardSpider>();
                if (cardUp.getCardNum() - card.getCardNum() == 1)
                {
                    if (bMove == true)
                    {
                        onCardMove(card, iPos, i);
                    }
                    return(true);
                }
            }
        }
        //空列不提示
        if (bMove == false)
        {
            return(false);
        }
        //再空列
        for (var i = 0; i < transP.childCount; i++)
        {
            if (card.getPos() == 0 && card.getRow() == i)
            {
                continue;
            }
            if (transP.GetChild(i).childCount == 0)
            {
                if (bMove == true)
                {
                    onCardMove(card, iPos, i);
                }
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 4
0
    void setBMove()
    {
        var transP = tTrans[0];

        for (int i = 0; i < IROWCOUNT; i++)
        {
            var trans = transP.GetChild(i);
            var len   = trans.childCount;
            if (len > 0)
            {
                CardSpider preCard = null;
                for (int j = len - 1; j >= 0; j--)
                {
                    var card = trans.GetChild(j).GetComponent <CardSpider>();
                    if (card.getBShowBg() == false && (j == len - 1 ||
                                                       (preCard.getBMove() == true && preCard.getCardType() == card.getCardType() && preCard.getCardNum() + 1 == card.getCardNum())))
                    {
                        card.setBMove(true);
                    }
                    else
                    {
                        card.setBMove(false);
                    }
                    preCard = card;
                }
            }
        }
        setTouchable(true);
    }