Exemple #1
0
 public AimAction(BattleSoldier soldier, BattleSoldier target, RangedWeapon weapon, ConcurrentQueue <string> log)
 {
     _soldier = soldier;
     _target  = target;
     _weapon  = weapon;
     _log     = log;
 }
Exemple #2
0
 public MoveAction(BattleSoldier soldier, BattleGrid grid, Tuple <int, int> newLocation, ConcurrentBag <MoveResolution> resultList)
 {
     _soldier     = soldier;
     _grid        = grid;
     _newLocation = newLocation;
     _resultList  = resultList;
 }
 public WoundResolution(BattleSoldier inflicter, WeaponTemplate weapon, BattleSoldier sufferer, float damage, HitLocation hitLocation)
 {
     Inflicter   = inflicter;
     Weapon      = weapon;
     Suffererer  = sufferer;
     Damage      = damage;
     HitLocation = hitLocation;
 }
Exemple #4
0
 public ShootAction(BattleSoldier shooter, RangedWeapon weapon, BattleSoldier target, float range, int numberOfShots, bool useBulk, ConcurrentBag <WoundResolution> resultList, ConcurrentQueue <string> log)
 {
     _soldier       = shooter;
     _weapon        = weapon;
     _target        = target;
     _range         = range;
     _numberOfShots = numberOfShots;
     _useBulk       = useBulk;
     _resultList    = resultList;
     _log           = log;
 }
Exemple #5
0
 private void RemoveSoldier(BattleSoldier soldier, BattleSquad squad)
 {
     squad.RemoveSoldier(soldier);
     _grid.RemoveSoldier(soldier.Soldier.Id);
     BattleView.RemoveSoldier(soldier.Soldier.Id);
     _soldierBattleSquadMap.Remove(soldier.Soldier.Id);
     if (squad.Soldiers.Count == 0)
     {
         RemoveSquad(squad);
     }
 }
Exemple #6
0
 public MeleeAttackAction(BattleSoldier attacker, BattleSoldier target,
                          MeleeWeapon weapon, bool didMove,
                          ConcurrentBag <WoundResolution> resultList,
                          ConcurrentQueue <string> log)
 {
     _attacker   = attacker;
     _target     = target;
     _weapon     = weapon;
     _didMove    = didMove;
     _resultList = resultList;
     _log        = log;
 }
Exemple #7
0
 private void WoundResolver_OnSoldierFall(BattleSoldier fallenSoldier, BattleSoldier inflicter, WeaponTemplate weapon)
 {
     _casualtyMap[fallenSoldier.Soldier.Id] = fallenSoldier;
     if (!fallenSoldier.BattleSquad.IsPlayerSquad)
     {
         // give the inflicter credit for downing this enemy
         // WARNING: this will lead to multi-counting in some cases
         // I may later try to divide credit, but having multiple soldiers
         // claim credit feels pseudo-realistic for now
         CreditSoldierForKill(inflicter, weapon);
     }
 }
Exemple #8
0
        private static string GetSoldierDetails(BattleSoldier soldier)
        {
            string report = soldier.Soldier.Name + "\n";

            foreach (RangedWeapon weapon in soldier.RangedWeapons)
            {
                report += weapon.Template.Name + "\n";
            }
            report += soldier.Armor.Template.Name + "\n";
            foreach (HitLocation hl in soldier.Soldier.Body.HitLocations)
            {
                if (hl.Wounds.WoundTotal != 0)
                {
                    report += hl.ToString() + "\n";
                }
            }
            report += "\n";
            return(report);
        }
Exemple #9
0
 private void WoundResolver_OnSoldierDeath(BattleSoldier casualty, BattleSoldier inflicter, WeaponTemplate weapon)
 {
     _casualtyMap[casualty.Soldier.Id] = casualty;
     if (casualty.BattleSquad.IsPlayerSquad)
     {
         // add death note to soldier history, though we currently just delete it
         // we'll probably want it later
         GameSettings.Chapter.PlayerSoldierMap[casualty.Soldier.Id]
         .AddEntryToHistory($"Killed in battle with the {_opposingFaction.Name} by a {weapon.Name}");
     }
     else
     {
         // give the inflicter credit for downing this enemy
         // WARNING: this will lead to multi-counting in some cases
         // I may later try to divide credit, but having multiple soldiers
         // claim credit feels pseudo-realistic for now
         CreditSoldierForKill(inflicter, weapon);
     }
 }
Exemple #10
0
        public void BattleView_OnSoldierPointerEnter(int soldierId)
        {
            BattleSquad battleSquad = _soldierBattleSquadMap[soldierId];

            if (_hoveredBattleSquad != null &&
                _hoveredBattleSquad.Id != battleSquad.Id &&
                battleSquad.Id != _selectedBattleSquad?.Id)
            {
                BattleView.HighlightSoldiers(_hoveredBattleSquad.Soldiers
                                             .Select(s => s.Soldier.Id),
                                             false, Color.clear);
            }

            if (battleSquad.Id != _selectedBattleSquad?.Id)
            {
                BattleView.HighlightSoldiers(battleSquad.Soldiers.Select(s => s.Soldier.Id),
                                             true, Color.cyan);
                _hoveredBattleSquad = battleSquad;
            }
            BattleSoldier soldier = battleSquad.Soldiers.First(s => s.Soldier.Id == soldierId);

            Tooltip.ShowTooltip(GetSoldierDetails(soldier));
        }
Exemple #11
0
        private HitLocation DetermineHitLocation(BattleSoldier soldier)
        {
            // we're using the "lottery ball" approach to randomness here, where each point of probability
            // for each available body party defines the size of the random linear distribution
            // TODO: factor in cover/body position
            //
            int roll = RNG.GetIntBelowMax(0, soldier.Soldier.Body.TotalProbabilityMap[soldier.Stance]);

            foreach (HitLocation location in soldier.Soldier.Body.HitLocations)
            {
                int locationChance = location.Template.HitProbabilityMap[(int)soldier.Stance];
                if (roll < locationChance)
                {
                    return(location);
                }
                else
                {
                    // this is basically an easy iterative way to figure out which body part on the "chart" the roll matches
                    roll -= locationChance;
                }
            }
            // this should never happen
            throw new InvalidOperationException("Could not determine a hit location");
        }
 public ReadyRangedWeaponAction(BattleSoldier soldier, RangedWeapon weapon)
 {
     _soldier = soldier;
     _weapon  = weapon;
 }
 public ReadyMeleeWeaponAction(BattleSoldier soldier, MeleeWeapon weapon)
 {
     _soldier = soldier;
     _weapon  = weapon;
 }
Exemple #14
0
 public MoveResolution(BattleSoldier soldier, BattleGrid grid, Tuple <int, int> newLocation)
 {
     Soldier     = soldier;
     Grid        = grid;
     NewLocation = newLocation;
 }
Exemple #15
0
 private void CreditSoldierForKill(BattleSoldier inflicter, WeaponTemplate weapon)
 {
     GameSettings.Chapter.PlayerSoldierMap[inflicter.Soldier.Id]
     .AddKill(_opposingFaction.Id, weapon.Id);
     inflicter.EnemiesTakenDown++;
 }
Exemple #16
0
 private void MoveResolver_OnRetreat(BattleSoldier soldier)
 {
     Log(false, "<b>" + soldier.Soldier.Name + " has retreated from the battlefield</b>");
     _casualtyMap[soldier.Soldier.Id] = soldier;
 }