Beispiel #1
0
        /// <summary>
        /// If a hit signal is broadcast, update the asteroid count text
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnAsteroidHitFriendlySignal(AsteroidHitFriendlySignal signal)
        {
            _count++;
            SetAsteroidsDestroyedText();

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// When the hit signal is broadcast, check to see if it hit this blaster.
        /// If so, kill it.
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnAsteroidHitFriendlySignal(AsteroidHitFriendlySignal signal)
        {
            if (signal.friendly == (IFriendly)this)
            {
                Kill();
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// If the hit signal was broadcast, create an asteroid explosion fx.
        /// If the ship was hit, then also create a ship explosion fx
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnAsteroidHitFriendlySignal(AsteroidHitFriendlySignal signal)
        {
            GameObject.Instantiate(asteroidExplosionPrefab, signal.position, Quaternion.identity, this.transform);

            if (signal.friendly.GetType() == typeof(Ship))
            {
                GameObject.Instantiate(shipExplosionPrefab, signal.position, Quaternion.identity, this.transform);
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// If the hit signal was broadcast, check to see if the game over condition exists (zero asteroids remaining)
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnAsteroidHitFriendlySignal(AsteroidHitFriendlySignal signal)
        {
            _asteroidsRemaining--;

            if (_asteroidsRemaining == 0)
            {
                // No asteroids remaining, so we broadcast a game over signal
                Signaler.Instance.Broadcast <GameOverSignal>(this, new GameOverSignal()
                {
                    state = GameOverState.Won
                });
            }

            return(true);
        }