public void setItemListDictionary(Dictionary<Item.Type, List<Item>> listDictionary)
{
bool isChanged = !inventory.activeSelf;
if (isChanged) {
inventory.SetActive (true);
}
foreach (KeyValuePair<Item.Type, string> pair in itemTags) {
GameObject[] holders = GameObject.FindGameObjectsWithTag (pair.Value);
List<Item> items = new List<Item> ();
foreach (Item item in listDictionary [pair.Key]) {
items.Add (item);
}
int listCount = 0;
for (int i = 0; i < holders.Length; i++) {
ItemTemplate holder = holders [i].GetComponent<ItemTemplate> ();
if (holder != null) {
holder.RemoveItem ();
if (pair.Key == Item.Type.Skill) {
// special case for skill gem
for (int j = 0; j < items.Count; j++) {
if (holder.index == items[j].itemIndex) {
this.addSkillGem (holder.index, (Gem) items[j]);
holder.SetItem (items[j]);
items.RemoveAt (j);
break;
}
}
} else {
// general case
if (listDictionary [pair.Key].Count > listCount) {
Item item = listDictionary [pair.Key] [listCount];
holder.SetItem (item);
listCount++;
}
}
}
}
// Debug.Log (itemTags [i] + holders.Length.ToString ());
}
if (isChanged) {
inventory.SetActive (false);
}
this.itemListDictionary = listDictionary;
foreach (KeyValuePair<Item.Type, List<Item>> pair in itemListDictionary) {
Debug.Log (pair.Key.ToString () + ":" + pair.Value.Count.ToString ());
}
}