Beispiel #1
0
    public static void Attack(Fighter attacker, Fighter target, bool doAnimations)
    {
        IsBattling = true;

        int spd1 = StatsCalc.AttackSpeed(attacker.Unit.stats.speed, attacker.Weapon.weight, attacker.Unit.stats.constitution);
        int spd2 = StatsCalc.AttackSpeed(target.Unit.stats.speed, target.Weapon.weight, target.Unit.stats.constitution);

        bool repeated        = StatsCalc.RepeatedAttack(spd1, spd2);
        bool repeatedCounter = StatsCalc.RepeatedAttack(spd2, spd1);
        bool counter         = false;

        Cell[] counterArea = Map.GetExtendedArea(new Cell[1] {
            Map.UnitTile(target)
        }, target.Weapon.range, target.Weapon.rangedClosedSet, target.Weapon.closedSetMin);

        foreach (Cell c in counterArea)
        {
            if (c == Map.UnitTile(attacker))
            {
                counter = true;
                break;
            }
        }

        Offensive atk1 = new Offensive(attacker, target);
        Offensive cnt1 = null;

        Offensive atk2 = null;
        Offensive cnt2 = null;

        if (counter)
        {
            cnt1 = new Offensive(target, attacker)
            {
                IsCounter = true
            };
        }
        if (repeated)
        {
            atk2 = new Offensive(attacker, target, true);
        }
        if (repeatedCounter)
        {
            cnt2           = new Offensive(target, attacker, true);
            cnt1.IsCounter = true;
        }

        instance.StartCoroutine(DoAttacks(
                                    new Offensive[4]
        {
            atk1,
            cnt1,
            atk2,
            cnt2
        }
                                    ));
    }