private void OnClearAll() { view.EnableAllButtons(false); raiseBetAmount = 0; isClickable = false; }
public ButtonPresenter(ButtonView view) { this.view = view; this.manager = GameManager.Instance; this.ObserveEveryValueChanged(x => x.isClickable).Subscribe(x => { if (x == false) { view.EnableAllButtons(false); } }); this.view.OnCallButtonClicked.Where(_ => isClickable).Subscribe(x => { manager.OnCall(currentGamePlayer.userIndex, currentGamePlayer.stageBet); isClickable = false; }); this.view.OnCall2ButtonClicked.Where(_ => isClickable).Subscribe(x => { manager.OnCall(currentGamePlayer.userIndex, currentGamePlayer.stageBet); isClickable = false; }); this.view.OnCallButtonClicked.Where(_ => isClickable).Subscribe(x => { if (currentGamePlayer.buyInLeft <= raiseBetAmount) { manager.OnAllIn(currentGamePlayer.userIndex, currentGamePlayer.stageBet, 0); } else { manager.OnCall(currentGamePlayer.userIndex, currentGamePlayer.stageBet); } isClickable = false; }); this.view.OnRaiseButtonClicked.Where(_ => isClickable).Subscribe(_ => { if (currentGamePlayer.buyInLeft <= raiseBetAmount) { manager.OnAllIn(currentGamePlayer.userIndex, currentGamePlayer.stageBet, currentGamePlayer.buyInLeft); } else { manager.OnRaise(currentGamePlayer.userIndex, currentGamePlayer.stageBet, raiseBetAmount); } isClickable = false; }); this.view.OnCheckButtonClicked.Where(_ => isClickable).Subscribe(_ => { manager.OnCheck(currentGamePlayer.userIndex); isClickable = false; }); this.view.OnFoldButtonClicked.Where(_ => isClickable).Subscribe(_ => { manager.OnFold(currentGamePlayer.userIndex); isClickable = false; }); this.view.OnToLobbyButtonClicked.Subscribe(_ => { manager.StandUp(UserData.Instance.userIndex); }); this.view.OnStandUpButtonClicked.Subscribe(_ => { manager.StandUp(UserData.Instance.userIndex); }); GameEvent.Instance.AddPlayerTurnEvent(OnPlayerTurnEvent); GameEvent.Instance.AddClearEvent(OnClearAll); }