コード例 #1
0
        public void Initialize(IEndGameService endGameService)
        {
            Alkar.InjectMonoBehaviour(this);

            _disposable.Add(
                endGameService
                .EndGameWithMessage
                .Subscribe(x => _text.text = x)
                );
        }
コード例 #2
0
        protected override IDisposable[] Init()
        {
            Alkar.InjectMonoBehaviour(this);

            _handler = new BallHandler(_ballKind);
            _jumpDirectionProvider = new JumpDirectionProvider();

            return(new IDisposable[]
            {
                _handler.JumpForce.Subscribe(Jump),
                _handler.RotationTorque.Subscribe(Rotate),
                _handler.ScaleAnimation.Subscribe(ScaleAnimation)
            });
        }
コード例 #3
0
        private void Awake()
        {
            Alkar.Clear();

            var playerPositionService = new PlayerPositionService();
            var inputFactory          = new BallInputFactory(_playerInput, playerPositionService, _ballSettings);
            var endGameService        = new EndGameService(_endGameMessages);

            _playerInput.Initialize(playerPositionService, endGameService);
            _endGameCanvas.Initialize(endGameService);

            Services.Register <ICameraService>(_cameraService);
            Services.Register(playerPositionService);
            Services.Register(inputFactory);
            Services.Register <IBallSettings>(_ballSettings);
            Services.Register <IEndGameService>(endGameService);

            SceneManager
            .LoadSceneAsync(Scenes.Play, LoadSceneMode.Additive)
            .completed += _ => { SceneManager.SetActiveScene(SceneManager.GetSceneByName(Scenes.Play)); };
        }
コード例 #4
0
        public BallHandler(BallKind ballKind)
        {
            _ballKind = ballKind;
            Alkar.Inject(this);

            _input = _ballInputFactory.Get(ballKind);

            _input.TrackHandler(this);

            RotationTorque = _input
                             .RawDirection
                             .Select(
                x => x * _ballSettings.Speed * Time.deltaTime
                )
                             .Select(x => x * Vector3.forward);

            JumpForce = _input
                        .Jump
                        .Where(_ => _touchingFloor)
                        .Select(_ => _ballSettings.JumpForce)
                        .ThrottleFirst(TimeSpan.FromSeconds(JumpThrottleSeconds));
        }
コード例 #5
0
 private void Awake()
 {
     Alkar.InjectMonoBehaviour(this);
 }