Ejemplo n.º 1
0
    public void CreateCard(CardMoveInfo card, int cardIndex)
    {
        var size  = XSize;
        var count = transform.childCount + 1;

        if ((count - 1f) * size > Width)
        {
            size = Width / (count - 1f);
        }
        cardIndex = (cardIndex == -1 ? transform.childCount : cardIndex);
        var position = new Vector3
                       (
            ((IsLock ? 0 : (-(count - 1f) * size / 2f)) + cardIndex * size),
            (-YSize * (cardIndex)),
            (IsCoverage ? (-0.1f - 0.01f * (count - cardIndex - 1)) : (-0.1f - 0.01f * cardIndex))
                       );

        card.IsCanDrag = IsCanDrag;
        card.transform.SetParent(transform);
        card.transform.SetSiblingIndex(GetTrueIndex(cardIndex));
        card.transform.localPosition = position;
        card.SetResetPoint(position);
        card.transform.localScale = Vector3.one;
        ResetCards();
        // if (Id.IsOnPlace())
        //     card.IsOn = true;
    }
Ejemplo n.º 2
0
    public void AddCard(CardMoveInfo card, int cardIndex)//,bool isAwait = true)
    {
        if (IsTem())
        {//添加卡牌的时候删除临时卡
            AddTemCard(null, -1);
        }
        card.IsCanDrag = IsCanDrag;
        var source = card.transform.parent.gameObject.GetComponent <CardsPosition>();
        var leader = card.transform.parent.gameObject.GetComponent <LeaderCard>();

        card.transform.SetParent(transform);
        card.transform.SetSiblingIndex(cardIndex == -1 ? transform.childCount : cardIndex);
        card.IsCanDrag = IsCanDrag;
        if (card.IsOn)//测试
        {
            card.IsOn = true;
        }
        if (source != null)
        {
            source.ResetCards();
        }
        if (leader != null)
        {
            leader.TrueCard = null;
        }
        ResetCards();
    }