public void OnCardPosChanged(int srcPos, int tgtPos)
        {
            if (srcPos < 0 || srcPos > 5)
            {
                return;
            }
            if (tgtPos < 0 || tgtPos > 5)
            {
                return;
            }
            if (srcPos == tgtPos)
            {
                return;
            }

            BattleSlot srcSlot = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][srcPos];
            BattleCard srcCard = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][srcPos].Battle_Card;
            BattleSlot tgtSlot = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][tgtPos];
            BattleCard tgtCard = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][tgtPos].Battle_Card;

            srcCard.OnChangeSlot(tgtSlot);
            tgtSlot.OnChangeCard(srcCard);

            if (tgtCard != null)
            {
                tgtCard.OnChangeSlot(srcSlot);
                srcSlot.OnChangeCard(tgtCard);
            }
            else
            {
                srcSlot.OnChangeCard(null);
            }
        }
Exemplo n.º 2
0
        public BattleCard(TroopMember member)
        {
            m_CardData            = new CardData();
            m_CardData.CardGuid   = member.guid;
            m_CardData.CardTempId = member.cardID;
            m_CardData.TotalHp    = member.initHp;
            m_CardData.MemberData = member;
            m_CurrentHp           = member.initHp;

            if (member.state == 1)
            {
                m_IsDead = true;
            }

            if (0 <= member.slotIndex && member.slotIndex <= 5)
            {
                m_CardType   = BattleCardType.E_BATTLE_CARD_TYPE_SELF;
                m_BattleSlot = BattleCardManager.Instance.BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][member.slotIndex];
            }
            else
            {
                m_CardType   = BattleCardType.E_BATTLE_CARD_TYPE_OTHER;
                m_BattleSlot = BattleCardManager.Instance.BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_OTHER][member.slotIndex - 6];
            }
            m_BattleSlot.SetCard(this);
            m_BattleSlot.SetTotalHp(member.initHp);
            m_BattleSlot.SetCurHp(member.initHp);

            m_StateMachine = new CardStateMachine(this);
        }
Exemplo n.º 3
0
 public void OnChangeSlot(BattleSlot slot)
 {
     m_BattleSlot = slot;
     m_BattleSlot.SetTotalHp(m_CardData.TotalHp);
     m_BattleCardObj.SetActive(true);
     m_BattleCardObj.GetComponent <CardUI>().SetCardTemplateID(m_CardData.CardTempId);
     ResetPosition();
     m_BattleCardObj.GetComponent <DraggableCard>().OnChangeSlot(slot.SlotIndex);
 }
        public bool Init(BattleCore core)
        {
            m_BattleCore = core;
            BattleSlot[] self_slots = new BattleSlot[6];
            for (int i = 0; i < 6; i++)
            {
                self_slots[i] = new BattleSlot(i);
            }
            m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF] = self_slots;

            BattleSlot[] other_slots = new BattleSlot[6];
            for (int i = 0; i < 6; i++)
            {
                other_slots[i] = new BattleSlot(i + 6);
            }
            m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_OTHER] = other_slots;

            return(true);
        }