Hi guys im having a error in down script and i cant figure it out wts going wrong:
Assets/Scripts/DataBase/Items/RPGItemDatabase.cs(19,56): error CS1922: A field of property ‘BaseItem’ cannot be initialized with a collection object initializer because type ‘BaseItem’ does not implement 'System.Collections.IEnumeration’Interface
Can someone help plz? Appreciate.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.IO;
public class RPGItemDatabase : MonoBehaviour
{
public TextAsset itemInventory;
public static List<BaseItem> inventoryItems = new List<BaseItem>();
private List<Dictionary<string, string>> inventoryItemsDictionary = new List<Dictionary<string, string>> ();
private Dictionary<string, string> inventoryDictionary;
void Awake()
{
ReadItemsFromDatabase ();
for (int i=0; i<inventoryItemsDictionary.Count; i++) {
inventoryItems.Add(new BaseItem{inventoryItemsDictionary[i]});
}
}
public void ReadItemsFromDatabase()
{
XmlDocument xmlDocument = new XmlDocument ();
xmlDocument.LoadXml (itemInventory.text);
XmlNodeList itemList = xmlDocument.GetElementsByTagName ("Item");
foreach (XmlNode inteInfo in itemList) {
XmlNodeList itemContent = inteInfo.ChildNodes;
inventoryDictionary = new Dictionary<string, string>(); //ItemName: TestItem
foreach(XmlNode content in itemContent){
switch(content.Name){
case "ItemName":
inventoryDictionary.Add("ItemName", content.InnerText);
break;
case "ItemID":
inventoryDictionary.Add("ItemID", content.InnerText);
break;
case "ItemType":
inventoryDictionary.Add("ItemType", content.InnerText);
break;
}
}
inventoryItemsDictionary.Add(inventoryDictionary);
}
}
}