/// <summary> /// Deactivate the trade panel and apply linked actions whether there was a deal or not (actions are applied only to the current location). /// </summary> /// <param name="tradePanel">The related trade panel.</param> /// <param name="deal">If a deal was concluded or not.</param> /// <param name="resLabels">All resource labels from trade panel.</param> public static void CloseTradePanel(GameObject tradePanel, bool deal, List <Text> resLabels) { if (deal) { Dictionary <ResourceType, int> resWanted = PlayerBoardController.GetAllResourcesToTrade(resLabels); Player.City.BuyResources(resWanted, CurrentTrade); PlayerBoardController.RefreshCoinAmount(); tradePanel.SetActive(false); TradeBoard boardToUpdate; if (CurrentTrade == CityManager.TradeLocation.WEST) { boardToUpdate = LeftTradeBoard; LeftTradeBoard.CleanBoard(); } else { boardToUpdate = RightTradeBoard; RightTradeBoard.CleanBoard(); } foreach (KeyValuePair <ResourceType, int> resource in resWanted) { for (int i = 0; i < resource.Value; i++) { boardToUpdate.AddResource(resource.Key); } } } else { tradePanel.SetActive(false); } }
/// <summary> /// Clean all trade boards (i.e. at the end of a turn). /// </summary> public static void CleanTradeBoards() { LeftTradeBoard.CleanBoard(); RightTradeBoard.CleanBoard(); }