Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public void SetUpBots(IEnumerable <ICompetitor> competitors)
        {
            _field.Bots = competitors.Select(competitor => new TankBlasterBot(competitor)).ToList();

            for (var i = 0; i < _field.Bots.Count; i++)
            {
                _field.Bots[i].Location = GetBotRandomStartupLocation();
                _field.Bots[i].Image    = ResourceImageHelper.LoadImage(i % 2 == 0 ? Resources.tank1 : Resources.tank2);
            }
        }