public void UpdateTradePlayers(Player player) { curr_player = player; toggle_box.isOn = true; SetCurrentContainer(true); foreach (GameObject go in inventory_objects) { Destroy(go); } inventory_objects.Clear(); player_name.text = curr_player.player_name; name_background.color = curr_player.player_faction.color; foreach (KeyValuePair <String, int> kvp in curr_player.inventory.GetAllItems()) { if (kvp.Value == 0) { continue; } GameObject new_inv_object = Instantiate(trade_obj_prefab); TradeUICell tcell = new_inv_object.GetComponent <TradeUICell>(); tcell.UpdateStats(kvp.Key, kvp.Value, curr_player.inventory.GetTradeItemCount(kvp.Key)); tcell.linked_player = curr_player; new_inv_object.transform.SetParent(grid_container.transform); tcell.GetComponent <RectTransform>().localScale = Vector3.one; inventory_objects.Add(new_inv_object); } int otherPlayerIdx = select_player.value; UpdateDropdown(otherPlayerIdx); UpdateOtherContainer(otherPlayerIdx); }
public void UpdateOtherContainer(int other) { other_player = otherPlayerList[other]; foreach (GameObject go in other_inventory_objects) { Destroy(go); } other_inventory_objects.Clear(); ColorBlock temp = select_player.colors; temp.normalColor = other_player.player_faction.color; temp.highlightedColor = other_player.player_faction.color; temp.selectedColor = other_player.player_faction.color; select_player.colors = temp; foreach (KeyValuePair <String, int> kvp in other_player.inventory.GetAllItems()) { if (kvp.Value == 0) { continue; } GameObject new_inv_object = Instantiate(trade_obj_prefab); TradeUICell tcell = new_inv_object.GetComponent <TradeUICell>(); tcell.UpdateStats(kvp.Key, kvp.Value, other_player.inventory.GetTradeItemCount(kvp.Key)); tcell.linked_player = other_player; new_inv_object.transform.SetParent(other_grid_container.transform); tcell.GetComponent <RectTransform>().localScale = Vector3.one; other_inventory_objects.Add(new_inv_object); } SetCurrentContainer(toggle_box.isOn); }