Hi!
Iv got AC set up to run 2 players, turn based style. Now I want the players to be able to trade items with eachother. I set up a Unity UI menu and create a list of inventory items and buttons.
I keep track of the items the player wants to trade in List<InvItem> OtherPlayerItemList. Below is the code for the function I call when the player clicks the "trade" button:
public void ProcessSwitchButtonClick()
{
//depending on which player is currently active...
if(KickStarter.player.ID == 0)
{
//...we look at the list of items that this player wants to get rid of...
foreach(InvItem invI in OtherPlayerItemList)
{
if(invI != null)
{
//...and gives them to the other player.
KickStarter.runtimeInventory.Add(invI.id,1,false,1);
KickStarter.runtimeInventory.Remove(invI);
}
}
}
else
{
foreach(InvItem invI in OtherPlayerItemList)
{
if(invI != null)
{
KickStarter.runtimeInventory.Add(invI.id,1,false,0);
KickStarter.runtimeInventory.Remove(invI);
}
}
}
}
Now what I found out through putting in some Traces, is that the KickStarter.runtimeInventory.Add() part works perfectly, but the KickStarter.runtimeInventory.Remove() doesnt. It leaves the items in. What am I doing wrong?
Comments