Exemple #1
0
        private void SpawnSingle()
        {
            var type        = SpawnUtils.GetRandomSpawnEnemyType();
            var poolManager = CoreManager.Instance.GetData <PoolManager>();
            var common      = ScriptableUtils.GetCommonElements();
            var view        = (CollisionView)poolManager.GetItem <EnemyType>((int)type);

            var command    = CommandFactory.GetAiCommand(type);
            var model      = EnemyFactory.GetEnemyModel(type, command);
            var controller = new EnemyController(model, view, _player.transform, view.GetComponent <Rigidbody>());

            var position =
                SpawnUtils.GetRandomSpawnPosition(_player.transform, common.SpawnInnerRange, common.SpawnOutRange);

            view.transform.position = position;

            controller.PlayerCollision -= OnPlayerCollision;
            controller.PlayerCollision += OnPlayerCollision;

            controller.Die -= OnEnemyDie;
            controller.Die += OnEnemyDie;

            _enemy.Add(controller);
            _count++;
        }