public TankBlasterUserControl(Battlefield arena) { InitializeComponent(); _arena = arena; _bombImgSource = ResourceImageHelper.LoadImage(Properties.Resources.bomb); _missileImgSource = ResourceImageHelper.LoadImage(Properties.Resources.missile); _regularTileImgSource = ResourceImageHelper.LoadImage(Properties.Resources.regularTile); _fortifiedTileImgSource = ResourceImageHelper.LoadImage(Properties.Resources.fortifiedTile); _fortifiedTileBlastImgSource = ResourceImageHelper.LoadImage(Properties.Resources.fortifiedTileBlast); _indestructibleTileImgSource = ResourceImageHelper.LoadImage(Properties.Resources.indestructibleTile); _mapBackgroundImgSource = ResourceImageHelper.LoadImage(Properties.Resources.grass); _bombExplHorImgSource = ResourceImageHelper.LoadImage(Properties.Resources.bomb_expl_mid_hor); _bombExplVerImgSource = ResourceImageHelper.LoadImage(Properties.Resources.bomb_expl_mid_vert); _tileSize = (int)(Height - PlayersGrid.Height) / _arena.Board.GetLength(1); Width = _tileSize * _arena.Board.GetLength(0); BoardGrid = new TankBlasterGridControl(); BoardGrid.SetValue(Grid.RowProperty, 1); BoardGrid.Init(_arena.Board.GetLength(0), _arena.Board.GetLength(1), _tileSize); Background = new ImageBrush(_mapBackgroundImgSource); MainGrid.Children.Add(BoardGrid); arena.ArenaChanged += OnArenaChange; }
public Battlefield ExportState() { var arena = new Battlefield(Board.GetLength(0), Board.GetLength(1)); Board.ForEveryElement((x, y, val) => { arena.Board[x, y] = val; }); arena.Bots = Bots.Select(bot => new TankBlasterBot(bot)).ToList(); arena.Bombs = Bombs.Select(bomb => new Bomb(bomb)).ToList(); arena.Missiles = Missiles.Select(missile => new Missile(missile)).ToList(); return arena; }
public LocationService(Battlefield field) { _field = field; }
public void ApplyConfiguration(string configurationXml) { _gameConfig = new XmlSerializer<TankBlasterConfig>().Deserialize(configurationXml); _field = new Battlefield(_gameConfig.MapWidth, _gameConfig.MapHeight); _locationService = new LocationService(_field); _explosionService = new ExplosionService(_field, _gameConfig, _locationService); _botService = new BotService(_field, _gameConfig, _locationService); }
public ExplosionService(Battlefield field, TankBlasterConfig config, LocationService locationService) { _field = field; _locationService = locationService; _gameConfig = config; }
public void ImportState(Battlefield arena) { var arenaCopy = arena.ExportState(); Board = arenaCopy.Board; Bots = arenaCopy.Bots; Bombs = arenaCopy.Bombs; Missiles = arenaCopy.Missiles; }