public static void Instantiate(GameObject Prefab, GameObject parent, TradingOffer source, bool canAccept) { TradeOfferListingController tradeOfferRepresentation = Instantiate(Prefab, parent.transform).GetComponent <TradeOfferListingController>(); Player sourcePlayer = GameManager.Instance.GetPlayerOfId(source.Owner); string sourcePlayerName; if (sourcePlayer) { sourcePlayerName = sourcePlayer.ToString(); } else { sourcePlayerName = source.Owner.ToString(); } tradeOfferRepresentation.Display.text = $"Spieler {sourcePlayerName}: Gebe {source.OfferedAmount} x {Translationhelper.Get(source.OfferedResource.ToString())} für {source.RequestedAmount} x {Translationhelper.Get(source.RequestedResource.ToString())}"; if (source.Owner == Player.LocalPlayer.netId) { tradeOfferRepresentation.ButtonText.text = "Zurückziehen"; tradeOfferRepresentation.SelfOwn = true; } else if (!canAccept) { tradeOfferRepresentation.AcceptButton.interactable = false; } tradeOfferRepresentation.source = source; }
public void SelectOfferList() { Show(); DisableAllViews(); OfferListView.SetActive(true); SetCloseBackButtonToBackMode(); foreach (Transform child in TradeOfferListRoot.transform) { Destroy(child.gameObject); } foreach (TradingOffer offer in GameManager.Instance.StockExchange.Offers) { int index = Player.LocalPlayer.Diplomacy.PlayerRelationships.Find(offer.Owner); bool isInAlliance = index != -1 && (Player.LocalPlayer.Diplomacy.PlayerRelationships[index].State == RelationshipState.TradingAgreement || Player.LocalPlayer.Diplomacy.PlayerRelationships[index].State == RelationshipState.Alliance); bool canAccept = Player.LocalPlayer.Resources.HasResources(offer.RequestedAsResourceInfoList); TradeOfferListingController.Instantiate(TradeOfferListingPrefab, TradeOfferListRoot, offer, canAccept && isInAlliance); } }