Пример #1
0
        /// <summary>
        /// 进行攻击
        /// </summary>
        public void Attack()
        {
            //直接攻击
            if (beAttackedCard == null)
            {
                attackCard.Attack();
                ChangeLifeEffectProcess changeLifeEffectProcess = new ChangeLifeEffectProcess(-attackCard.GetAttackValue(), ChangeLifeType.Battle, attackCard.GetDuelCardScript().GetOwner().GetOpponentPlayer());
                attackCard.GetDuelCardScript().GetOwner().GetOpponentPlayer().AddEffectProcess(changeLifeEffectProcess);
                return;
            }
            //怪兽间攻击
            attackCard.Attack();
            int  card2Value   = 0;
            bool card2Defense = false;

            if (beAttackedCard.GetCardGameState() == CardGameState.FrontAttack)
            {
                card2Value = beAttackedCard.GetAttackValue();
            }
            else if (beAttackedCard.GetCardGameState() == CardGameState.FrontDefense ||
                     beAttackedCard.GetCardGameState() == CardGameState.Back)
            {
                card2Value   = beAttackedCard.GetDefenseValue();
                card2Defense = true;
            }
            int differenceValue = attackCard.GetAttackValue() - card2Value;

            if (differenceValue == 0)
            {
                if (!card2Defense)
                {
                    SendCardToTomb(attackCard, MoveCardToTombType.Battle);
                    SendCardToTomb(beAttackedCard, MoveCardToTombType.Battle);
                }
            }
            else if (differenceValue > 0)
            {
                if (!card2Defense || attackCard.GetCanPenetrateDefense())
                {
                    ChangeLifeEffectProcess changeLifeEffectProcess = new ChangeLifeEffectProcess(-differenceValue, ChangeLifeType.Battle, beAttackedCard.GetDuelCardScript().GetOwner());
                    beAttackedCard.GetDuelCardScript().GetOwner().AddEffectProcess(changeLifeEffectProcess);
                }
                SendCardToTomb(beAttackedCard, MoveCardToTombType.Battle);
            }
            else
            {
                ChangeLifeEffectProcess changeLifeEffectProcess = new ChangeLifeEffectProcess(differenceValue, ChangeLifeType.Battle, attackCard.GetDuelCardScript().GetOwner());
                attackCard.GetDuelCardScript().GetOwner().AddEffectProcess(changeLifeEffectProcess);
                if (!card2Defense)
                {
                    SendCardToTomb(attackCard, MoveCardToTombType.Battle);
                }
            }
        }