public void Initialize() { PhotonPlayerHandler.OnLeftAsObservable() .Where(_ => !MainStateEntity.Check(MainState.Wait, MainState.Result)) .Where(_ => PhotonNetwork.IsMasterClient) .Subscribe(_ => ChangeStateError()) .AddTo(Disposable); MainStateEntity.OnChangeStateAsObservable(MainState.Error) .Subscribe(_ => Disconnect()) .AddTo(Disposable); }
public void Initialize() { AudioPlayer.Play(AudioType.Main1); WaitLeaveRoomButtonHandler.OnDownAsObservable() .Where(_ => MainStateEntity.Check(MainState.Wait)) .Subscribe(_ => LeaveRoom()) .AddTo(Disposable); PhotonPlayerHandler.OnEnterAsObservable() .Where(_ => MainStateEntity.Check(MainState.Wait)) .Subscribe(player => SetInfo($"{player.NickName} さんがルームに参加しました")) .AddTo(Disposable); // 待機中にプレイヤーの情報に変更があれば描画する Observable.Merge( PhotonPlayerHandler.OnEnterAsObservable().AsUnitObservable(), PhotonPlayerHandler.OnLeftAsObservable().AsUnitObservable(), PhotonPlayerHandler.OnUpdateCustomPropertyAsObservable().AsUnitObservable() ) .Where(_ => MainStateEntity.Check(MainState.Wait)) .Subscribe(_ => { OnUpdatedPlayerList(); PlaySE(); }) .AddTo(Disposable); // 人数が上限に達したらホストが状態変更のリクエストを投げる PhotonPlayerHandler.OnEnterAsObservable() .Where(_ => PhotonNetwork.CurrentRoom.PlayerCount == PhotonNetwork.CurrentRoom.MaxPlayers) .Where(_ => PhotonNetwork.MasterClient.UserId != null) .Where(_ => PhotonNetwork.IsMasterClient) .Subscribe(_ => ChangeReadyStateRequest()) .AddTo(Disposable); PhotonPlayerHandler.OnLeftAsObservable() .Where(_ => MainStateEntity.Check(MainState.Wait)) .Subscribe(player => SetInfo($"{player.NickName} さんがルームから退出しました")) .AddTo(Disposable); OnUpdatedPlayerList(); SetInfo("3人揃うまでお待ちください コメントを変更することができます"); }