コード例 #1
0
        public void Initialize()
        {
            var entity = _characterView.GetEntity();

            _character.Initialize(entity.Id, entity, entity.SkillEntities, entity.Owner);
            _residueCharacter.AddCharacter(_character);


            _moveLoadProvider.OnLoadSubmit()
            .Where(_ => _characterView.GetEntity() == _turnCharacter.OnTurnCharacterChanged().Value.CharacterEntity)
            .Subscribe(OnMove).AddTo(_disposable);


            _phaseProvider.OnPhaseChanged()
            .Where(phase => phase == GamePhase.Damage)
            .Where(_ => _character == _turnCharacter.OnTurnCharacterChanged().Value)
            .Subscribe(_ =>
            {
                _characterView.OnAnimation(_currentSkill.OnSkillChanged().Value.AnimationState);
                _characterView.OnAnimationEnded()
                .Take(1)
                .Subscribe(animation =>
                {
                    _damagePhaseFinalizer.EmitDamage();
                });
            }).AddTo(_disposable);
            _character.OnDirectionChanged()
            .Subscribe(_characterView.SetRotation).AddTo(_disposable);
            _character.Position()
            .Subscribe(_characterView.SetPosition)
            .AddTo(_disposable);
            _character.OnHpChanged()
            .Do(_ => _characterView.OnAnimation(AnimationState.Attacked))
            .Where(hp => hp <= 0)
            .Subscribe(_ => _characterView.OnDead())
            .AddTo(_disposable);
        }
コード例 #2
0
        public void Initialize()
        {
            var entity = _characterView.GetEntity();

            _character.Initialize(entity.Id, entity, entity.SkillEntities, entity.Owner);
            _enemyRegister.AddEnemy(_character);

            // 移動アニメーション
            _moveLoadProvider.OnLoadSubmit()
            .Where(_ => _characterView.GetEntity() == _turnCharacter.OnTurnCharacterChanged().Value.CharacterEntity)
            .Subscribe(OnMove).AddTo(_disposable);

            _phaseProvider.OnPhaseChanged()
            .Where(phase => phase == GamePhase.Damage)
            .Where(_ => _character == _turnCharacter.OnTurnCharacterChanged().Value)
            .Subscribe(_ =>
            {
                _characterView.OnAnimation(_currentSkill.OnSkillChanged().Value.AnimationState);
                _characterView.OnAnimationEnded()
                .Take(1)
                .Subscribe(animation =>
                {
                    _damagePhaseFinalizer.EmitDamage();
                });
            }).AddTo(_disposable);

            _character.OnDirectionChanged()
            .Subscribe(_characterView.SetRotation).AddTo(_disposable);
            _character.Position()
            .Subscribe(_characterView.SetPosition)
            .AddTo(_disposable);
            _character.OnHpChanged()
            .Where(hp => hp <= 0)
            .Subscribe(_ => _characterView.OnDead())
            .AddTo(_disposable);

            _phaseProvider.OnPhaseChanged()
            .Where(phase => phase == GamePhase.Move)
            .Where(_ => _character == _turnCharacter.OnTurnCharacterChanged().Value)
            .Subscribe(_ =>
            {
                var load          = _cpuUseCase.CpuMove();
                var panelEntities = load.ToList();
                if (panelEntities.Any())
                {
                    _cpuUseCase.MoveCharacter(panelEntities);
                }
                else
                {
                    _phaseRegister.SkipAttack();
                }
            })
            .AddTo(_disposable);

            _phaseProvider.OnPhaseChanged()
            .Where(phase => phase == GamePhase.Attack)
            .Where(_ => _character == _turnCharacter.OnTurnCharacterChanged().Value)
            .Subscribe(_ =>
            {
                if (!_cpuUseCase.CpuAttack())
                {
                    _phaseRegister.SkipAttack();
                }
            })
            .AddTo(_disposable);
        }