// Update is called once per frame void Update() { if (Input.GetKeyDown(trigger)) { DadCell cell2 = this.GetComponentInParent <DadCell>(); ClickItem item = cell2.GetComponentInChildren <ClickItem>(); if (item != null) { if (item.type == ClickItem.Type.consumable) { DadItem.eat(cell, item); } if (item.type == ClickItem.Type.weapon) { if (item.value == 1) { DadItem.attack(cell, item); } if (item.value == 2) { DadItem.burn(cell, item); } } } } }
/// <summary> /// Raises the pointer click event. /// </summary> /// <param name="eventData">Event data.</param> public void OnPointerClick(PointerEventData eventData) { DadCell cell = this.GetComponentInParent <DadCell>(); if (cell.loc == DadCell.Location.crate) { DadCell[] cells = FindObjectsOfType <DadCell>(); for (int i = 0; i < cells.Length; i++) { if (cells[i].GetDadItem() == null && cells[i].loc == DadCell.Location.backpack) { if (cell.GetComponentInChildren <ClickItem>().type == Type.scroll) { int win = 0; DadCell[] cellsI = FindObjectOfType <DummyInventoryControl>().inventory.GetComponentsInChildren <DadCell>(); for (int j = 0; j < cellsI.Length; j++) { if (cellsI[j].GetItem() != null && cellsI[j].GetComponentInChildren <ClickItem>().type == ClickItem.Type.scroll) { win++; } } if (win == 8) { TimeController.butterflies = 9; SceneManager.LoadScene("DeathScene"); } } cells[i].AddItem(cell.GetItem()); cell.RemoveItem(); cell.UpdateBackgroundState(); break; } } } else if (cell.loc == DadCell.Location.backpack && this.type == Type.consumable) { DadItem.eat(cell, this); } else if (cell.loc == DadCell.Location.backpack && this.type == Type.weapon) { DadCell[] cells = FindObjectsOfType <DadCell>(); for (int i = 0; i < cells.Length; i++) { if (cells[i].GetDadItem() == null && cells[i].loc == DadCell.Location.body) { cells[i].AddItem(cell.GetItem()); cell.RemoveItem(); cell.UpdateBackgroundState(); break; } } } }