예제 #1
0
        internal void Update()
        {
            Status.Update();
            Resupply.Update();
            ExpeditionStatus.Update(RawData.Expedition);

            var rState  = FleetState.None;
            var rSortie = KanColleGame.Current.Sortie;

            if (rSortie?.Fleet == this || Port.Fleets.CombinedFleetType != CombinedFleetType.None && rSortie?.Fleet.ID == 1 && ID == 2)
            {
                rState |= FleetState.Sortie;
            }
            else if (ExpeditionStatus.Expedition != null)
            {
                rState |= FleetState.Expedition;
            }
            else
            {
                rState |= FleetState.Idle;
            }

            Ship[] rShipsToBeRepaired = null;
            if ((rState & FleetState.Idle) != 0)
            {
                if (r_Ships.Any(r => r.Fuel.Current < r.Fuel.Maximum || r.Bullet.Current < r.Bullet.Maximum))
                {
                    rState |= FleetState.Unsupplied;
                }

                if (r_Ships.Any(r => Port.RepairDocks.Values.Any(rpDock => rpDock.Ship == r)))
                {
                    rState |= FleetState.Repairing;
                }

                if ((rState & FleetState.Repairing) == 0 && r_Ships.Any(r => (r.State & ShipState.HeavilyDamaged) != 0))
                {
                    rState |= FleetState.HeavilyDamaged;
                }

                if (r_Ships.Count > 0 && (ShipType)r_Ships[0].Info.Type.ID == ShipType.RepairShip)
                {
                    rShipsToBeRepaired = r_Ships.Take(2 + r_Ships[0].EquipedEquipment.Count(r => r.Info.Type == EquipmentType.ShipRepairFacility))
                                         .Where(r => r.DamageState != ShipDamageState.FullyHealthy && r.DamageState < ShipDamageState.ModeratelyDamaged && !Port.RepairDocks.Values.Any(rpDock => rpDock.Ship == r)).ToArray();
                    if (rShipsToBeRepaired.Length > 0)
                    {
                        rState |= FleetState.AnchorageRepair;
                    }
                }
            }

            if ((rState & FleetState.Sortie) == 0)
            {
                ConditionRegeneration.Update();
            }
            else
            {
                ConditionRegeneration.Reset();
            }

            if ((rState & FleetState.AnchorageRepair) != 0)
            {
                AnchorageRepair.Update(rShipsToBeRepaired);
            }
            else if ((State & FleetState.AnchorageRepair) != 0)
            {
                AnchorageRepair.Stop();
            }

            var rConditionType = ShipConditionType.HighMorale;

            foreach (var rShip in Ships)
            {
                if (rConditionType < rShip.ConditionType)
                {
                    rConditionType = rShip.ConditionType;
                }
            }

            switch (rConditionType)
            {
            case ShipConditionType.HighMorale:
                rState |= FleetState.HighMorale;
                break;

            case ShipConditionType.ModerateTired:
                rState |= FleetState.ModerateTired;
                break;

            case ShipConditionType.SeriouslyTired:
                rState |= FleetState.SeriouslyTired;
                break;
            }

            State = rState;
        }
예제 #2
0
        internal void Update()
        {
            Status.Update();
            Resupply.Update();
            ExpeditionStatus.Update(RawData.Expedition);

            var rState  = FleetState.None;
            var rSortie = KanColleGame.Current.Sortie;

            if (rSortie?.Fleet == this ||
                Port.Fleets.CombinedFleetType != CombinedFleetType.None && rSortie?.Fleet.ID == 1 && ID == 2)
            {
                rState |= FleetState.Sortie;
            }
            else if (ExpeditionStatus.Expedition != null)
            {
                rState |= FleetState.Expedition;
            }
            else
            {
                rState |= FleetState.Idle;
            }

            Ship[] rShipsToBeRepaired = null;
            if ((rState & FleetState.Idle) == FleetState.Idle)
            {
                if (r_Ships.Any(r => r.Fuel.Current < r.Fuel.Maximum || r.Bullet.Current < r.Bullet.Maximum))
                {
                    rState |= FleetState.Unsupplied;
                }

                if (r_Ships.Any(r => Port.RepairDocks.Values.Any(rpDock => rpDock.Ship == r)))
                {
                    rState |= FleetState.Repairing;
                }

                if (r_Ships.Any(r => (r.State & ShipState.HeavilyDamaged) == ShipState.HeavilyDamaged))
                {
                    rState |= FleetState.HeavilyDamaged;
                }

                if (r_Ships.Count > 0 && (ShipType)r_Ships[0].Info.Type.ID == ShipType.RepairShip)
                {
                    rShipsToBeRepaired = r_Ships.Take(2 + r_Ships[0].EquipedEquipment.Count(r => r.Info.Type == EquipmentType.ShipRepairFacility))
                                         .Where(r => r.HP.Current != r.HP.Maximum && r.HP.Current / (double)r.HP.Maximum > .5 && !Port.RepairDocks.Values.Any(rpDock => rpDock.Ship == r)).ToArray();
                    if (rShipsToBeRepaired.Length > 0)
                    {
                        rState |= FleetState.AnchorageRepair;
                    }
                }
            }

            if ((rState & FleetState.Sortie) == 0)
            {
                ConditionRegeneration.Update();
            }
            else
            {
                ConditionRegeneration.Reset();
            }

            if ((rState & FleetState.AnchorageRepair) == FleetState.AnchorageRepair)
            {
                AnchorageRepair.Update(rShipsToBeRepaired);
            }
            else if ((State & FleetState.AnchorageRepair) == FleetState.AnchorageRepair)
            {
                AnchorageRepair.Stop();
            }

            State = rState;
        }