Ejemplo n.º 1
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;
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void addCard(CardSpider card)
    {
        var        iPos       = card.getPos();
        var        iRow       = card.getRow();
        CardSpider upCardTemp = null;

        if (card.transform.parent == _delegate.getTransMove())
        {
            var upTrans = _delegate.getTransP(iPos, iRow);
            var iLen    = upTrans.childCount;
            if (iLen > 0)
            {
                var upCard = upTrans.GetChild(iLen - 1).GetComponent <CardSpider> ();
                if (upCard.getBShowBg() == true)
                {
                    upCardTemp = upCard;
                }
            }
        }
        else
        {
            var idx = card.transform.GetSiblingIndex();
            if (idx > 0)
            {
                var upTrans = card.transform.parent;
                var upCard  = upTrans.GetChild(idx - 1).GetComponent <CardSpider> ();
                if (upCard.getBShowBg() == true)
                {
                    upCardTemp = upCard;
                }
            }
        }
        lPreCard.Add(card);
        lPrePos.Add(iPos);
        lPreRow.Add(iRow);
        lPreUpCard.Add(upCardTemp);
    }
Ejemplo 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);
    }
Ejemplo n.º 4
0
    public void moveCards(CardSpider card, int iPos, int iRow)
    {
        adMgr.PlaySound("move");
        bool bAutoMove = true;

        if (card.transform.parent.gameObject == goMove)
        {
            bAutoMove = false;
        }
        if (bAutoMove == true && iPos == 0)
        {
            card.addItems();
        }
        var       items = card.getItems();
        Transform upTrans;

        if (bAutoMove == true)
        {
            var cIdx = card.transform.GetSiblingIndex();
            if (cIdx > 0 && card.getPos() == 0)
            {
                upTrans = card.transform.parent;
                var upCard = upTrans.GetChild(cIdx - 1).GetComponent <CardSpider>();
                if (upCard.getBShowBg() == true)
                {
                    upCard.showBg(false);
                }
            }
        }
        else
        {
            upTrans = getTransP(card.getPos(), card.getRow());
            var iLen = upTrans.childCount;
            if (iLen > 0)
            {
                var upCard = upTrans.GetChild(iLen - 1).GetComponent <CardSpider>();
                if (upCard.getBShowBg() == true)
                {
                    upCard.showBg(false);
                }
            }
        }
        var trans = getTransP(iPos, iRow);

        card.setPos(iPos);
        card.setRow(iRow);
        card.transform.SetParent(trans);
        if (iPos == 0)
        {
            if (items.Count > 0)
            {
                foreach (Transform item in items)
                {
                    var itemCard = item.GetComponent <CardSpider>();
                    itemCard.setPos(iPos);
                    itemCard.setRow(iRow);
                    item.SetParent(trans);
                }
            }
            _transWin = trans;
            setBMove();
            showWin();
            if (bAutoMove == false)
            {
                card.transform.localPosition = new Vector3(0, 0 - 30 * (trans.childCount - 1 - items.Count), 0);
                if (items.Count > 0)
                {
                    var idx = 0;
                    foreach (Transform item in items)
                    {
                        idx++;
                        item.localPosition = new Vector3(0, 0 - 30 * (trans.childCount - 1 - items.Count + idx), 0);
                    }
                }
            }
            else
            {
                card.transform.SetParent(goMove.transform);
                var iPosX = _px + IROWDIS * iRow;
                var iPosY = _py - 30 * (trans.childCount - items.Count);
                var pos   = card.gameObject.GetComponent <RectTransform>().anchoredPosition;
                if (items.Count > 0)
                {
                    foreach (Transform item in items)
                    {
                        item.SetParent(card.transform);
                    }
                }
                card.showMove(iPosX - pos.x, iPosY - pos.y, iPosX);
            }
        }
    }