private static IEnumerable <Attack> ParseAttack(decimal[] damageList, int[] torpedoFlags, int[] bombFlags, int[] criticalList, bool direction, ShipInBattle[] fleet, ShipInBattle torpedoSource, ShipInBattle bombSource) { for (int i = 1; i < damageList.Length; i++) { ShipInBattle source; bool torpedo = torpedoFlags[i] != 0, bomb = bombFlags[i] != 0; if (torpedo && bomb) { source = null; } else if (torpedo) { source = torpedoSource; } else if (bomb) { source = bombSource; } else { continue; } var damage = Attack.ParseDamage(damageList[i]); (var friend, var enemy) = direction ? (source, fleet[i - 1]) : (fleet[i - 1], source);
public static void SetGiveDamage(ShipInBattle ship, decimal damage) { if (ship == null) { return; } ship.DamageGiven += (int)damage; }
private ShipInBattle FindShip(int index, ShipInBattle[] friend, ShipInBattle[] enemy) { try { if (index <= 6) return friend[index - 1]; return enemy[index - 7]; } catch { return null; } }
public AerialSupport(OldBattle battle, sortie_battle_old.airbattle api) : base(api) { if (api.api_stage1 != null) { AirControl = (AirControl)api.api_stage1.api_disp_seiku; } ShipInBattle enemytorpedo = null, enemybomb = null; enemytorpedo = battle.EnemyFleet.Where(x => x.CanAerialTorpedo).TakeIfSingle(); enemybomb = battle.EnemyFleet.Where(x => x.CanAerialBomb).TakeIfSingle(); ParseAttacks(battle, api, null, null, enemytorpedo, enemybomb); }
public JetPlaneAttack(OldBattle battle, sortie_battle_old.airbattle api, bool isSupport) : base(api) { ShipInBattle friendjet = null, enemyjet = null; if (!isSupport) { if (api.api_plane_from[0]?.Length == 1 && api.api_plane_from[0][0] > 0) { friendjet = battle.Fleet1[api.api_plane_from[0][0] - 1]; } if (api.api_plane_from.Length >= 2 && api.api_plane_from[1]?.Length == 1 && api.api_plane_from[1][0] > 0) { enemyjet = battle.EnemyFleet[api.api_plane_from[1][0] - 1]; } } ParseAttacks(battle, api, null, friendjet, null, enemyjet); }
public AerialCombat(OldBattle battle, sortie_battle_old.airbattle api) : base(api) { if (api.api_stage1 != null) { AirControl = (AirControl)api.api_stage1.api_disp_seiku; FriendTouch = Staff.Current.MasterData.EquipInfo[api.api_stage1.api_touch_plane[0]]; EnemyTouch = Staff.Current.MasterData.EquipInfo[api.api_stage1.api_touch_plane[1]]; } if (api.api_stage2?.api_air_fire != null) { AntiAir = new AntiAirCutin(battle, api.api_stage2.api_air_fire); } ShipInBattle friendtorpedo = null, friendbomb = null, enemytorpedo = null, enemybomb = null; friendtorpedo = battle.Fleet1.Where(x => x.CanAerialTorpedo).TakeIfSingle(); friendbomb = battle.Fleet1.Where(x => x.CanAerialBomb).TakeIfSingle(); enemytorpedo = battle.EnemyFleet.Where(x => x.CanAerialTorpedo).TakeIfSingle(); enemybomb = battle.EnemyFleet.Where(x => x.CanAerialBomb).TakeIfSingle(); ParseAttacks(battle, api, friendtorpedo, friendbomb, enemytorpedo, enemybomb); }
public static void SetDamage(ShipInBattle ship, decimal damage) { if (ship == null) { return; } ship.ToHP -= (int)damage; if (ship.ToHP <= 0) { if (ship.DamageControl == null) { ship.ToHP = 0; } else if (ship.DamageControl.Id == 42)//応急修理要員 { ship.ToHP = (int)(ship.MaxHP * 0.2); } else if (ship.DamageControl.Id == 43)//応急修理女神 { ship.ToHP = ship.MaxHP; } } ship.Damage += (int)damage; }
public static void SetStartHP(ShipInBattle ship, int hp) => ship.FromHP = ship.ToHP = hp;
public static void SetDamage(ShipInBattle ship, decimal damage) { if (ship == null) return; ship.ToHP -= (int)damage; if (ship.ToHP <= 0) if (ship.DamageControl == null) ship.ToHP = 0; else if (ship.DamageControl.Id == 42)//応急修理要員 ship.ToHP = (int)(ship.MaxHP * 0.2); else if (ship.DamageControl.Id == 43)//応急修理女神 ship.ToHP = ship.MaxHP; ship.Damage += (int)damage; }
private AirCombat AirBattle(sortie_battle.airbattle api, bool issupport) { if (api == null) { return(null); } AirCombat combat = new AirCombat(); ShipInBattle friendtorpedo = null, friendbomb = null, enemytorpedo = null, enemybomb = null; if (!issupport) { if (api.api_stage1 != null)//stage1一直都有吧 { combat.AirControl = (AirControl)api.api_stage1.api_disp_seiku; combat.FriendStage1 = new LimitedValue(api.api_stage1.api_f_count - api.api_stage1.api_f_lostcount, api.api_stage1.api_f_count); combat.EnemyStage1 = new LimitedValue(api.api_stage1.api_e_count - api.api_stage1.api_e_lostcount, api.api_stage1.api_e_count); } if (api.api_stage2 != null) { combat.FriendStage2 = new LimitedValue(api.api_stage2.api_f_count - api.api_stage2.api_f_lostcount, api.api_stage2.api_f_count); combat.EnemyStage2 = new LimitedValue(api.api_stage2.api_e_count - api.api_stage2.api_e_lostcount, api.api_stage2.api_e_count); } friendtorpedo = Fleet1.Where(x => x.CanAerialTorpedo).TakeIfSingle(); friendbomb = Fleet1.Where(x => x.CanAerialBomb).TakeIfSingle(); enemytorpedo = EnemyFleet.Where(x => x.CanAerialTorpedo).TakeIfSingle(); enemybomb = EnemyFleet.Where(x => x.CanAerialBomb).TakeIfSingle(); } if (api.api_stage3 != null) { if (!issupport) { Fleet1.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); } EnemyFleet.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); if (!issupport) { for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (api.api_stage3.api_frai_flag[i] != 0) { if (api.api_stage3.api_fbak_flag[i] != 0) { if (enemytorpedo == enemybomb && enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } else if (enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } else if (api.api_stage3.api_fbak_flag[i] != 0) { if (enemybomb != null) { enemybomb.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (api.api_stage3.api_erai_flag[i] != 0) { if (api.api_stage3.api_ebak_flag[i] != 0) { if (friendtorpedo == friendbomb && friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } else if (friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } else if (api.api_stage3.api_ebak_flag[i] != 0) { if (friendbomb != null) { friendbomb.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } } } } if (api.api_stage3_combined != null) { if (api.api_stage3_combined.api_fdam != null) { Fleet2?.ArrayZip(api.api_stage3_combined.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3_combined.api_fdam.Length; i++) { if (api.api_stage3_combined.api_frai_flag[i] != 0) { if (api.api_stage3_combined.api_fbak_flag[i] != 0) { if (enemytorpedo == enemybomb && enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } else if (enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } else if (api.api_stage3_combined.api_fbak_flag[i] != 0) { if (enemybomb != null) { enemybomb.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } } } if (api.api_stage3_combined.api_edam != null) { EnemyFleet2?.ArrayZip(api.api_stage3_combined.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3_combined.api_edam.Length; i++) { if (api.api_stage3_combined.api_erai_flag[i] != 0) { if (api.api_stage3_combined.api_ebak_flag[i] != 0) { if (friendtorpedo == friendbomb && friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } else if (friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } else if (api.api_stage3_combined.api_ebak_flag[i] != 0) { if (friendbomb != null) { friendbomb.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } } } } return(combat); }
protected void ParseAttacks(OldBattle battle, sortie_battle_old.airbattle api, ShipInBattle friendtorpedo, ShipInBattle friendbomb, ShipInBattle enemytorpedo, ShipInBattle enemybomb) { var result = Enumerable.Empty <Attack>(); void ParseStage3(sortie_battle_old.airbattle.stage3 stage3, ShipInBattle[] friend, ShipInBattle[] enemy) { if (stage3 == null) { return; } if (stage3.api_fdam != null) { result = result.Concat(ParseAttack(stage3.api_fdam, stage3.api_frai_flag, stage3.api_fbak_flag, stage3.api_fcl_flag, false, friend, enemytorpedo, enemybomb)); } if (stage3.api_edam != null) { result = result.Concat(ParseAttack(stage3.api_edam, stage3.api_erai_flag, stage3.api_ebak_flag, stage3.api_ecl_flag, true, enemy, friendtorpedo, friendbomb)); } } ParseStage3(api.api_stage3, battle.Fleet1, battle.EnemyFleet); ParseStage3(api.api_stage3_combined, battle.Fleet2, battle.EnemyFleet2); ApplyAttacks(result, battle); }
public static void OnEndUpdate(ShipInBattle ship) { ship.EndUpdate(); ship.IsMostDamage = false; }
private void JetAttack(sortie_battle.airbattle api) { if (api == null) { return; } ShipInBattle friendattack = null, enemyattack = null; if (api.api_plane_from[0]?.Length == 1 && api.api_plane_from[0][0] > 0) { friendattack = Fleet1[api.api_plane_from[0][0] - 1]; } if (api.api_plane_from.Length >= 2 && api.api_plane_from[1]?.Length == 1 && api.api_plane_from[1][0] > 0) { enemyattack = EnemyFleet[api.api_plane_from[1][0] - 1]; } if (api.api_stage3 != null) { if (api.api_stage3.api_edam != null) { EnemyFleet.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (friendattack != null) { friendattack.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_edam[i]; } } } if (api.api_stage3.api_fdam != null) { Fleet1.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (enemyattack != null) { enemyattack.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } } if (api.api_stage3_combined != null) { if (api.api_stage3_combined.api_fdam != null) { Fleet2?.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (enemyattack != null) { enemyattack.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } if (api.api_stage3_combined.api_edam != null) { EnemyFleet2?.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (friendattack != null) { friendattack.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_edam[i]; } } } } }
public static void SetMaxHP(ShipInBattle ship, int hp) => ship.MaxHP = hp;
public static void SetGiveDamage(ShipInBattle ship, decimal damage) { if (ship == null) return; ship.DamageGiven += (int)damage; }
private void FireAttack(sortie_battle.fire api, ShipInBattle[] fleet, ShipInBattle[] enemy) { if (api == null) return; api.api_df_list.ZipEach(api.api_damage, (x, y) => x.ZipEach(y, (a, b) => Delegates.SetDamage(FindShip(a, fleet, enemy), b))); api.api_damage.ArrayZip(api.api_at_list, 1, (x, y) => x.ForEach(d => Delegates.SetGiveDamage(FindShip(y, fleet, enemy), d))); }
private void FireAttack(sortie_battle.fire api, ShipInBattle[] fleet) => FireAttack(api, fleet, EnemyFleet);