Exemple #1
0
        /// <summary>
        /// If a reset signal is broadcast, set up the in game UI
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnResetGameSignal(ResetGameSignal signal)
        {
            _count = 0;
            SetAsteroidsDestroyedText();

            gameOverText.gameObject.SetActive(false);
            replayText.gameObject.SetActive(false);
            instructionsText.gameObject.SetActive(true);

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// When the reset signal is broadcast, destroy any current blasters
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnResetGameSignal(ResetGameSignal signal)
        {
            var blasters = GetComponentsInChildren <Blaster>();

            foreach (var blaster in blasters)
            {
                Destroy(blaster.gameObject);
            }

            return(true);
        }
        public void Execute(ResetGameSignal param)
        {
            try
            {
                // Resetting GameTimer.
                _remoteDataModel.HeroModel.ResetGameTime();

                // Reset Last Speed Update Time.
                _remoteDataModel.HeroModel.SpeedLastUpdate = DateTime.Now;
            }
            catch (Exception ex)
            {
                Debug.LogError("Error while Resetting: " + ex.ToString());
            }
        }
Exemple #4
0
        /// <summary>
        /// When the reset signal is broadcast, destroy all the asteroids, then
        /// create new ones
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnResetGameSignal(ResetGameSignal signal)
        {
            var asteroids = GetComponentsInChildren <Asteroid>();

            foreach (var asteroid in asteroids)
            {
                Destroy(asteroid.gameObject);
            }

            CreateAsteroidSignal create = new CreateAsteroidSignal();

            for (var i = 0; i < asteroidCount; i++)
            {
                var spawnRadius = Random.Range(minMaxSpawnRadius.x, minMaxSpawnRadius.y);
                var spawnAngle  = Random.Range(0, 360f) * Mathf.Deg2Rad;
                create.position = new Vector3(Mathf.Cos(spawnAngle), Mathf.Sin(spawnAngle), 0) * spawnRadius;
                create.size     = Asteroid.AsteroidSize.Large;

                OnCreateAsteroidSignal(create);
            }

            return(true);
        }
Exemple #5
0
        /// <summary>
        /// If the reset signal is broadcast, reset the ship (or create it),
        /// and get the total number of asteroids that will be created in the game.
        /// </summary>
        /// <param name="signal"></param>
        /// <returns></returns>
        private bool OnResetGameSignal(ResetGameSignal signal)
        {
            if (_ship != null)
            {
                _ship.Reset();
            }
            else
            {
                var obj = GameObject.Instantiate(shipPrefab, Vector3.zero, Quaternion.identity, this.transform);
                _ship = obj.GetComponent <Ship>();
            }

            // request the total asteroids that will be created in the game
            List <SignalResponse <GetAsteroidCountResponse> > responses;

            if (Signaler.Instance.Broadcast <GetAsteroidCountRequest, GetAsteroidCountResponse>(this, out responses) > 0)
            {
                // a response was sent back
                _asteroidsRemaining = responses[0].response.count;
            }

            return(true);
        }