Esempio n. 1
0
        private void AddScore(LifeCycleController lifeCycleController)
        {
            lifeCycleController.OnDestroy -= AddScore;
            if (GameManager.Instance.IsFinished)
            {
                return;
            }

            Score += lifeCycleController.GetComponent <ScoreReward>().reward;
            OnScoreChange?.Invoke(Score);
        }
Esempio n. 2
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);
            }
        }