private void OnTradeBtn(Button b, TradeActions action, Direction counterOffer) { PlayerTrade playerTrade = null; foreach (KeyValuePair <PlayerTrade, Button> valuePair in _incomingTradeDictionary) { if (valuePair.Value == b) { playerTrade = valuePair.Key; } } foreach (KeyValuePair <PlayerTrade, Button> valuePair in _outgoingTradeDictionary) { if (valuePair.Value == b) { playerTrade = valuePair.Key; } } if (playerTrade == null) { throw new Exception("We got a problem bois..."); } switch (action) { case TradeActions.TradeRejected: playerTrade.RejectTrade(_playerController); break; case TradeActions.TradeAccepted: playerTrade.AcceptTrade(counterOffer, _playerController); break; case TradeActions.TradeCanceled: playerTrade.CancelTrade(_playerController.playerTag); break; case TradeActions.TradeCanceledByGameHandler: playerTrade.CancelTrade(GameHandler.Current); break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }
public void AcceptButton() { _trade.AcceptTrade(_counterOffer, _playerController); }