本文整理汇总了C#中Ship.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.Where方法的具体用法?C# Ship.Where怎么用?C# Ship.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateShips
private void UpdateShips(Ship[] ships)
{
this.originalShips = ships;
this.Ships = ships.Where(x => x != null).ToArray();
this.State.Calculate();
this.State.Update();
}
示例2: Update
/// <summary>
/// 艦隊に編成されている艦娘の状態から、再出撃可能かどうかを判定します。
/// </summary>
/// <param name="ships">艦隊に編成されている艦娘。</param>
internal void Update(Ship[] ships, Repairyard repairyard)
{
try
{
if (ships.Length == 0)
{
this.ReadyTime = null;
this.UpdateCore();
if (this.CriticaledShips.Count > 0)
{
this.CriticalCleared(this, new EventArgs());
this.CriticaledShips.Clear();
}
return;
}
var reason = CanReSortieReason.NoProblem;
if (ships.Any(s => s.IsBadlyDamaged))
{
reason |= CanReSortieReason.Wounded;
// We only send out the event once, when the ships has reached critical from its previous state.
IEnumerable<Ship> CriticalShips = ships.Where(s => s.IsBadlyDamaged);
foreach (Ship s in CriticalShips)
{
if (this.CriticalCondition != null && !repairyard.CheckRepairing(s.Id) && (this.CriticaledShips.Count == 0 || (this.CriticaledShips.Count > 0 && !this.CriticaledShips[s.Id])))
{
this.CriticalCondition(this, new ShipCriticalConditionEventArgs(s));
this.CriticaledShips.Add(s.Id, true);
}
}
int RepairingCritShips = ships.Where(s => s.IsBadlyDamaged && repairyard.CheckRepairing(s.Id)).Count();
if (this.CriticalCleared != null && ships.Where(s => s.IsBadlyDamaged).Count() == RepairingCritShips)
{
this.CriticalCleared(this, new EventArgs());
this.CriticaledShips.Clear();
}
}
else if (this.CriticalCleared != null && this.CriticaledShips.Count > 0)
{
this.CriticaledShips.Clear();
this.CriticalCleared(this, new EventArgs());
}
if (ships.Any(s => s.Fuel.Current < s.Fuel.Maximum || s.Bull.Current < s.Bull.Maximum))
{
reason |= CanReSortieReason.LackForResources;
}
var min = ships.Min(x => x.Condition);
if (min < 40)
{
reason |= CanReSortieReason.BadCondition;
// コンディションの最小値が前回から変更された場合のみ、再出撃可能時刻を更新する
// (サーバーから来るコンディション値が 3 分に 1 回しか更新されないので、毎回カウントダウンし直すと最大 3 分くらいズレる)
if (min != this.minCondition)
{
this.ReadyTime = DateTimeOffset.Now.Add(TimeSpan.FromMinutes(40 - min));
}
}
else
{
this.ReadyTime = null;
}
this.minCondition = min;
this.Reason = reason;
this.UpdateCore();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}