コード例 #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;
        }
コード例 #2
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;
        }