Esempio n. 1
0
        private void RemoveEnemy(LifeCycleController lifeCycleController)
        {
            _lifeCycleControllers.Remove(lifeCycleController);
            if (_lifeCycleControllers.Count > 0 || Spawner.IsSpawning)
            {
                return;
            }

            FinishRound();
        }
        private void Split(LifeCycleController lifeCycleController)
        {
            var spawner  = GameManager.Instance.Spawner;
            var movement = GetComponent <IMovement>();

            for (var i = 0; i < splitCount; i++)
            {
                spawner.SpawnEnemy(splitPrefabs[Random.Range(0, splitPrefabs.Count)], movement.Position, Random.Range(0f, 360f), MathHelper.DegreeToVector2(Random.Range(0f, 360f)));
            }
        }
Esempio n. 3
0
        private void AddScore(LifeCycleController lifeCycleController)
        {
            lifeCycleController.OnDestroy -= AddScore;
            if (GameManager.Instance.IsFinished)
            {
                return;
            }

            Score += lifeCycleController.GetComponent <ScoreReward>().reward;
            OnScoreChange?.Invoke(Score);
        }
Esempio n. 4
0
 private void CheckPlayerDeath(LifeCycleController playerLifeCycleController)
 {
     if (LivesLeft > 0)
     {
         LivesLeft--;
         OnLivesChanged?.Invoke(LivesLeft);
         StartCoroutine(Respawn(playerLifeCycleController));
     }
     else
     {
         GameManager.Instance.FinishGame();
     }
 }
Esempio n. 5
0
        private void Wreck(LifeCycleController lifeCycleController)
        {
            var movement = lifeCycleController.GetComponent <IMovement>();

            for (var i = 0; i < fragmentAmount; i++)
            {
                var velocity =
                    MathHelper.DegreeToVector2(Random.Range(0f, 360f)) *
                    Random.Range(minInitialSpeed, maxInitialSpeed);
                var position = movement.Position + velocity * wreckTimeSkip;

                var fragment = Instantiate(fragmentPrefabs[Random.Range(0, fragmentPrefabs.Count)], position,
                                           Quaternion.identity);

                fragment.GetComponent <LifeCycleController>().Spawn();
                fragment.GetComponent <MovementController>()
                .Launch(position, Random.Range(0f, 360f), velocity);
            }
        }
 private void Spawn(LifeCycleController lifeCycleController)
 {
     _rotationVelocity = 0f;
     _isAccelerating   = false;
 }
Esempio n. 7
0
        private IEnumerator Respawn(LifeCycleController playerLifeCycleController)
        {
            yield return(new WaitForSeconds(respawnTime));

            playerLifeCycleController.Spawn();
        }
Esempio n. 8
0
 private void Spawn(LifeCycleController lifeCycleController)
 {
     _currentHealth = maxHealth;
 }
Esempio n. 9
0
 private void PlaySound(LifeCycleController lifeCycleController)
 {
     AudioSource.PlayClipAtPoint(destroySound, Vector3.zero);
 }