private void OnMouseOver() { if (descriptionBox) { descriptionBox.gameObject.SetActive(true); descriptionBox.itemName.text = itembase.cardName; descriptionBox.itemDescription.text = itembase.cardDescription; descriptionBox.itemType.text = itembase.cardType; if (itembase is Weapon) { Weapon weapon = (Weapon)itembase; descriptionBox.weaponDamage.text = "Damage: " + weapon.damage.ToString(); descriptionBox.weaponDurability.text = "Durability: " + lifeTime + " / " + weapon.lifetime; } } if (Input.GetMouseButtonDown(1)) { descriptionBox.gameObject.SetActive(false); theInv.RemoveFromInventory(inventoryIndex); } if (Input.GetMouseButtonDown(0) && itembase is Consumable) { Consumable consumable = (Consumable)itembase; consumable.Consume(FindObjectOfType <Player>()); descriptionBox.gameObject.SetActive(false); theInv.RemoveFromInventory(inventoryIndex); } }
private void Eat(Consumable food) { float amount = consumptionSpeed * Time.deltaTime; food.Consume(amount); brain.stomach.AddFood(amount); //Inately connects to the Stomach }
///<summary>This Method should be called by the Inventory Buttons</summary> public void InteractWithInventoryUI(Item invItem) { if (invItem != null) { if (invItem is Consumable) { Consumable consItem = (Consumable)invItem; Debug.Log("Item"); consItem.Consume(null); inventory.RemoveItem(invItem, 1); inventoryUIConnection.UpdateInventoryUI(); return; } if (invItem is Armor) { for (int i = 0; i < equipmentSlotArray.Length; i++) { if (equipmentSlotArray[i] != null) { if (equipmentSlotArray[i].slot.ToString() == invItem.equipmentSlot.ToString()) { equipmentSlotArray[i].Equip((Armor)invItem); return; } } else { Debug.Log("equipmentSlotArray " + i + " is null"); return; } } } if (invItem is Weapon) { Debug.Log("Weapon"); for (int i = 0; i < equipmentSlotArray.Length; i++) { if (equipmentSlotArray[i] != null) { if (equipmentSlotArray[i].slot.ToString() == invItem.equipmentSlot.ToString()) { equipmentSlotArray[i].Equip((Weapon)invItem); return; } } else { Debug.Log("equipmentSlotArray " + i + " is null"); return; } } } } }
public void ConsumeItem(Int32 p_slot, Int32 p_targetCharacter) { BaseItem itemAt = GetItemAt(p_slot); if (itemAt is Consumable) { Consumable consumable = (Consumable)itemAt; consumable.Consume(new InventorySlotRef(this, p_slot), p_targetCharacter); } }
private bool HandleUseConsumable(out string result, StoredObject storedObject) { result = ""; Consumable consumable = Player.I.gameObject.AddComponent(storedObject.objectType) as Consumable; if (consumable == null) { return(false); } consumable.Consume(out result); return(true); }
private void Consume(Consumable item) { if (item.cantidad > 0) { item.Consume(); item.cantidad -= 1; } else { Debug.Log("No tienes PowerUPs"); } }
public void DoInteraction(GameObject player) { if (consumed) { return; } consumed = true; if (dissolve) { StartCoroutine(DissolveTransition(0, 1, 1)); } if (destroy) { Destroy(gameObject, dissolveTime); } if (interaction == action.Consumable && consumeRef != null) { consumeRef.Consume(player); } }
public void ConsumeItem(int i) { Consumable consumable = (Consumable)inventory.items[i]; consumable.Consume(this); }
/// <summary> /// Logic to be executed on enemy turn /// </summary> /// <param name="targets">List of possible targets</param> private void OnEnemyTurn(List <BattleEntity> targets) { target = GetTarget(targets); currentAttack = DetermineAttackScore(target); consumable = DetermineConsumableScore(); node = DetermineMoveScore(target, canAttack: currentAttack != null, canConsume: consumable != null); //print("A-score: " + attackingScore + " C-score: "+ consumableScore + " M-Score: "+moveScore); //If enemy cant do anything just end turn if (currentAttack == null && (consumable == null || consumableScore <= 0) && !canMove) { RaiseEndTurnEvent(); } state = GetState(); switch (state) { case State.Attack: print("Attacking..."); if (currentAttack != null && moveForAttack) //TODO remove the first condition { Node nodeToMoveTo = null; List <Node> movementRangeNodes = Pathfinding.GetRange(battleController.Nodes, nodeParent, (data.Speed)); int minDistance = int.MaxValue; for (int i = 0; i < movementRangeNodes.Count; i++) { if (nodeParent != movementRangeNodes[i] && target.nodeParent != movementRangeNodes[i]) { List <Node> attackRangeNodes = Pathfinding.GetRange(battleController.Nodes, movementRangeNodes[i], currentAttack.Range); int currentDistance = Pathfinding.GetDistance(target.nodeParent, movementRangeNodes[i]); if (currentDistance < minDistance) { minDistance = currentDistance; nodeToMoveTo = movementRangeNodes[i]; } } } List <Node> path = Pathfinding.FindPath(nodeParent, nodeToMoveTo, reverse: true); for (int i = 0; i < path.Count; i++) { int distance = Pathfinding.GetDistance(path[i], target.nodeParent); if (distance <= currentAttack.Range) { path = Pathfinding.FindPath(nodeParent, path[i], reverse: true); break; } } SetPathNodes(path); node = path[path.Count - 1]; checkForLocationReached = true; } else if (currentAttack != null) { Attack.AttackTarget(currentAttack, target); RaiseEndTurnEvent(); } break; case State.Consumable: print("consuming"); consumable.Consume(this); data.Consumables.Remove(consumable); print("Consuming " + consumable.Name); consumable = null; //TODO allow selecting other targets(party members) RaiseEndTurnEvent(); break; case State.Move: print("Moving..."); List <Node> _path = Pathfinding.FindPath(nodeParent, node, reverse: true); if (_path != null) { SetPathNodes(_path); node = _path[_path.Count - 1]; } checkForLocationReached = true; break; } }
/// <summary> /// Consumes <see cref="SelectedPotion"/> and destroys it /// </summary> public override void Consume() { SelectedPotion.Consume(); base.Consume(); Destroy(SelectedPotion.gameObject); }