/// <summary> /// 両軍のHPゲージを設定します。 /// </summary> private void SetHPBar(BattleData bd) { KCDatabase db = KCDatabase.Instance; bool isPractice = bd.IsPractice; bool isFriendCombined = bd.IsFriendCombined; bool isEnemyCombined = bd.IsEnemyCombined; bool isBaseAirRaid = bd.IsBaseAirRaid; bool hasFriend7thShip = bd.Initial.FriendMaxHPs.Count(hp => hp > 0) == 7; var initial = bd.Initial; var resultHPs = bd.ResultHPs; var attackDamages = bd.AttackDamages; foreach (var bar in HPBars) bar.SuspendUpdate(); void EnableHPBar(int index, int initialHP, int resultHP, int maxHP) { HPBars[index].Value = resultHP; HPBars[index].PrevValue = initialHP; HPBars[index].MaximumValue = maxHP; HPBars[index].BackColor = SystemColors.Control; HPBars[index].Visible = true; } void DisableHPBar(int index) { HPBars[index].Visible = false; } // friend main for (int i = 0; i < initial.FriendInitialHPs.Length; i++) { int refindex = BattleIndex.Get(BattleSides.FriendMain, i); if (initial.FriendInitialHPs[i] != -1) { EnableHPBar(refindex, initial.FriendInitialHPs[i], resultHPs[refindex], initial.FriendMaxHPs[i]); string name; bool isEscaped; bool isLandBase; var bar = HPBars[refindex]; if (isBaseAirRaid) { name = string.Format("第{0}基地", i + 1); isEscaped = false; isLandBase = true; bar.Text = "LB"; //note: Land Base (Landing Boat もあるらしいが考えつかなかったので) } else { ShipData ship = bd.Initial.FriendFleet.MembersInstance[i]; name = ship.NameWithLevel; isEscaped = bd.Initial.FriendFleet.EscapedShipList.Contains(ship.MasterID); isLandBase = ship.MasterShip.IsLandBase; bar.Text = Constants.GetShipClassClassification(ship.MasterShip.ShipType); } ToolTipInfo.SetToolTip(bar, string.Format ("{0}\r\nHP: ({1} → {2})/{3} ({4}) [{5}]\r\n与ダメージ: {6}\r\n\r\n{7}", name, Math.Max(bar.PrevValue, 0), Math.Max(bar.Value, 0), bar.MaximumValue, bar.Value - bar.PrevValue, Constants.GetDamageState((double)bar.Value / bar.MaximumValue, isPractice, isLandBase, isEscaped), attackDamages[refindex], bd.GetBattleDetail(refindex) )); if (isEscaped) bar.BackColor = Color.Silver; else bar.BackColor = SystemColors.Control; } else { DisableHPBar(refindex); } } // enemy main for (int i = 0; i < initial.EnemyInitialHPs.Length; i++) { int refindex = BattleIndex.Get(BattleSides.EnemyMain, i); if (initial.EnemyInitialHPs[i] != -1) { EnableHPBar(refindex, initial.EnemyInitialHPs[i], resultHPs[refindex], initial.EnemyMaxHPs[i]); ShipDataMaster ship = bd.Initial.EnemyMembersInstance[i]; var bar = HPBars[refindex]; bar.Text = Constants.GetShipClassClassification(ship.ShipType); ToolTipInfo.SetToolTip(bar, string.Format("{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n\r\n{7}", ship.NameWithClass, initial.EnemyLevels[i], Math.Max(bar.PrevValue, 0), Math.Max(bar.Value, 0), bar.MaximumValue, bar.Value - bar.PrevValue, Constants.GetDamageState((double)bar.Value / bar.MaximumValue, isPractice, ship.IsLandBase), bd.GetBattleDetail(refindex) ) ); } else { DisableHPBar(refindex); } } // friend escort if (isFriendCombined) { FleetFriendEscort.Visible = true; for (int i = 0; i < initial.FriendInitialHPsEscort.Length; i++) { int refindex = BattleIndex.Get(BattleSides.FriendEscort, i); if (initial.FriendInitialHPsEscort[i] != -1) { EnableHPBar(refindex, initial.FriendInitialHPsEscort[i], resultHPs[refindex], initial.FriendMaxHPsEscort[i]); ShipData ship = bd.Initial.FriendFleetEscort.MembersInstance[i]; bool isEscaped = bd.Initial.FriendFleetEscort.EscapedShipList.Contains(ship.MasterID); var bar = HPBars[refindex]; bar.Text = Constants.GetShipClassClassification(ship.MasterShip.ShipType); ToolTipInfo.SetToolTip(bar, string.Format( "{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n与ダメージ: {7}\r\n\r\n{8}", ship.MasterShip.NameWithClass, ship.Level, Math.Max(bar.PrevValue, 0), Math.Max(bar.Value, 0), bar.MaximumValue, bar.Value - bar.PrevValue, Constants.GetDamageState((double)bar.Value / bar.MaximumValue, isPractice, ship.MasterShip.IsLandBase, isEscaped), attackDamages[refindex], bd.GetBattleDetail(refindex) )); if (isEscaped) bar.BackColor = Color.Silver; else bar.BackColor = SystemColors.Control; } else { DisableHPBar(refindex); } } } else { FleetFriendEscort.Visible = false; foreach (var i in BattleIndex.FriendEscort.Skip(Math.Max(bd.Initial.FriendFleet.Members.Count - 6, 0))) DisableHPBar(i); } MoveHPBar(hasFriend7thShip); // enemy escort if (isEnemyCombined) { FleetEnemyEscort.Visible = true; for (int i = 0; i < 6; i++) { int refindex = BattleIndex.Get(BattleSides.EnemyEscort, i); if (initial.EnemyInitialHPsEscort[i] != -1) { EnableHPBar(refindex, initial.EnemyInitialHPsEscort[i], resultHPs[refindex], initial.EnemyMaxHPsEscort[i]); ShipDataMaster ship = bd.Initial.EnemyMembersEscortInstance[i]; var bar = HPBars[refindex]; bar.Text = Constants.GetShipClassClassification(ship.ShipType); ToolTipInfo.SetToolTip(bar, string.Format("{0} Lv. {1}\r\nHP: ({2} → {3})/{4} ({5}) [{6}]\r\n\r\n{7}", ship.NameWithClass, bd.Initial.EnemyLevelsEscort[i], Math.Max(bar.PrevValue, 0), Math.Max(bar.Value, 0), bar.MaximumValue, bar.Value - bar.PrevValue, Constants.GetDamageState((double)bar.Value / bar.MaximumValue, isPractice, ship.IsLandBase), bd.GetBattleDetail(refindex) ) ); } else { DisableHPBar(refindex); } } } else { FleetEnemyEscort.Visible = false; foreach (var i in BattleIndex.EnemyEscort) DisableHPBar(i); } if ((isFriendCombined || (hasFriend7thShip && !Utility.Configuration.Config.FormBattle.Display7thAsSingleLine)) && isEnemyCombined) { foreach (var bar in HPBars) { bar.Size = SmallBarSize; bar.Text = null; } } else { bool showShipType = Utility.Configuration.Config.FormBattle.ShowShipTypeInHPBar; foreach (var bar in HPBars) { bar.Size = DefaultBarSize; if (!showShipType) bar.Text = "HP:"; } } { // support PhaseSupport support = null; if (bd is BattleDayFromNight bddn) { if (bddn.NightSupport?.IsAvailable ?? false) support = bddn.NightSupport; } if (support == null) support = bd.Support; if (support?.IsAvailable ?? false) { switch (support.SupportFlag) { case 1: FleetFriend.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedTorpedo; break; case 2: FleetFriend.ImageIndex = (int)ResourceManager.EquipmentContent.MainGunL; break; case 3: FleetFriend.ImageIndex = (int)ResourceManager.EquipmentContent.Torpedo; break; case 4: FleetFriend.ImageIndex = (int)ResourceManager.EquipmentContent.DepthCharge; break; default: FleetFriend.ImageIndex = (int)ResourceManager.EquipmentContent.Unknown; break; } FleetFriend.ImageAlign = ContentAlignment.MiddleLeft; ToolTipInfo.SetToolTip(FleetFriend, "支援攻撃\r\n" + support.GetBattleDetail()); if ((isFriendCombined || hasFriend7thShip) && isEnemyCombined) FleetFriend.Text = "自軍"; else FleetFriend.Text = "自軍艦隊"; } else { FleetFriend.ImageIndex = -1; FleetFriend.ImageAlign = ContentAlignment.MiddleCenter; FleetFriend.Text = "自軍艦隊"; ToolTipInfo.SetToolTip(FleetFriend, null); } } if (bd.Initial.IsBossDamaged) HPBars[BattleIndex.EnemyMain1].BackColor = Color.MistyRose; if (!isBaseAirRaid) { foreach (int i in bd.MVPShipIndexes) HPBars[BattleIndex.Get(BattleSides.FriendMain, i)].BackColor = Color.Moccasin; if (isFriendCombined) { foreach (int i in bd.MVPShipCombinedIndexes) HPBars[BattleIndex.Get(BattleSides.FriendEscort, i)].BackColor = Color.Moccasin; } } foreach (var bar in HPBars) bar.ResumeUpdate(); }