-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix concealed enemy spotting - Implement indirect fire
- Loading branch information
layagyasz
committed
Aug 25, 2017
1 parent
33a4d32
commit 1e0a64d
Showing
15 changed files
with
211 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace PanzerBlitz | ||
{ | ||
public class AttackFactorCalculation | ||
{ | ||
public readonly int Attack; | ||
public readonly List<AttackFactorCalculationFactor> Factors; | ||
public int Attack { get; private set; } | ||
public List<AttackFactorCalculationFactor> Factors { get; private set; } | ||
|
||
public AttackFactorCalculation(int Attack, List<AttackFactorCalculationFactor> Factors) | ||
public AttackFactorCalculation(int Attack, IEnumerable<AttackFactorCalculationFactor> Factors) | ||
{ | ||
this.Attack = Attack; | ||
this.Factors = Factors; | ||
this.Factors = Factors.ToList(); | ||
} | ||
|
||
public AttackFactorCalculation(Unit Unit, AttackMethod AttackMethod, bool EnemyArmored, LineOfSight LineOfSight) | ||
{ | ||
if (AttackMethod == AttackMethod.NORMAL_FIRE) GetNormalAttack(Unit, EnemyArmored, LineOfSight); | ||
else | ||
{ | ||
if (Unit.CanAttack(AttackMethod, EnemyArmored, LineOfSight) != NoSingleAttackReason.NONE) | ||
{ | ||
Attack = 0; | ||
Factors = new List<AttackFactorCalculationFactor> { AttackFactorCalculationFactor.CANNOT_ATTACK }; | ||
} | ||
Attack = Unit.Configuration.Attack; | ||
Factors = new List<AttackFactorCalculationFactor>(); | ||
} | ||
} | ||
|
||
void GetNormalAttack(Unit Unit, bool EnemyArmored, LineOfSight LineOfSight) | ||
{ | ||
if (Unit.CanAttack(AttackMethod.NORMAL_FIRE, EnemyArmored, LineOfSight) != NoSingleAttackReason.NONE) | ||
{ | ||
Attack = 0; | ||
Factors = new List<AttackFactorCalculationFactor> { AttackFactorCalculationFactor.CANNOT_ATTACK }; | ||
return; | ||
} | ||
|
||
Factors = new List<AttackFactorCalculationFactor>(); | ||
Attack = Unit.Configuration.Attack; | ||
if (LineOfSight.Initial.Elevation < LineOfSight.Final.Elevation) | ||
{ | ||
Attack /= 2; | ||
Factors.Add(AttackFactorCalculationFactor.ELEVATION); | ||
} | ||
|
||
if (EnemyArmored) | ||
{ | ||
int HalfRange = Unit.Configuration.Range / 2; | ||
if (Unit.Configuration.WeaponClass == WeaponClass.HIGH_EXPLOSIVE | ||
|| Unit.Configuration.WeaponClass == WeaponClass.MORTAR) | ||
{ | ||
if (LineOfSight.Range > HalfRange) | ||
{ | ||
Attack /= 2; | ||
Factors.Add(AttackFactorCalculationFactor.ARMOR_RANGE); | ||
} | ||
} | ||
else if (Unit.Configuration.WeaponClass == WeaponClass.ANTI_ARMOR) | ||
{ | ||
if (LineOfSight.Range <= HalfRange) | ||
{ | ||
Attack *= 2; | ||
Factors.Add(AttackFactorCalculationFactor.ANTI_ARMOR_RANGE); | ||
} | ||
} | ||
} | ||
else if (Unit.Configuration.WeaponClass == WeaponClass.ANTI_ARMOR && !EnemyArmored) | ||
{ | ||
Attack /= 2; | ||
Factors.Add(AttackFactorCalculationFactor.NOT_ARMORED); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.