public override void LoadFromRequest(string apiname, Dictionary <string, string> data) { base.LoadFromRequest(apiname, data); KCDatabase db = KCDatabase.Instance; switch (apiname) { case "api_req_kousyou/destroyship": { for (int i = 0; i < Slot.Count; i++) { if (Slot[i] == -1) { continue; } db.Equipments.Remove(Slot[i]); } } break; case "api_req_kaisou/open_exslot": ExpansionSlot = -1; break; } }
public override void LoadFromRequest(string apiname, Dictionary <string, string> data) { base.LoadFromRequest(apiname, data); KCDatabase db = KCDatabase.Instance; switch (apiname) { case "api_req_kousyou/destroyship": { for (int i = 0; i < _slot.Length; i++) { if (_slot[i] == -1) { continue; } db.Equipments.Remove(_slot[i]); } } break; } }
/// <summary> /// 艦隊の状態の情報をラベルに適用します。 /// </summary> /// <param name="fleet">艦隊データ。</param> /// <param name="label">適用するラベル。</param> /// <param name="tooltip">適用するツールチップ。</param> /// <param name="prevstate">前回の状態。</param> /// <param name="timer">日時。</param> /// <returns>艦隊の状態を表す定数。</returns> public static FleetStates UpdateFleetState(FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer) { KCDatabase db = KCDatabase.Instance; //初期化 tooltip.SetToolTip(label, null); label.BackColor = Color.Transparent; //所属艦なし if (fleet == null || fleet.Members.Count(id => id != -1) == 0) { label.Text = FleetRes.NoShips; label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip; return(FleetStates.NoShip); } { //入渠中 long ntime = db.Docks.Values.Max( dock => { if (dock.State == 1 && fleet.Members.Count((id => id == dock.ShipID)) > 0) { return(dock.CompletionTime.Ticks); } else { return(0); } } ); if (ntime > 0) //入渠中 { timer = new DateTime(ntime); label.Text = FleetRes.Docking + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking; tooltip.SetToolTip(label, FleetRes.CompletionTime + ": " + timer); return(FleetStates.Docking); } } if (fleet.IsInSortie) { //大破出撃中 if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = FleetRes.CriticalDamageAdvance; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged; return(FleetStates.SortieDamaged); } else //出撃中 { label.Text = FleetRes.OnSortie; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie; return(FleetStates.Sortie); } } //遠征中 if (fleet.ExpeditionState != 0) { timer = fleet.ExpeditionTime; label.Text = FleetRes.OnExped + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition; tooltip.SetToolTip(label, string.Format("{0} : {1}\r\n" + FleetRes.CompletionTime + " : {2}", KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID, KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name, timer)); return(FleetStates.Expedition); } //大破艦あり if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = FleetRes.CriticallyDamagedShip; label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged; //label.BackColor = Color.LightCoral; return(FleetStates.Damaged); } //泊地修理中 { if (fleet.CanAnchorageRepairing && fleet.MembersInstance.Take(2 + KCDatabase.Instance.Ships[fleet[0]].SlotInstanceMaster.Count(eq => eq != null && eq.CategoryType == 31)) .Any(s => s != null && s.HPRate <1.0 && s.HPRate> 0.5 && s.RepairingDockID == -1)) { label.Text = FleetRes.AnchorageRepairing + DateTimeHelper.ToTimeElapsedString(KCDatabase.Instance.Fleet.AnchorageRepairingTimer); label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing; tooltip.SetToolTip(label, string.Format(FleetRes.StartTime + ": {0}", KCDatabase.Instance.Fleet.AnchorageRepairingTimer)); return(FleetStates.AnchorageRepairing); } } //未補給 { int fuel = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.FuelMax - ship.Fuel) * (ship.IsMarried ? 0.85 : 1.00))); int ammo = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.AmmoMax - ship.Ammo) * (ship.IsMarried ? 0.85 : 1.00))); int aircraft = fleet.MembersInstance.Sum( ship => { if (ship == null) { return(0); } else { int c = 0; for (int i = 0; i < ship.Slot.Count; i++) { c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i]; } return(c); } }); int bauxite = aircraft * 5; if (fuel > 0 || ammo > 0 || bauxite > 0) { label.Text = FleetRes.SupplyNeeded; label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished; tooltip.SetToolTip(label, string.Format(FleetRes.ResupplyTooltip, fuel, ammo, bauxite, aircraft)); return(FleetStates.NotReplenished); } } //疲労 { int cond = fleet.MembersInstance.Min(s => s == null ? 100 : s.Condition); if (cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null) { timer = (DateTime)fleet.ConditionTime; label.Text = FleetRes.Fatigued + DateTimeHelper.ToTimeRemainString(timer); if (cond < 20) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired; } else if (cond < 30) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired; } else { label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired; } tooltip.SetToolTip(label, string.Format(FleetRes.EstimatedRecoveryTime + ": {0}", timer)); return(FleetStates.Tired); } else if (cond >= 50) //戦意高揚 { label.Text = FleetRes.FightingSpiritHigh; label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle; tooltip.SetToolTip(label, string.Format(FleetRes.SparkledTooltip, cond, Math.Ceiling((cond - 49) / 3.0))); return(FleetStates.Sparkled); } } //出撃可能! { label.Text = FleetRes.ReadyToSortie; label.ImageIndex = (int)ResourceManager.IconContent.FleetReady; return(FleetStates.Ready); } }
/// <summary> /// 艦隊の状態の情報をラベルに適用します。 /// </summary> /// <param name="fleet">艦隊データ。</param> /// <param name="label">適用するラベル。</param> /// <param name="tooltip">適用するツールチップ。</param> /// <param name="prevstate">前回の状態。</param> /// <param name="timer">日時。</param> /// <returns>艦隊の状態を表す定数。</returns> public static FleetStates UpdateFleetState(FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer) { KCDatabase db = KCDatabase.Instance; //初期化 tooltip.SetToolTip(label, null); label.BackColor = Color.Transparent; //所属艦なし if (fleet == null || fleet.Members.Count(id => id != -1) == 0) { label.Text = "所属艦なし"; label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip; return(FleetStates.NoShip); } { //入渠中 long ntime = db.Docks.Values.Max( dock => { if (dock.State == 1 && fleet.Members.Count((id => id == dock.ShipID)) > 0) { return(dock.CompletionTime.Ticks); } else { return(0); } } ); if (ntime > 0) //入渠中 { timer = new DateTime(ntime); label.Text = "入渠中 " + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking; tooltip.SetToolTip(label, "完了日時 : " + timer); return(FleetStates.Docking); } } if (fleet.IsInSortie) { //大破出撃中 if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = "!!大破進撃中!!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged; return(FleetStates.SortieDamaged); } else //出撃中 { label.Text = "出撃中"; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie; return(FleetStates.Sortie); } } //遠征中 if (fleet.ExpeditionState != 0) { timer = fleet.ExpeditionTime; label.Text = "遠征中 " + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition; tooltip.SetToolTip(label, string.Format("{0} : {1}\r\n完了日時 : {2}", KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID, KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name, timer)); return(FleetStates.Expedition); } //大破艦あり if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = "大破艦あり!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged; //label.BackColor = Color.LightCoral; return(FleetStates.Damaged); } //泊地修理中 { if (fleet.IsAnchorageRepairing) { label.Text = "泊地修理中 " + DateTimeHelper.ToTimeElapsedString(KCDatabase.Instance.Fleet.AnchorageRepairingTimer); label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing; tooltip.SetToolTip(label, string.Format("開始日時 : {0}", KCDatabase.Instance.Fleet.AnchorageRepairingTimer)); return(FleetStates.AnchorageRepairing); } } //未補給 { int fuel = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.MasterShip.Fuel - ship.Fuel) * (ship.IsMarried ? 0.85 : 1.00))); int ammo = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.MasterShip.Ammo - ship.Ammo) * (ship.IsMarried ? 0.85 : 1.00))); int aircraft = fleet.MembersInstance.Sum( ship => { if (ship == null) { return(0); } else { int c = 0; for (int i = 0; i < ship.Slot.Count; i++) { c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i]; } return(c); } }); int bauxite = aircraft * 5; if (fuel > 0 || ammo > 0 || bauxite > 0) { label.Text = "未補給"; label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished; tooltip.SetToolTip(label, string.Format("燃 : {0}\r\n弾 : {1}\r\nボ : {2} ({3}機)", fuel, ammo, bauxite, aircraft)); return(FleetStates.NotReplenished); } } //疲労 { int cond = fleet.MembersInstance.Min(s => s == null ? 100 : s.Condition); if (cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null) { timer = (DateTime)fleet.ConditionTime; label.Text = "疲労 " + DateTimeHelper.ToTimeRemainString(timer); if (cond < 20) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired; } else if (cond < 30) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired; } else { label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired; } tooltip.SetToolTip(label, string.Format("回復目安日時: {0}", timer)); return(FleetStates.Tired); } else if (cond >= 50) //戦意高揚 { label.Text = "戦意高揚!"; label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle; tooltip.SetToolTip(label, string.Format("最低cond: {0}\r\nあと {1} 回遠征可能", cond, Math.Ceiling((cond - 49) / 3.0))); return(FleetStates.Sparkled); } } //出撃可能! { label.Text = "出撃可能!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetReady; return(FleetStates.Ready); } }
/// <summary> /// 艦隊の状態の情報をラベルに適用します。 /// </summary> /// <param name="fleet">艦隊データ。</param> /// <param name="label">適用するラベル。</param> /// <param name="tooltip">適用するツールチップ。</param> /// <param name="prevstate">前回の状態。</param> /// <param name="timer">日時。</param> /// <returns>艦隊の状態を表す定数。</returns> public static FleetStates UpdateFleetState(FleetData fleet, ImageLabel label, ToolTip tooltip, FleetStates prevstate, ref DateTime timer) { KCDatabase db = KCDatabase.Instance; //初期化 tooltip.SetToolTip(label, null); label.BackColor = Color.Transparent; //所属艦なし if (fleet == null || fleet.Members.Count(id => id != -1) == 0) { label.Text = "所属艦なし"; label.ImageIndex = (int)ResourceManager.IconContent.FleetNoShip; return(FleetStates.NoShip); } { //入渠中 long ntime = db.Docks.Values.Max( dock => { if (dock.State == 1 && fleet.Members.Count((id => id == dock.ShipID)) > 0) { return(dock.CompletionTime.Ticks); } else { return(0); } } ); if (ntime > 0) //入渠中 { timer = new DateTime(ntime); label.Text = "入渠中 " + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetDocking; tooltip.SetToolTip(label, "完了日時 : " + DateTimeHelper.TimeToCSVString(timer)); return(FleetStates.Docking); } } if (fleet.IsInSortie) { //大破出撃中 if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = "!!大破進撃中!!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortieDamaged; return(FleetStates.SortieDamaged); } else //出撃中 { label.Text = "出撃中"; label.ImageIndex = (int)ResourceManager.IconContent.FleetSortie; return(FleetStates.Sortie); } } //遠征中 if (fleet.ExpeditionState != 0) { timer = fleet.ExpeditionTime; label.Text = "遠征中 " + DateTimeHelper.ToTimeRemainString(timer); label.ImageIndex = (int)ResourceManager.IconContent.FleetExpedition; tooltip.SetToolTip(label, string.Format("{0} : {1}\r\n完了日時 : {2}", KCDatabase.Instance.Mission[fleet.ExpeditionDestination].ID, KCDatabase.Instance.Mission[fleet.ExpeditionDestination].Name, DateTimeHelper.TimeToCSVString(timer))); return(FleetStates.Expedition); } //大破艦あり if (fleet.MembersInstance.Count(s => (s != null && !fleet.EscapedShipList.Contains(s.MasterID) && (double)s.HPCurrent / s.HPMax <= 0.25) ) > 0) { label.Text = "大破艦あり!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetDamaged; //label.BackColor = Color.LightCoral; return(FleetStates.Damaged); } //泊地修理中 { if (fleet.CanAnchorageRepairing && fleet.MembersInstance.Take(2 + KCDatabase.Instance.Ships[fleet[0]].SlotInstanceMaster.Count(eq => eq != null && eq.CategoryType == 31)) .Any(s => s != null && s.HPRate <1.0 && s.HPRate> 0.5 && s.RepairingDockID == -1)) { label.Text = "泊地修理中 " + DateTimeHelper.ToTimeElapsedString(KCDatabase.Instance.Fleet.AnchorageRepairingTimer); label.ImageIndex = (int)ResourceManager.IconContent.FleetAnchorageRepairing; StringBuilder sb = new StringBuilder(); sb.AppendFormat("開始日時 : {0}\r\n修理時間 :\r\n", DateTimeHelper.TimeToCSVString(KCDatabase.Instance.Fleet.AnchorageRepairingTimer)); for (int i = 0; i < fleet.Members.Count; i++) { var ship = fleet.MembersInstance[i]; if (ship != null && ship.HPRate < 1.0) { var totaltime = DateTimeHelper.FromAPITimeSpan(ship.RepairTime); var unittime = Calculator.CalculateDockingUnitTime(ship); sb.AppendFormat("#{0} : {1:00}:{2:00}:{3:00} @ {4:00}:{5:00}:{6:00} x -{7} HP\r\n", i + 1, (int)totaltime.TotalHours, totaltime.Minutes, totaltime.Seconds, (int)unittime.TotalHours, unittime.Minutes, unittime.Seconds, ship.HPMax - ship.HPCurrent ); } else { sb.Append("#").Append(i + 1).Append(" : ----\r\n"); } } tooltip.SetToolTip(label, sb.ToString()); return(FleetStates.AnchorageRepairing); } } //未補給 { int fuel = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.FuelMax - ship.Fuel) * (ship.IsMarried ? 0.85 : 1.00))); int ammo = fleet.MembersInstance.Sum(ship => ship == null ? 0 : (int)((ship.AmmoMax - ship.Ammo) * (ship.IsMarried ? 0.85 : 1.00))); int aircraft = fleet.MembersInstance.Sum( ship => { if (ship == null) { return(0); } else { int c = 0; for (int i = 0; i < ship.Slot.Count; i++) { c += ship.MasterShip.Aircraft[i] - ship.Aircraft[i]; } return(c); } }); int bauxite = aircraft * 5; if (fuel > 0 || ammo > 0 || bauxite > 0) { label.Text = "未補給"; label.ImageIndex = (int)ResourceManager.IconContent.FleetNotReplenished; tooltip.SetToolTip(label, string.Format("燃 : {0}\r\n弾 : {1}\r\nボ : {2} ({3}機)", fuel, ammo, bauxite, aircraft)); return(FleetStates.NotReplenished); } } //疲労 { int cond = fleet.MembersInstance.Min(s => s == null ? 100 : s.Condition); if (cond < Configuration.Config.Control.ConditionBorder && fleet.ConditionTime != null) { timer = (DateTime)fleet.ConditionTime; label.Text = "疲労 " + DateTimeHelper.ToTimeRemainString(timer); if (cond < 20) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionVeryTired; } else if (cond < 30) { label.ImageIndex = (int)ResourceManager.IconContent.ConditionTired; } else { label.ImageIndex = (int)ResourceManager.IconContent.ConditionLittleTired; } tooltip.SetToolTip(label, string.Format("回復目安日時: {0}", DateTimeHelper.TimeToCSVString(timer))); return(FleetStates.Tired); } else if (cond >= 50) //戦意高揚 { label.Text = "戦意高揚!"; label.ImageIndex = (int)ResourceManager.IconContent.ConditionSparkle; tooltip.SetToolTip(label, string.Format("最低cond: {0}\r\nあと {1} 回遠征可能", cond, Math.Ceiling((cond - 49) / 3.0))); return(FleetStates.Sparkled); } } //出撃可能! { label.Text = "出撃可能!"; label.ImageIndex = (int)ResourceManager.IconContent.FleetReady; return(FleetStates.Ready); } }