コード例 #1
0
ファイル: Fleet.cs プロジェクト: 1273700934/AdmiralRoom
        public void UpdateStatus()
        {
            LowCondition   = false;
            HeavilyDamaged = false;
            NeedCharge     = false;
            Repairing      = false;
            foreach (var ship in Ships)
            {
                LowCondition   |= ship.Condition < 40;
                HeavilyDamaged |= !ship.IsEscaped && ship.DamageControl == null && ship != Ships.FirstOrDefault() && ship.HP.Current * 4 <= ship.HP.Max;
                NeedCharge     |= !(ship.Fuel.IsMax && ship.Bull.IsMax);
                Repairing      |= ship.IsRepairing;
            }
#pragma warning disable CC0014
            if (InSortie)
            {
                Status = HeavilyDamaged ? FleetStatus.Warning : FleetStatus.InSortie;
            }
            else if (MissionState != FleetMissionState.None)
            {
                Status = FleetStatus.InMission;
            }
            else if (NeedCharge || HeavilyDamaged || LowCondition || Repairing || CanHomeportRepairing)
            {
                Status = FleetStatus.NotReady;
            }
            else
            {
                Status = FleetStatus.Ready;
            }
#pragma warning restore CC0014
            AirFightPower = Ships.Aggregate(new int[8], (x, y) => x.Zip(y.AirFightPower, (a, b) => a + b).ToArray());
            if (Ships.Any())
            {
                mincondition = Ships.Min(x => x.Condition);
            }
            else
            {
                mincondition = 49;
                Status       = FleetStatus.Empty;
            }
            OnPropertyChanged(nameof(AirFightPower));
            OnPropertyChanged(nameof(LevelSum));
            OnPropertyChanged(nameof(LevelAverage));
            OnPropertyChanged(nameof(LoSInMap));
            OnPropertyChanged(nameof(ChargeCost));
            OnPropertyChanged(nameof(RepairCost));
            OnPropertyChanged(nameof(CanHomeportRepairing));
        }