Пример #1
0
    private void attack(Card attacker)
    {
        Control       control       = server.control;
        BattleControl battleControl = control.getBattleControl();
        int           opponent_id   = control.getOpponentId();

        if (gameObject.tag == "enemy")
        {
            if (battleControl.canAttackPlayer(attacker) &&
                server.tryAttackPlayer(attacker.getID(), attacker.getPosition()))
            {
                battleControl.directAttack(attacker, opponent_id);
            }
        }
        else
        {
            Card target = transform.GetComponent <CardGOInstance>().card;
            if (target == null)
            {
                return;
            }

            if (battleControl.canAttackCharacter(attacker, target) == false)
            {
                return;
            }

            bool can_attack_target = server.tryAttackCharacter(attacker.getID(), target.getID(), attacker.getPosition(), target.getPosition());
            if (can_attack_target)
            {
                battleControl.cardAttackCard(attacker, target);
            }
        }
    }