public void OnEnable() { // usedIndex = new int[ItemTable.keys[ItemTable.keys.Length-1] + 1]; itemList = GetComponent <ItemTable>(); usedIndex = ItemTable.keys; if (!Load()) { foodData = 0; goldData = 0; researchData = 0; suppliesData = 0; Debug.Log("Size is: " + (ItemTable.keys[ItemTable.keys.Length - 1] + 1)); //remove later // inventory = new int[itemList.Size]; inventory = new int[ItemTable.keys[ItemTable.keys.Length - 1] + 1]; // while(inventory.Count < inventory.Capacity){ // inventory.Add(0); // } // usedIndex = ItemTable.keys; listData = new HunterList(); } }
public bool Load() { // Debug.Log (Application.persistentDataPath); if (File.Exists(Application.persistentDataPath + "/gameInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gameInfo.dat", FileMode.Open); GameData data = (GameData)bf.Deserialize(file); file.Close(); foodData = data.food; goldData = data.gold; researchData = data.research; suppliesData = data.supplies; listData = new HunterList(data.list); // inventory = new int[](data.inventory); inventory = data.inventory; // usedIndex = data.usedIndex; // if(inventory.Count < itemList.Size){ // // inventory = new int[itemList.Size]; // Debug.Log("Load Failed!"); // return false; // } Debug.Log("Load Success!"); Debug.Log("Count is: " + data.list.Count); return(true); } Debug.Log("Load Failed!"); return(false); }
public ListCast(HunterList list) { this.hunterList = list.hunterList; this.nextSerial = list.NextSerial; }