public IEnumerator ProcessTradeOffer (TradeOffer offer) { // wait for 2 frames, incase this was a counter offer yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); Debug.Log (playerName+": Trade Offer Recieved"); // process trade offer isProcessingTradeOffer = true; Debug.Log (playerName+": Processing Trade Offer..."); OnTradeOfferRecieved(offer); while(isProcessingTradeOffer == true){ yield return new WaitForEndOfFrame(); } Debug.Log (playerName+": Done processing trade offer..."); // did we accept? if(didAcceptTrade == true){ // make the swap Debug.Log ("YAY TRADE ACCEPTED"); // get all the data from the trade GamePlayer senderPlayer = offer.GetSender(); GamePlayer recieverPlayer = offer.GetReciever(); BoardTile senderProperty = offer.GetSenderProperty(); BoardTile recieverProperty = offer.GetRecieverProperty(); // swap the funds senderPlayer.money += offer.recieverFunds; senderPlayer.money -= offer.senderFunds; recieverPlayer.money += offer.senderFunds; recieverPlayer.money -= offer.recieverFunds; // swap the properties senderPlayer.RemoveProperty(senderProperty); recieverPlayer.RemoveProperty(recieverProperty); senderPlayer.AddProperty(recieverProperty); recieverPlayer.AddProperty(senderProperty); // notify the sender that the trade was accepted senderPlayer.TradeOfferAccepted(); UpdateOwnedProperties(); Debug.Log ("Trade Complete!"); } else{ // nothing happens, trade failed offer.GetSender().TradeOfferDeclined(); Debug.Log ("TRADE REJECTED"); } }