public void ShowOfferResponse(int[] resourcesDesired, int fromIndex) { Player localPlayer = GameObject.Find("Local Player Panel").GetComponent <Player> (); transform.GetChild(6).gameObject.GetComponent <Button> ().interactable = true; for (int i = 0; i < 8; i++) { if (localPlayer.resources [i] + resourcesDesired [i] < 0) { transform.GetChild(6).gameObject.GetComponent <Button> ().interactable = false; } resourcesDisplay [i].text = (localPlayer.resources [i] + resourcesDesired [i]).ToString(); if (resourcesDesired [i] >= 0) { resourcesDesiredDisplay [i].text = resourcesDesired [i].ToString(); resourcesOfferedDisplay [i].text = "0"; } else { resourcesOfferedDisplay [i].text = (-resourcesDesired [i]).ToString(); resourcesDesiredDisplay [i].text = "0"; } } resourcesDesiredDisplay [8].text = "0"; resourcesOfferedDisplay [8].text = "0"; tradeDelegate = delegate { localPlayer.CmdAcceptTradeOffer(resourcesDesired, fromIndex); gameObject.SetActive(false); }; }
public void ReceiveTradeOffer(int[] resourcesDesired, int fromIndex) { isRespondingTradeOffers = true; gameObject.SetActive(true); transform.GetChild(7).gameObject.SetActive(true); transform.GetChild(8).gameObject.SetActive(false); InitiateTradeOffer(); PrepareTradeWithPlayer(); transform.GetChild(7).GetChild(0).gameObject.GetComponent <Button> ().interactable = false; for (int i = 0; i < 9; i++) { ForceModifyOffer(i, -resourcesDesired [i]); } //show where does the offer come from transform.GetChild(7).GetChild(1 + fromIndex).gameObject.SetActive(true); transform.GetChild(7).GetChild(1 + fromIndex).GetChild(2).gameObject.SetActive(true); tradeDelegate = delegate { GameObject.Find("Local Player Panel").GetComponent <Player> ().CmdResponseTradeOffer(resourcesOffered.ToArray(), fromIndex); gameObject.SetActive(false); isRespondingTradeOffers = false; }; List <int> tempList = new List <int> (); for (int i = 0; i < 8; i++) { tempList.Add(0); } transform.GetChild(5).gameObject.GetComponent <Button> ().onClick.AddListener(delegate { GameObject.Find("Local Player Panel").GetComponent <Player> ().CmdResponseTradeOffer(tempList.ToArray(), fromIndex); transform.GetChild(5).gameObject.GetComponent <Button> ().onClick.RemoveAllListeners(); isRespondingTradeOffers = false; }); }
public void PrepareTradeWithBack() { tradeDelegate = OfferTradeToBank; isTradingWithPlayers = false; tradeInstancePrimary = 0; Player localPlayer = GameObject.Find("Local Player Panel").GetComponent <Player> (); for (int i = 0; i < 8; i++) { transform.GetChild(8).GetChild(i + 1).gameObject.GetComponent <Text> ().text = "1:" + localPlayer.tradeRatios [i].ToString(); tradeRatios [i] = localPlayer.tradeRatios [i]; } if (localPlayer.hasMerchant) { Hex merchantAt = GameObject.Find("GameBoard").GetComponent <GameBoard> ().merchant.transform.parent.gameObject.GetComponent <Hex> (); transform.GetChild(8).GetChild((int)merchantAt.Product() + 1).gameObject.GetComponent <Text> ().text = "1:2"; tradeRatios [(int)merchantAt.Product()] = 2; } if (localPlayer.merchantFleet) { for (int i = 0; i < 8; i++) { transform.GetChild(8).GetChild(i + 1).gameObject.GetComponent <Text> ().text = "1:2"; tradeRatios [i] = 2; } } buttonDesiring [8].interactable = false; buttonOffering [8].interactable = false; }
public void PrepareTradeWithPlayer() { foreach (Button b in buttonOffering) { b.interactable = true; } foreach (Button b in buttonDesiring) { b.interactable = true; } tradeDelegate = OfferTradeToPlayers; isTradingWithPlayers = true; tradeInstancePrimary = 0; tradeInstanceSecondary = 0; Transform tradingWithPlayers = transform.GetChild(7); tradingWithPlayers.GetChild(0).gameObject.GetComponent <Button> ().interactable = true; for (int i = 1; i < 5; i++) { tradingWithPlayers.GetChild(i).gameObject.SetActive(false); for (int j = 0; j < tradingWithPlayers.GetChild(i).childCount - 1; j++) { tradingWithPlayers.GetChild(i).GetChild(j).gameObject.SetActive(false); tradingWithPlayers.GetChild(i).GetChild(j).gameObject.GetComponent <Button> ().onClick.RemoveAllListeners(); } } }
public void RunTradeDelegate() { if (tradeDelegate != null) { tradeDelegate(); tradeDelegate = null; } }
public TradeWorker() { IncomingTradeDelegate = new TradeDelegate(IncomingTrade); OutgoingTradeDelegate = new TradeDelegate(OutgoingTrade); client = new functions(); if (File.Exists("account.maFile")) { accountFileExist = true; //Загружаем данные от мобильного аккаунта _mobileAccount = JsonConvert.DeserializeObject <SteamGuardAccount>(File.ReadAllText("account.maFile")); } if (File.Exists("config.json")) { _config = Config.Reload(); if (!string.IsNullOrEmpty(_config.SteamLogin) && !string.IsNullOrEmpty(_config.SteamPassword)) { Auth(); } } }