public void Initialize() { _phaseProvider.OnPhaseChanged() .Where(phase => phase == GamePhase.End) .Subscribe(_ => { if (!_residueCharacters.Characters().Any()) { _phaseRegister.GameOver(); } else if (!_residueEnemies.Enemies().Any()) { _phaseRegister.StageClear(); } else { _phaseRegister.NextTurn(); } }).AddTo(_disposable); }
private async void CreateStage() { Reset(); foreach (var character in _loadCharacter.LoadCharacters()) { _characters.Add(_characterFactory.Create(_id, character, Owner.Player)); _id++; } await UniTask.WaitWhile(() => _residueCharacters.Characters().Any()); _residueCharacters.Initialize(); foreach (var character in _loadCharacter.LoadEnemies()) { _characters.Add(_characterFactory.Create(_id, character, Owner.CPU)); _id++; } await UniTask.WaitWhile(() => _residueEnemies.Enemies().Any()); _residueEnemies.Initialize(); _bufferInitializer.UpdateCharacters(_residueCharacters.Characters().Concat(_residueEnemies.Enemies())); var stage = _stageInitializer.NextStage(_loadStage.LoadStage(), _residueCharacters.Characters().ToList(), _residueEnemies.Enemies().ToList()); foreach (var panel in stage) { _dice.Add(_diceFactory.Create(panel.GetEntity())); var entity = panel.GetEntity(); if (entity.PanelState == PanelState.NoEntry) { continue; } _panel.Add(_panelFactory.Create(entity)); } _phaseRegister.NextTurn(); }