Exemple #1
0
        /// <summary>
        /// Prüft ob es eine Kollision zwischen Spieler und Gegner gab oder ob alle Gegern tot sind
        /// </summary>
        private void GameOver()
        {
            var countInvadersDeath = 0;
            var shipLocationY      = _ship.LocationY;

            if (_refreshShipLabel)
            {
                _infobar.UpdateSpaceShipLivesLabel(_ship.Lives);
            }

            _refreshShipLabel = false;

            for (var i = 0; i < _invaders.Count; i++)
            {
                if (shipLocationY <= _invaders.GetLocationY(i) - _invaders.Width)
                {
                    Stop();
                    CreateGameStateLabel(false);
                }

                if (_invaders.InvaderDead(i))
                {
                    countInvadersDeath++;
                }
            }

            if (countInvadersDeath == _invaders.Count)
            {
                Stop();
                CreateGameStateLabel(true);
            }

            if (_ship.Alive)
            {
                return;
            }

            Stop();
            CreateGameStateLabel(false);
        }