public int space = 10; // Amount of item spaces //void Start() //{ // if (inventoryType == InventoryType.NULL) // Debug.LogError("inventory type of " + name + " is null"); // else if (inventoryType == InventoryType.Player) // { // UI = UIController.instance.inventoryUI.GetComponent<UIforInventory>(); // SetInventoryToUI(); // } // else if (inventoryType == InventoryType.Trader) // { // UI = UIController.instance.tradeUI.GetComponentInChildren<UIforInventory>(); // if (UI.inventory == null) // SetInventoryToUI(); // } //} //public void SetInventoryToUI() //{ // if (inventoryType == InventoryType.Player) // { // UIController.instance.playerInventory = this; // } // else if (inventoryType == InventoryType.Trader) // { // UIController.instance.traderInventory = this; // } // UI.inventory = this; // onItemChangedCallback += UI.UpdateUI; // UI.UpdateUI(); //} public void SetInventoryToUI() { if (inventoryType == InventoryType.NULL) { Debug.LogError("inventory type of " + name + " is null"); } else if (inventoryType == InventoryType.Player) { UI = UIController.instance.inventoryUI.GetComponent <UIforInventory>(); UIController.instance.playerInventory = this; } else if (inventoryType == InventoryType.Trader) { UI = UIController.instance.tradeUI.GetComponentInChildren <UIforInventory>(); UIController.instance.traderInventory = this; } else if (inventoryType == InventoryType.Loot) { UI = UIController.instance.lootUI.GetComponentInChildren <UIforInventory>(); UIController.instance.lootInventory = this; } UI.inventory = this; onItemChangedCallback += UI.UpdateUI; UI.UpdateUI(); }
//public bool AddItem(Item item) //{ // if (SpaceEnough()) // { // Items.Add(item); // UNDONE Update UI // return true; // } // return false; //} //public void RemoveItem(Item item) //{ // Items.Remove(item); // //UNDONE Update UI //} void OnLevelWasLoaded(int level) { //1 - global map //2 - battle Map if (type == InventoryType.Player) { if (level == 1) { UI = UIGlobalMap.instance.PlayerInventoryUI.GetComponent <UIforInventory>(); UI.CurrentInventory = this; } if (level == 2) { UI = UIBattleMap.instance.PlayerInventory.GetComponent <UIforInventory>(); UI.CurrentInventory = this; } } }
public void SetInventoryToUI(UIforInventory ui) { UI = ui; UI.CurrentInventory = this; }