// Updates the list of ships to give orders to and targets when the system changes public void RefreshShips(int a, int b) { if (SelectedSystem == null || _starSystems.SelectedIndex == -1) { return; } _shipList.Clear(); foreach (Entity ship in SelectedSystem.SystemManager.GetAllEntitiesWithDataBlob <ShipInfoDB>(_gameVM.CurrentAuthToken)) { if (ship.HasDataBlob <PropulsionDB>()) { ShipList.Add(ship, ship.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction)); } } _shipList.SelectedIndex = 0; //RefreshTarget(0, 0); OnPropertyChanged(nameof(ShipList)); OnPropertyChanged(nameof(MoveTargetList)); OnPropertyChanged(nameof(SelectedShip)); OnPropertyChanged(nameof(SelectedMoveTarget)); return; }
public void SetConfiguration(Configuration config) { Config = config; var newConfig = new MatchConfig(); newConfig.FieldSize = new Coordinates(Config.GetValue <int>("mbc_field_width"), Config.GetValue <int>("mbc_field_height")); newConfig.NumberOfRounds = Config.GetValue <int>("mbc_match_rounds"); var initShips = new ShipList(); foreach (var length in Config.GetList <int>("mbc_ship_sizes")) { initShips.Add(new Ship(length)); } newConfig.StartingShips = initShips; newConfig.TimeLimit = Config.GetValue <int>("mbc_player_timeout"); newConfig.GameMode = 0; foreach (var mode in Config.GetList <GameMode>("mbc_game_mode")) { newConfig.GameMode |= mode; } if (!newConfig.GameMode.HasFlag(GameMode.Classic)) { throw new NotImplementedException("The " + newConfig.GameMode.ToString() + " game mode is not supported."); } newConfig.Random = new Random(); ApplyEvent(new MatchConfigChangedEvent(newConfig)); }
private void ReactToShipDying(Ship ship) { // to prevent collisions, etc ShipList.Remove(ship); DeadShipList.Add(ship); ship.Visible = false; var randomSpawnPoint = GetSpawnPoint(); var controller = CameraControllerList.First(item => item.TargetEntity == ship); controller.FollowImmediately = false; this.Call(() => { controller.Tween("X", to: randomSpawnPoint.X, during: CameraController.TimeToInterpolateToNewSpawnLocation, interpolation: FlatRedBall.Glue.StateInterpolation.InterpolationType.Quadratic, easing: FlatRedBall.Glue.StateInterpolation.Easing.InOut); controller.Tween("Y", to: randomSpawnPoint.Y, during: CameraController.TimeToInterpolateToNewSpawnLocation, interpolation: FlatRedBall.Glue.StateInterpolation.InterpolationType.Quadratic, easing: FlatRedBall.Glue.StateInterpolation.Easing.InOut); }) .After(CameraController.TimeToWatchSinkingShip); this.Call(() => { ship.ResetHealth(); ship.X = randomSpawnPoint.X; ship.Y = randomSpawnPoint.Y; ship.Velocity = Vector3.Zero; DeadShipList.Remove(ship); ShipList.Add(ship); controller.FollowImmediately = true; ship.Visible = true; }) .After(CameraController.TimeToWatchSinkingShip + CameraController.TimeToInterpolateToNewSpawnLocation + CameraController.TimeToLookAtNewSpawnPointBeforeSpawning); }
public void SetConfiguration(Configuration config) { Config = config; var newConfig = new MatchConfig(); newConfig.FieldSize = new Coordinates(Config.GetValue<int>("mbc_field_width"), Config.GetValue<int>("mbc_field_height")); newConfig.NumberOfRounds = Config.GetValue<int>("mbc_match_rounds"); var initShips = new ShipList(); foreach (var length in Config.GetList<int>("mbc_ship_sizes")) { initShips.Add(new Ship(length)); } newConfig.StartingShips = initShips; newConfig.TimeLimit = Config.GetValue<int>("mbc_player_timeout"); newConfig.GameMode = 0; foreach (var mode in Config.GetList<GameMode>("mbc_game_mode")) { newConfig.GameMode |= mode; } if (!newConfig.GameMode.HasFlag(GameMode.Classic)) { throw new NotImplementedException("The " + newConfig.GameMode.ToString() + " game mode is not supported."); } newConfig.Random = new Random(); ApplyEvent(new MatchConfigChangedEvent(newConfig)); }