// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) && isActiveBau == true) { if (Input.GetKeyDown(KeyCode.Space) && fullBau == true) { foreach (AudioSource objeto in Object.FindObjectsOfType(typeof(AudioSource))) { if (objeto.tag != "Som") { objeto.Stop(); nullItem.Play(); } } return; } encontrouBau.Play(); currentSlot = inventory.selectSlot(); Debug.Log("Encontrou baú"); itemAux = findItem(); itemAux.getAudioNome().PlayDelayed(2); // informa o item achado currentSlot.setItemSlot(itemAux); Debug.Log("Você encontrou " + itemAux.getNome()); inventory.addItemSlot(itemAux, currentSlot); } }
//adiciona um item ao slot public void AddItem(PickupItens item) { bool found = false; //procurador de item stackable SlotInventory empty = NextEmptySlot(); //proximo slot vazio //se o item a adicionar vor stackable if (item.isStack) { //checa em todos os slots foreach (SlotInventory slot in invSlot) { //se ha um slot ocupado com o mesmo item if (slot.item != null && slot.item.itemName == item.itemName) { //caso sim almenta a quantia de item slot.item.AddItem(); found = true; //e diz que o item foi encontrado } } //caso o item nao foi encontrado e o slot for vaziu if (!found && empty != null) {//adiciona o item if (pl.GetComponent <PlayerUIController>().shopping) { item.AddItem(1, true); } empty.item = item; } }//caso o item nao for stackable else if (empty != null) {//o adiciona no proximo slot vaziu empty.item = item; } }
//equipa um item public void EquipItem() { EquipamentControll.instance.Equip(selectedSlot.item.type, selectedSlot.item); selectedSlot.item.Use(); selectedSlot.SetUpSlot(); SetOffOptButtons(); selectedSlot = null; }
public void SellItem() { int sellPrice = selectedSlot.item.ItemPrice() / 2; money += sellPrice; selectedSlot.item.AfterUse(); selectedSlot.SetUpSlot(); SetOffOptButtons(); selectedSlot = null; }
public bool slotFull(SlotInventory slot, int pos) { for (int i = 0; i < inventoryItems.Count; i++) { if (pos == i && slot.getSlotFull()) { return(true); } } return(false); }
public void addItemSlot(ItemBase item, SlotInventory slot) // adiciona item no slot { for (int i = 0; i < inventoryItems.Count; i++) { if (slot.getSlotFull() == false) { slot.setItemSlot(item); slot.setSlotFull(true); slot.setNameItem(item.getNome()); } } }
public void removeItemSlot(int index, bool remv) { if (remv == true) { ItemBase itemNovo = null; for (int i = 0; i < inventoryItems.Count; i++) { inventoryItems[index].setItemSlot(itemNovo); slotController = inventoryItems[index]; slotController.setSlotFull(false); slotController.setNameItem(null); } } }
//procura o primeiro slot vazio da lista private SlotInventory NextEmptySlot() { SlotInventory slotReturn = null; //checa cada slot do inventario foreach (SlotInventory slot in invSlot) { //e caso nao tenha item if (slot.item == null) { //a variavel de retorno recebe o slot slotReturn = slot; break; } } return(slotReturn); }
public void bossDead(int index) { monstroMorreu.PlayDelayed(index); Debug.Log("monstro morreu"); GameController.changeState(GAME_STATE.IN_EXPLORATION); jogador.setXP(jogador.getXP() + enemy.getXPBoss()); //abilitaAreas(); ValidaTeclas.changeStateButton(BUTTON_STATE.IN_DEFFAULT); slotVazio = inventory.selectSlot(); inventory.addItemSlot(dropItem(), slotVazio); if (jogador.getXP() >= 100) { Debug.Log("Atualizando status jogador"); int nivelAtual = jogador.getNivel(); atualizaStatusJogador(nivelAtual + 1); } return; }
public void QuestChecker(string checker, SlotInventory itemSlot) { foreach (QuestSlot slot in questSlot) { if (slot != null && slot.quest != null && slot.quest.task.objName == checker) { if (slot.quest.task.type == TaskType.Gathering && itemSlot != null) { slot.InvQuestItem(itemSlot); } if (slot.quest.task.type == TaskType.Kill) { slot.AddKillAmount(); break; } } } }
//joga item fora public void DropItem() { //referencia do item GameObject drop = selectedSlot.item.itemPrefab; //checa se o item em questao tem a referencia do inventario, caso nao o adiciona if (drop.GetComponent <PickupItens>().inventory == null) { drop.GetComponent <PickupItens>().inventory = GameObject.Find("UIInventory").GetComponent <InventoryControll>(); } //dropa o item e o posiciona no mapa perto do personagem jogador, e o cria dentro do objeto de controles de itens dropados na cena drop.GetComponent <PickupItens>().Dropped(drop); ShowAndHide tr = FindObjectOfType(typeof(ShowAndHide)) as ShowAndHide; Instantiate(drop, pl.transform.position + new Vector3(1, 0, 1), drop.transform.rotation, tr.gameObject.transform); //e apos isso finaliza o uso do item selectedSlot.item.AfterUse(); SetOffOptButtons(); selectedSlot = null; }
private void Start() { Instance = this; SetSlotInventory(); }
// Use this for initialization void Start() { instance = this; }
private void OnDisable() { selectedSlot = null; }
public void InvQuestItem(SlotInventory slotItem) { quest.task.GatheringSlot(slotItem.item.InventoryAmount() + 1); }
private void OnEnable() { selectedSlot = null; }
public void addSlotToInventory(SlotInventory slot) { inventoryItems.Add(slot); }