Beispiel #1
0
    void HandleRightMouseDownEvent(object sender, EventArgs e)
    {
        GameObject orderheap = m_gloManager.orderHeap;

        foreach (CardHeap h in orderheap.GetComponentsInChildren <CardHeap>())
        {
            if (!h.curCard && cardInfo.num != 1)
            {
                continue;
            }
            if ((!h.curCard && cardInfo.num == 1) ||
                (h.curCard.cardInfo.color == cardInfo.color && h.curCard.cardInfo.num == cardInfo.num - 1))
            {
                RectTransform heapRt   = m_gloManager.GetHeapRcTrans(h.name);
                CardHeap      tempHeap = heapRt.GetComponent <CardHeap>();
                Card          tempCard = tempHeap.curCard;

                //将原来牌堆当前牌替换
                curHeap.RefreshCurCard(this);

                //处理新牌堆
                if (!tempCard)
                {
                    m_rt.SetParent(heapRt, false);
                    if (cardAniEvent != null)
                    {
                        cardAniEvent(this, new cardAniArgs(new Vector2(0, -68), 0.5f, m_rt));
                    }
                }
                else
                {
                    m_rt.SetParent(tempCard.GetComponent <RectTransform>(), false);
                    if (cardAniEvent != null)
                    {
                        cardAniEvent(this, new cardAniArgs(Vector2.zero, 0.5f, m_rt));
                    }
                }
                Card card = GetComponent <Card>();
                foreach (Transform t in GetComponentsInChildren <Transform>())
                {
                    card = t.GetComponent <Card>();
                }
                curHeap         = tempHeap;
                curHeap.curCard = card;
                SetCurHeap(curHeap);
            }
        }
        if (m_gloManager.orderHeap.transform.childCount == 52)
        {
            Debug.Log("you win");
        }
    }
Beispiel #2
0
    void HandleRightMouseDownEvent(object sender, EventArgs e)
    {
        GameObject orderheap = m_gloManager.orderHeap;

        m_selectedCard     = (sender as GameObject).GetComponent <Card>();
        m_selectedCardInfo = m_selectedCard.cardInfo;
        m_selectedCardRt   = m_selectedCard.GetComponent <RectTransform>();

        foreach (CardHeap h in orderheap.GetComponentsInChildren <CardHeap>())
        {
            if (!OrderCardRule(h.curCard, m_selectedCard))
            {
                continue;
            }

            m_curHeapRt     = m_gloManager.GetHeapRcTrans(h.name);
            m_curHeap       = m_curHeapRt.GetComponent <CardHeap>();
            m_newParentCard = m_curHeap.curCard;

            //将原来牌堆当前牌替换
            m_selectedCard.curHeap.RefreshCurCard(m_selectedCard);

            //处理新牌堆
            if (!m_newParentCard)
            {
                m_selectedCardRt.SetParent(m_curHeapRt, false);
                if (cardAniEvent != null)
                {
                    cardAniEvent(this, new cardAniArgs(
                                     new Vector2(0, -68), 0.5f, m_selectedCardRt));
                }
            }
            else
            {
                m_selectedCardRt.SetParent(m_newParentCard.GetComponent <RectTransform>(), false);
                if (cardAniEvent != null)
                {
                    cardAniEvent(this, new cardAniArgs(
                                     Vector2.zero, 0.5f, m_selectedCardRt));
                }
            }
            Card overCard = null;
            foreach (Transform t in m_selectedCardRt.GetComponentsInChildren <Transform>())
            {
                overCard = t.GetComponent <Card>();
            }
            m_selectedCard.curHeap = m_curHeap;
            m_curHeap.curCard      = overCard;
            m_selectedCard.SetCurHeap(m_curHeap);
        }
    }