Beispiel #1
0
        public void ChangePhase(Enum type, PhaseArgument argument = null)
        {
            if (!_phaseDict.TryGetValue(type, out var phase))
            {
                Utility.Log.Error($"有効なPhaseが見つからない {type}");
                return;
            }

            _cancellationTokenSource?.Cancel();

            if (_currentPhase != null)
            {
                _currentPhase.IsPlaying = false;
                _currentPhase.PhaseStop();
            }

            phase.Argument = argument;
            _currentPhase  = phase;
            _currentType   = type;

            phase.IsPlaying = true;
            phase.PhaseStart();

            if (phase.IsPlaying)
            {
                // 非同期を投げっぱにする
                _cancellationTokenSource = new CancellationTokenSource();

                phase.PhaseStartAsync(_cancellationTokenSource.Token).Forget();
            }
        }
Beispiel #2
0
        public void StartPhase(Enum type, PhaseArgument argument = null)
        {
            foreach (var pair in _phaseDict)
            {
                var phase = pair.Value;
                phase.SetController(this);

                // 初期化処理を一度だけ呼び出す
                phase.Initialize();
            }

            ChangePhase(type, argument);
        }
Beispiel #3
0
 public void Change <TType>(TType type, PhaseArgument argument = null) where TType : Enum =>
 _controller.ChangePhase(type, argument);