Esempio n. 1
0
        public Game()
        {
            InitializeComponent();

            _player = new Player();
            _player.DisplayOn(gameCanvas);

            _alien = new Alien();
            _alien.DisplayOn(gameCanvas);

            _bombs  = new BombCollection();
            _lasers = new LaserCollection();

            _animationTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(40)
            };
            _animationTimer.Tick += animationTimer_Tick;
            _animationTimer.Start();


            _bombTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(2)
            };
            _bombTimer.Tick += bombTimer_Tick;
            _bombTimer.Start();
        }
Esempio n. 2
0
        public void DropBomb(BombCollection bombs)
        {
            var bombX = X + (Width / 2);
            var bombY = Y + Height;
            var bomb  = new Bomb(bombX, bombY, bombs);

            bomb.DisplayOn(_canvas);
        }
Esempio n. 3
0
        public Bomb(int x, int y, BombCollection bombCollection)
        {
            _ellipse = new Ellipse {
                Fill = new SolidColorBrush(Colors.Black)
            };
            _stepSize            = 8;
            this._bombCollection = bombCollection;

            X      = x;
            Y      = y;
            Width  = 5;
            Height = 5;

            _bombCollection.Add(this);
        }