public void CloseContainer(playerBase player) { CanvasGroup panel; GUIController gui; gui = player.GetComponentInParent<InputManager>().gui; panel = gui.ContainerPanel; gui.Container = null; StartCoroutine(gui.fadeOut(panel)); gui.ToggleInventory(false); }
public void DoAction(playerBase player) { GlobalSettings.PrintDebug("Clicked on container " + ContainerName); CanvasGroup panel; GUIController gui; gui = player.GetComponentInParent<InputManager>().gui; panel = gui.ContainerPanel; if (gui.Container == null) { gui.Container = this; panel.transform.FindChild("Details").FindChild("Header").GetComponent<Text>().text = ContainerName; for (int r = 0; r < Storage.Rows; r++) { for (int c = 0; c < Storage.Cols; c++) { GameObject slot = (GameObject)Instantiate(Resources.Load("emptySlot")); //slot.transform.SetParent.transform.FindChild("SlotHolder")); slot.transform.SetParent(panel.transform.FindChild("SlotHolder")); slot.GetComponent<RectTransform>().anchoredPosition = new Vector2(64 * c, -64 * r); // slot.GetComponent<Transform>().position = new Vector3(slot.transform.position.x, slot.transform.position.y, 0); slot.name = "X" + c + "Y" + r; slot.GetComponent<slotScript>().x = c; slot.GetComponent<slotScript>().y = r; slot.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1); slot.GetComponent<RectTransform>().localPosition = new Vector3(slot.GetComponent<RectTransform>().localPosition.x, slot.GetComponent<RectTransform>().localPosition.y, 0); Storage.Slots[c, r] = slot.GetComponent<slotScript>(); slot.GetComponent<slotScript>().slotNum = Storage.Slots[c, r].ToString(); } } panel.GetComponent<RectTransform>().sizeDelta = new Vector2(64 * Storage.Cols, (64 * Storage.Rows) + 30); StartCoroutine(gui.fadeIn(panel)); gui.ToggleInventory(true); } else { GlobalSettings.PrintDebug("Can't open two containers!"); } //inventoryHeader.text = "Inventory - " + Player.PlayerData.Name; //GlobalSettings.PrintDebug(item.ToString()); //storageBase inv = player.PlayerData.Inventory; //if (inv.CheckAvailableSlots(item)) // Destroy(gameObject); }