public AdmiralInfo(Admiral admiral, Materials materials) { this.MemberId = admiral.MemberId; this.Nickname = admiral.Nickname; this.Comment = admiral.Comment; this.Experience = admiral.Experience; this.ExperienceForNexeLevel = admiral.ExperienceForNexeLevel; this.Level = admiral.Level; this.Rank = admiral.Rank; this.SortieWins = admiral.SortieWins; this.SortieLoses = admiral.SortieLoses; this.SortieWinningRate = admiral.SortieWinningRate; this.MaxShipCount = admiral.MaxShipCount; this.MaxSlotItemCount = admiral.MaxSlotItemCount; this.Fuel = materials.Fuel; this.Ammunition = materials.Ammunition; this.Steel = materials.Steel; this.Bauxite = materials.Bauxite; this.DevelopmentMaterials = materials.DevelopmentMaterials; this.InstantRepairMaterials = materials.InstantRepairMaterials; this.Bucket = materials.Bucket; this.InstantBuildMaterials = materials.InstantBuildMaterials; this.Id = Guid.NewGuid().ToString(); this.CreateDate = DateTime.Now; }
private void UpdateHQRecord(Admiral admiral) { if (tableHQRecord.InvokeRequired) { this.tableHQRecord.Invoke(() => UpdateHQRecord(admiral)); return; } this.HQRecorder.Updated(); HQRecord.HQRecordElement res; int diff; res = this.HQRecorder.GetRecordMonth(); diff = admiral.Experience - res.HQExp; tableHQRecord.TableCells[0].Value = string.Format("{0} exp. / {1:n2}", diff, diff * 7 / 10000.0); res = this.HQRecorder.GetRecordDay(); diff = admiral.Experience - res.HQExp; tableHQRecord.TableCells[1].Value = string.Format("{0} exp. / {1:n2}", diff, diff * 7 / 10000.0); res = this.HQRecorder.GetRecordPrevious(); diff = admiral.Experience - res.HQExp; tableHQRecord.TableCells[2].Value = string.Format("{0} exp. / {1:n2}", diff, diff * 7 / 10000.0); tableHQRecord.TableCells[0].Visible = true; tableHQRecord.TableCells[1].Visible = true; tableHQRecord.TableCells[2].Visible = true; tableHQRecord.RequestUpdate(); }
private void Start() { Player1 = new Admiral(this) { Ships = new List <Ship>() { new Ship(1), new Ship(1), new Ship(1), new Ship(1), new Ship(2), new Ship(2), new Ship(2), new Ship(3), new Ship(3), new Ship(4) } }; Ai = new Admiral(this) { Ships = new List <Ship>() { new Ship(1), new Ship(1), new Ship(1), new Ship(1), new Ship(2), new Ship(2), new Ship(2), new Ship(3), new Ship(3), new Ship(4) } }; SetGameState(new AiPlacementState(this)); _gameState.ExecuteState(); }
public GameState() { FastCoord.Init(); FastShipPosition.Init(); forecaster = new Forecaster(this); admiral = new Admiral(this); strateg = new Strateg(this); }
public void UpdateAdmiral(RawBasic rpData) { if (Admiral == null) Admiral = new Admiral(rpData); else Admiral.Update(rpData); OnPropertyChanged(() => Admiral); }
private void Awake() { if (GetAdmiral() == true) { frequency = Admiral.getFrequency(frequency); } else { frequency = -1; } }
internal void UpdateAdmiral(RawBasic rpAdmiral) { if (Admiral != null) { Admiral.Update(rpAdmiral); } else { Admiral = new Admiral(rpAdmiral); OnPropertyChanged(nameof(Admiral)); } }
internal AdmiralRankingPoints(Admiral rpAdmiral) { r_Owner = rpAdmiral; r_AdmiralID = rpAdmiral.ID; ApiService.SubscribeOnce("api_port/port", delegate { ReloadInitialRankingPoints(); PreviousUpdateDifference = new AdmiralRankingPointsDifference(this, AdmiralRankingPointsDifferenceType.PreviousUpdate); DayDifference = new AdmiralRankingPointsDifference(this, AdmiralRankingPointsDifferenceType.Day); MonthDifference = new AdmiralRankingPointsDifference(this, AdmiralRankingPointsDifferenceType.Month); Update(); var rRankUpdateTime = new DateTimeOffset(DateTimeOffset.Now.Date, TimeSpan.FromHours(6.0)); var rDayTimeSpan = TimeSpan.FromDays(1.0); Observable.Timer(rRankUpdateTime.AddDays(1.0), rDayTimeSpan).Subscribe(delegate { PreviousUpdateDifference.Reload(); DayDifference.Reload(); OnPropertyChanged(nameof(PreviousUpdateDifference)); OnPropertyChanged(nameof(DayDifference)); }); rRankUpdateTime += TimeSpan.FromHours(12.0); if (DateTimeOffset.Now > rRankUpdateTime) rRankUpdateTime += rDayTimeSpan; Observable.Timer(rRankUpdateTime, rDayTimeSpan).Subscribe(delegate { PreviousUpdateDifference.Reload(); OnPropertyChanged(nameof(PreviousUpdateDifference)); }); var rNow = DateTimeOffset.Now; var rFinalizationTime = new DateTimeOffset(rNow.Year, rNow.Month, 1, 0, 0, 0, TimeSpan.FromHours(9.0)).AddMonths(1).AddHours(-2.0); if (rNow >= rFinalizationTime) FinalizeThisMonth(); else Observable.Return(Unit.Default).Delay(rFinalizationTime).Subscribe(_ => FinalizeThisMonth()); Observable.Return(Unit.Default).Delay(rFinalizationTime.AddHours(2.0)).Subscribe(_ => r_IsFinalized = false); RecordService.Instance.Update += RecordService_Update; }); }
public CardNotepad(Player player) { //Si tiene x tipo de carta cardNumber = new bool[8]; //Retorno de x tipo de carta typeCards = new Card[8]; typeCards[0] = new Guardian(); typeCards[1] = new Spy(); typeCards[2] = new BountyHunter(); typeCards[3] = new Shield(); typeCards[4] = new Captain(); typeCards[5] = new Admiral(); typeCards[6] = new Adviser(); typeCards[7] = new Warmind(); //Tiene que ver con el spotteo y un index creeeeo cardNumberOrigen = new int[8]; Player = player; }
internal void UpdateAdmiral(kcsapi_basic data) { this.Admiral = new Admiral(data); }
internal void UpdateAdmiral(RawBasic rpAdmiral) { if (Admiral != null) Admiral.Update(rpAdmiral); else { Admiral = new Admiral(rpAdmiral); OnPropertyChanged(nameof(Admiral)); } }
public NavalBase(GameProvider listener, ITimingService timingService, NotificationManager notification, IStatePersist statePersist, IQuestKnowledges questKnowledges) { Notification = notification; StatePersist = statePersist; this.questKnowledges = questKnowledges; MasterData = new MasterDataRoot(listener); Battle = new BattleManager(listener, this); Quests = new QuestManager(listener, questKnowledges, statePersist); _allEquipment = new IdTable <EquipmentId, HomeportEquipment, RawEquipment, NavalBase>(this); _buildingDocks = new IdTable <BuildingDockId, BuildingDock, RawBuildingDock, NavalBase>(this); _repairingDocks = new IdTable <RepairingDockId, RepairingDock, RawRepairingDock, NavalBase>(this); _useItems = new IdTable <UseItemId, UseItemCount, RawUseItemCount, NavalBase>(this); _allShips = new IdTable <ShipId, HomeportShip, RawShip, NavalBase>(this); _fleets = new IdTable <FleetId, HomeportFleet, RawFleet, NavalBase>(this); _maps = new IdTable <MapId, Map, RawMap, NavalBase>(this); _airForce = new IdTable <(MapAreaId MapArea, AirForceGroupId GroupId), AirForceGroup, RawAirForceGroup, NavalBase>(this); listener.AllEquipmentUpdated += (t, msg) => _allEquipment.BatchUpdate(msg, t); listener.BuildingDockUpdated += (t, msg) => _buildingDocks.BatchUpdate(msg, t); listener.UseItemUpdated += (t, msg) => _useItems.BatchUpdate(msg, t); listener.AdmiralUpdated += (t, msg) => { if (Admiral?.Id != msg.Id) { var @new = new Admiral(msg, this, t); AdmiralChanging?.Invoke(t, Admiral, @new); Admiral = @new; NotifyPropertyChanged(nameof(Admiral)); StatePersist?.Initialize(msg.Id); this.questKnowledges.Load(); } else { Admiral.Update(msg, t); } }; listener.MaterialsUpdated += (t, msg) => { var oldMaterials = Materials; var materials = oldMaterials; msg.Apply(ref materials); if (Materials != materials) { Materials = materials; MaterialsUpdating?.Invoke(t, oldMaterials, materials, msg.Reason); } }; listener.HomeportReturned += (t, msg) => { _allShips.BatchUpdate(msg.Ships, t); CombinedFleet = msg.CombinedFleetType; if (StatePersist != null) { StatePersist.LastHomeportUpdate = t; StatePersist.SaveChanges(); } HomeportUpdated?.Invoke(t, this); }; listener.CompositionChanged += (t, msg) => { var fleet = Fleets[msg.FleetId]; if (msg.ShipId is ShipId shipId) { var ship = AllShips[shipId]; fleet.ChangeComposition(msg.Index, ship); } else { fleet.ChangeComposition(msg.Index, null); } }; listener.FleetsUpdated += (t, msg) => _fleets.BatchUpdate(msg, t); listener.FleetPresetSelected += (t, msg) => Fleets[msg.Id].Update(msg, t); listener.ShipExtraSlotOpened += (t, msg) => AllShips[msg].OpenExtraSlot(); listener.PartialFleetsUpdated += (t, msg) => _fleets.BatchUpdate(msg, t, removal: false); listener.PartialShipsUpdated += (t, msg) => _allShips.BatchUpdate(msg, t, removal: false); listener.RepairingDockUpdated += (t, msg) => _repairingDocks.BatchUpdate(msg, t); listener.ShipSupplied += (t, msg) => { foreach (var raw in msg) { var ship = AllShips[raw.ShipId]; ShipSupplying?.Invoke(t, ship, raw); ship?.Supply(raw); } questKnowledges.OnSingletonEvent(SingletonEvent.ShipSupply); }; listener.RepairStarted += (t, msg) => { var ship = AllShips[msg.ShipId]; if (ship == null) { return; } ShipRepairing?.Invoke(t, ship, msg.InstantRepair); if (msg.InstantRepair) { ship.SetRepaired(); } var oldMaterials = Materials; var materials = oldMaterials; materials.Fuel -= ship.RepairingCost.Fuel; materials.Steel -= ship.RepairingCost.Steel; Materials = materials; MaterialsUpdating?.Invoke(t, oldMaterials, materials, MaterialsChangeReason.ShipRepair); questKnowledges.OnSingletonEvent(SingletonEvent.ShipRepair); }; listener.InstantRepaired += (t, msg) => { var dock = RepairingDocks[msg]; RepairingDockInstant?.Invoke(t, msg, dock.RepairingShip); dock.Instant(); }; listener.InstantBuilt += (t, msg) => { var dock = BuildingDocks[msg]; dock.Instant(); var oldMaterials = Materials; var materials = oldMaterials; materials.InstantBuild -= dock.IsLSC ? 10 : 1; Materials = materials; MaterialsUpdating?.Invoke(t, oldMaterials, materials, MaterialsChangeReason.InstantBuilt); }; listener.ShipCreated += (t, msg) => questKnowledges.OnSingletonEvent(SingletonEvent.ShipConstruct); listener.ShipBuildCompleted += (t, msg) => { _allEquipment.BatchUpdate(msg.Equipments, t, removal: false); _allShips.Add(msg.Ship, t); }; listener.EquipmentCreated += (t, msg) => { foreach (var e in msg.Equipment) { if (e is object) { _allEquipment.Add(e, t); } questKnowledges.OnSingletonEvent(SingletonEvent.EquipmentCreate); } }; listener.ShipDismantled += (t, msg) => { var removed = RemoveShips(msg.ShipIds, msg.DismantleEquipments); questKnowledges.OnShipDismantle(removed); ShipDismantling?.Invoke(t, removed, msg.DismantleEquipments); }; listener.EquipmentDismantled += (t, msg) => { var removed = RemoveEquipment(msg); questKnowledges.OnEquipmentDismantle(removed); EquipmentDismantling?.Invoke(t, removed); }; listener.EquipmentImproved += (t, msg) => { var consumed = msg.ConsumedEquipmentIds != null?RemoveEquipment(msg.ConsumedEquipmentIds) : null; var original = AllEquipment[msg.EquipmentId]; EquipmentImproving?.Invoke(t, original, msg.UpdatedTo, consumed, msg.IsSuccess); if (msg.IsSuccess) { original.Update(msg.UpdatedTo, t); } questKnowledges?.OnSingletonEvent(SingletonEvent.EquipmentImprove); }; listener.ShipPoweruped += (t, msg) => { var consumed = RemoveShips(msg.ConsumedShipIds, msg.DismantleEquipments); var original = AllShips[msg.ShipId]; questKnowledges.OnShipPowerup(original, consumed, msg.IsSuccess); ShipPoweruping?.Invoke(t, original, msg.UpdatedTo, consumed); original.Update(msg.UpdatedTo, t); }; listener.ExpeditionCompleted += (t, msg) => { var fleet = Fleets[msg.FleetId]; questKnowledges?.OnExpeditionComplete(fleet, fleet.Expedition, msg.Result); }; listener.MapsUpdated += (t, msg) => _maps.BatchUpdate(msg, t); listener.AirForceUpdated += (t, msg) => _airForce.BatchUpdate(msg, t); listener.AirForcePlaneSet += (t, msg) => AirForce[(msg.MapAreaId, msg.GroupId)].SetPlane(t, msg);
public NavalBase(IGameProvider listener, ILocalizationService localization) { Localization = localization; MasterData = new MasterDataRoot(listener, localization); Quests = new QuestManager(listener, localization); _allEquipment = new IdTable<EquipmentId, Equipment, IRawEquipment, NavalBase>(this); _buildingDocks = new IdTable<BuildingDockId, BuildingDock, IRawBuildingDock, NavalBase>(this); _repairingDocks = new IdTable<RepairingDockId, RepairingDock, IRawRepairingDock, NavalBase>(this); _useItems = new IdTable<UseItemId, UseItemCount, IRawUseItemCount, NavalBase>(this); _allShips = new IdTable<ShipId, Ship, IRawShip, NavalBase>(this); _fleets = new IdTable<FleetId, Fleet, IRawFleet, NavalBase>(this); _maps = new IdTable<MapId, Map, IRawMap, NavalBase>(this); _airForce = new IdTable<(MapAreaId MapArea, AirForceGroupId GroupId), AirForceGroup, IRawAirForceGroup, NavalBase>(this); listener.AllEquipmentUpdated += (t, msg) => _allEquipment.BatchUpdate(msg, t); listener.BuildingDockUpdated += (t, msg) => _buildingDocks.BatchUpdate(msg, t); listener.UseItemUpdated += (t, msg) => _useItems.BatchUpdate(msg, t); listener.AdmiralUpdated += (t, msg) => { if (Admiral?.Id != msg.Id) { var @new = new Admiral(msg, this, t); AdmiralChanging?.Invoke(t, Admiral, @new); Admiral = @new; NotifyPropertyChanged(nameof(Admiral)); } else Admiral.Update(msg, t); }; listener.MaterialsUpdated += (t, msg) => { var materials = Materials; msg.Apply(ref materials); if (Materials != materials) { Materials = materials; MaterialsUpdating?.Invoke(t, Materials, materials, msg.Reason); } }; listener.HomeportReturned += (t, msg) => _allShips.BatchUpdate(msg.Ships, t); listener.CompositionChanged += (t, msg) => { var fleet = Fleets[msg.FleetId]; if (msg.ShipId is ShipId shipId) { var ship = AllShips[shipId]; fleet.ChangeComposition(msg.Index, ship, Fleets.FirstOrDefault(x => x.Ships.Contains(ship))); } else fleet.ChangeComposition(msg.Index, null, null); }; listener.FleetsUpdated += (t, msg) => _fleets.BatchUpdate(msg, t); listener.FleetPresetSelected += (t, msg) => Fleets[msg.Id].Update(msg, t); listener.ShipEquipmentUdated += (t, msg) => AllShips[msg.ShipId].UpdateEquipments(msg.EquipmentIds); listener.ShipExtraSlotOpened += (t, msg) => AllShips[msg].ExtraSlot = new Slot(); listener.PartialFleetsUpdated += (t, msg) => _fleets.BatchUpdate(msg, t, removal: false); listener.PartialShipsUpdated += (t, msg) => _allShips.BatchUpdate(msg, t, removal: false); listener.RepairingDockUpdated += (t, msg) => _repairingDocks.BatchUpdate(msg, t); listener.ShipSupplied += (t, msg) => { foreach (var raw in msg) AllShips[raw.ShipId]?.Supply(raw); }; listener.RepairStarted += (t, msg) => { if (msg.InstantRepair) AllShips[msg.ShipId]?.SetRepaired(); }; listener.InstantRepaired += (t, msg) => { var dock = RepairingDocks[msg]; dock.State = RepairingDockState.Empty; dock.RepairingShip = null; }; listener.InstantBuilt += (t, msg) => BuildingDocks[msg].State = BuildingDockState.BuildCompleted; listener.ShipBuildCompleted += (t, msg) => { _allEquipment.BatchUpdate(msg.Equipments, t, removal: false); _allShips.Add(msg.Ship, t); }; listener.EquipmentCreated += (t, msg) => { if (msg.IsSuccess) _allEquipment.Add(msg.Equipment, t); }; listener.ShipDismantled += (t, msg) => ShipDismantling?.Invoke(t, RemoveShips(msg.ShipIds, msg.DismantleEquipments, t), msg.DismantleEquipments); listener.EquipmentDismantled += (t, msg) => EquipmentDismantling?.Invoke(t, RemoveEquipments(msg, t)); listener.EquipmentImproved += (t, msg) => { var consumed = RemoveEquipments(msg.ConsumedEquipmentIds, t); var original = AllEquipment[msg.EquipmentId]; EquipmentImproving?.Invoke(t, original, msg.UpdatedTo, consumed, msg.IsSuccess); if (msg.IsSuccess) original.Update(msg.UpdatedTo, t); }; listener.ShipPoweruped += (t, msg) => { var consumed = RemoveShips(msg.ConsumedShipIds, true, t); var original = AllShips[msg.ShipId]; ShipPoweruping?.Invoke(t, original, msg.UpdatedTo, consumed); original.Update(msg.UpdatedTo, t); }; listener.MapsUpdated += (t, msg) => _maps.BatchUpdate(msg, t); listener.AirForceUpdated += (t, msg) => _airForce.BatchUpdate(msg, t); listener.AirForcePlaneSet += (t, msg) => { var group = AirForce[(msg.MapAreaId, msg.GroupId)]; group.Distance = msg.NewDistance; group.squadrons.BatchUpdate(msg.UpdatedSquadrons, t, removal: false); };
internal void UpdateAdmiral(RawBasic rpAdmiral) { if (Admiral == null) Admiral = new Admiral(rpAdmiral); else Admiral.Update(rpAdmiral); }
private void Update(Admiral admiral) { this.Model = admiral; RaisePropertyChanged(nameof(Coin)); }