Exemplo n.º 1
0
        private bool InAttackRange(BattleFormation attacker, BattleFormation target, Weapon tool, float attackDistance)
        {
            var toFirstRow = Math.Abs(target.DistanceToCenter - attacker.DistanceToCenter);

            if (toFirstRow > tool.Far || toFirstRow + attacker.Length + target.Length < tool.Near)
            {
                throw new AttackBreaker("Out of range bounds");
            }
            if (attacker.RangeResource < 1)
            {
                throw new AttackBreaker("The shells are exhausted");
            }
            // TODO Учесть размеры строя лучников и целевого строя
            if (attackDistance < toFirstRow)
            {
                throw new AttackBreaker("Very early");
            }

            return(true);
        }
Exemplo n.º 2
0
        public Batalia(int basicId, Cell battleground, Army inserters)
        {
            Battleground = battleground;
            Times        = 0;
            var side = battleground.Camp;

            if (side != null && side.Owner.Id != inserters.Owner.Id && side.Strength > 0 && side.Active)
            {
                Left  = new BattleFormation(basicId + 1, battleground.Camp, true);
                Right = new BattleFormation(basicId + 2, inserters, false);
                Is    = BattleType.FieldFight;
                return;
            }
            side = battleground.Settling?.Guard;
            if (side != null && side.Owner.Id != inserters.Owner.Id && inserters.Strength > 0 && inserters.Active)
            {
                Left  = new BattleFormation(basicId + 1, side, true);
                Right = new BattleFormation(basicId + 2, inserters, false);
                Is    = BattleType.StormDwelling;
                return;
            }
            throw new ApplicationException("");
        }