private void Update() { hit2D = Physics2D.Raycast(new Vector2(transform.position.x - 15, transform.position.y + 5), Vector2.right, 30f); if (hit2D && Input.GetKeyDown(KeyCode.E) && !WorldVariables.dialogueActive) { if (hit2D.collider.gameObject.tag == "Door") { Door door = hit2D.collider.gameObject.GetComponent <Door>(); door.Interact(this.gameObject); } else if (hit2D.collider.gameObject.tag == "Interactable") { Interactable inter = hit2D.collider.gameObject.GetComponent <Interactable>(); if (ps.Interact()) { inv.AddItem(inter.GetItem()); inter.CanInteract(false); } } else if (hit2D.collider.gameObject.tag == "Item") { FreeItem item = hit2D.collider.gameObject.GetComponent <FreeItem>(); inv.AddItem(item.id); Destroy(hit2D.collider.gameObject); } else if (hit2D.collider.gameObject.tag == "BackDoor") { BackDoor door = hit2D.collider.gameObject.GetComponent <BackDoor>(); door.Interact(this.gameObject); } } }
public void PerformAction(string action) { if (playerNear) { switch (action) { case "WOOD_CHUNK": if (!dead) { Inventory.DeselectItem(); Inventory.RemoveItem("WOOD_CHUNK"); Inventory.AddItem("BONE"); Inventory.SetText("Got Bone"); text.text = "<i>The skeleton excitedly takes the wood chunk\nand replaces it's own leg.\nIt seems happy.</i>"; normal.SetActive(false); pegleg.SetActive(true); gaveLeg = true; LookAtObject(player); } break; case "SPEAK": if (!dead) { player.SendMessage("TakeControl"); LookAtObject(player); AdvanceDialog(); } break; case "GRAB": Inventory.DeselectItem(); if (dead) { if (!gaveLeg) { Inventory.AddItem("BONE"); Inventory.SetText("You got a Bone..."); gaveLeg = true; } else { Inventory.SetText("You don't need another bone"); } } else { Inventory.SetText("You can't do that right now"); } break; } } else { Inventory.SetText("You are too far away for that"); } }
public void PerformAction(string action) { switch (action) { case "GRAB": if (playerNear) { Inventory.DeselectItem(); if (partTaken) { Inventory.SetText("Already got this part."); } else { Inventory.SetText("Found a plane part!"); Inventory.AddItem("PLANE_PART3"); partTaken = true; } } else { Inventory.SetText("Object is Too Far"); } break; } }
public void PerformAction(string action) { if (playerNear) { if (reachable) { switch (action) { case "GRAB": Destroy(gameObject); Inventory.DeselectItem(); Inventory.AddItem("CANNON_BALL"); Inventory.SetText("Got Metal Ball"); break; } } else { Inventory.SetText("It's too high to reach"); } } else { Inventory.SetText("Object is Too Far"); } }
public void createObject(int productID, int productAmount, int[] componentID, int[] componentAmount) { //Dictionary<Item, int> inventory = inventoryModel.inventory; // Does the inventory contains the components ? bool isCreatable = true; for (int k = 0; k < componentID.Length && isCreatable; k++) { // looping on the //ToDo use the controller with GetQuantity() if (countItemId(componentID[k]) < componentAmount[k]) { isCreatable = false; } } if (isCreatable && inventoryController.CanItFit(productID, productAmount)) { // Enough of every components // Adds the product a productAmount of times inventoryController.AddItem(productID, productAmount); GameObject.Find("Data").GetComponentInChildren <OtherStats>().CraftedItems++; // Remove the components for (int k = 0; k < componentID.Length; k++) {// looping on the components inventoryController.RemoveItem(componentID[k], componentAmount[k]); } } else { Debug.Log("Component not creatable"); } }
public void DeliverRewards() { using (var e1 = quest.RewardList.GetEnumerator()) using (var e2 = quest.RewardQuantityList.GetEnumerator()) { while (e1.MoveNext() && e2.MoveNext()) { inventoryController.AddItem(e1.Current, e2.Current); } } if (quest.IsMainQuest) { GameObject.Find("Data").GetComponentInChildren <QuestProgress>().questProgress++; } if (quest.Victory == 1) { SceneManager.LoadSceneAsync("HiveVictory", LoadSceneMode.Single); } else if (quest.Victory == 2) { SceneManager.LoadSceneAsync("AIRVictory", LoadSceneMode.Single); } else if (quest.Victory == 3) { SceneManager.LoadSceneAsync("SelfVictory", LoadSceneMode.Single); } GameObject.Find("QuestLog").GetComponent <QuestLogController>().UpdateQuestLog(); }
public static void AddItem(StoredItem s, bool quiet = false) { Item item = s.item; if (!quiet) { SoundManager.ItemGetSound(); if (!item.IsType(ItemType.ABILITY)) { if (s.count != 1) { AlerterText.Alert($"{item.name} ({s.count}) acquired"); } else { AlerterText.Alert(item.name + " acquired"); } } } if (item.gameStates != null) { AddStates(item.gameStates); } inventory.AddItem(s, quiet); PropagateItemChange(); }
private GameObject InteractWithObject(GameObject item, List <GameObject> inArray, AudioClip clip) { var addedItem = invController.AddItem(item); if (addedItem) { AudioSource.PlayClipAtPoint(clip, player.transform.position); inArray.Remove(item); if (currentMeleeWeapon == null) { if (item.name.Contains("Knife")) { MeleeWeapon = "Knife"; currentAttackType = "melee"; } } if (currentRangedWeapon == null) { if (item.name.Contains("Pistol")) { RangedWeapon = "Gun"; currentAttackType = "ranged"; } } this.player.GetComponent <StatusBarLogic>().SetWeapon(); return(item); } return(null); }
public static void AddItem(InventoryItem item) { if (!item.IsAbility()) { AlerterText.Alert(item.itemName + " acquired"); } inventory.AddItem(item); }
public override void Interact() { IItem item = (IItem)ScriptableObject.CreateInstance(itemName + "Item"); InventoryController.AddItem(item); SetChildrenEnabled(false); isPickedUp = true; }
/// <summary> /// Figures out the input of the user and applies it to the player, and changes the animation conditions depending on the input. /// </summary> void Update() { walkV = Input.GetAxisRaw("Vertical"); walkH = Input.GetAxisRaw("Horizontal"); switchInventory = Input.GetAxisRaw("Inventory Scroll"); action = Input.GetAxis("Action"); pick = Input.GetAxis("Pick"); if (animCon.animFinished) { if (switchInventory != 0) { walkV = 0; walkH = 0; movement = direction.forward; invCon.MoveInventory(switchInventory); animCon.SwitchInventory(); invCon.ShowItem(); } else if (action != 0 && invCon.currItem != null) { if (invCon.currItem.tag == "tool") { animCon.UseTool(invCon.currItem.GetComponent <Tool>().AnimVar()); isInteracting = true; } else if (invCon.currItem.tag == "seeds") { invCon.RemoveItem(invCon.currItem); animCon.UseSeeds(); isInteracting = true; } else if (invCon.currItem.tag == "crop" || invCon.currItem.tag == "fence") { animCon.Throw(); isInteracting = true; } } else if (pick != 0) //and there's something there and there's nothing in the player's hands { //Will need changing when merged and able to look at grid system Vector2 mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); RaycastHit2D hit = Physics2D.Raycast(transform.position, mousePos, 1); if (hit.collider != null) { animCon.PickUp(); invCon.AddItem(hit.collider.gameObject); Destroy(hit.collider.gameObject); } } else { MovePlayer(); CheckDirection(); } } }
public void GiveAward(string name) { if (contr.GameOver) { return; } inventory.AddItem(name); ui.ItemReceived(name); }
public void AddWood(int quantity) { if (quantity == 0) { return; } var wood = Shipwreck.ResourceFactory.GetResource(ResourceType.Branch); InventoryController.AddItem(Inventory, wood, quantity); }
/// <summary> /// Adds an item to the player's inventory. /// </summary> /// <param name="item">The item to be added</param> public bool AddItem(Item item) { if (!HasEmptySlots && !NotFullItemStacks.Contains(item)) { return(false); } playerInventory.AddItem(item); return(true); }
private void OnTriggerStay2D(Collider2D collision) { if (collision.transform.tag == "Player" && !inventoryController.IsInventoryFull() && Input.GetKeyDown(KeyCode.E)) { Debug.Log("Item to add: " + item.UniqueID); inventoryController.AddItem(item, item.ID); //inventoryController.DropItem(inventoryController.items[1].UniqueID); Destroy(gameObject); } }
private void CraftItem() { List <CraftItem> neededItems = GetNeededItems(craftableItems[showenItemIndex]); for (int i = 0; i < neededItems.Count; i++) { craftInventory.RemoveItem(neededItems[i].item, neededItems[i].count); } mainInventory.AddItem(new Item(craftableItems[showenItemIndex].item)); craftInventory.isInventoryChanged = true; }
private void HandleOnLootAllPressed() { for (int row = 0; row < 4; row++) { for (int col = 0; col < 2; col++) { LootChestSlot slot = chestInventorySlots[row, col]; if (slot.IsOccupied() && backPackSlotManager.HasEmptySlots()) { // Take ItemTile from Chest ItemInventoryTile tile = slot.GetItemTile(); slot.RemoveItemTile(); // Add to the Backpack and to the inventory backPackSlotManager.AddItemTileToBackpack(tile); inventoryController.AddItem(tile.GetParentItem(), false); } } } }
private void Update() { if (!WorldVariables.dialogueActive && !WorldVariables.eventos[eventNumber] && WorldVariables.items[itemId]) { if (givesItem) { playerInv.AddItem(itemId); } WorldVariables.items[itemId] = false; } }
public bool PlayerGetItem(Item item, bool alert = true) { if (alert == true) { se.Play(2); } if (item.itemDurability == 0) { item.ItemDurability = gm.itemPool.GetItemDurability(item); } return(invController.AddItem(item, alert)); }
public void PerformAction(string action) { if (!playerNear) { Inventory.SetText("Object is Too Far"); } else if (hidden) { Inventory.SetText("You can't see that"); } else { switch (action) { case "GRAB": Inventory.DeselectItem(); if (empty) { Inventory.SetText("You got what you need"); } else { Inventory.SetText("It's Locked"); } break; case "CHEST_KEY": Inventory.DeselectItem(); if (empty) { Inventory.SetText("You got what you need"); } else { Inventory.SetText("You found a plane part!"); Inventory.AddItem("PLANE_PART1"); empty = true; } break; case "BONE": Inventory.DeselectItem(); Inventory.SetText("It's not a Skeleton Key"); break; case "WOOD_AXE": case "TORCH": Inventory.DeselectItem(); Inventory.SetText("You don't want to damage the contents"); break; } } }
public void PickupAll() { for (int i = itemsInSpace.Count - 1; i >= 0; i--) { Item item = itemsInSpace[i]; if (inventoryController.CanPickup(item)) { item.PickUpItem(); inventoryController.AddItem(item, true); } } }
public void CraftItem(GameObject item) { Debug.Log("Crafting " + name + " [CC: 74)"); ic.AddItem(item.name, 1); if (!InventoryController.sorted) { //Make a copy of the object of that item in order to drop it to the floor GameObject go = Instantiate(item, ic.dropPoint.transform.position + ic.cam.transform.forward * 1, Quaternion.identity); go.GetComponent <Rigidbody>().velocity = 5 * ic.cam.transform.forward; go.name = item.name; go.GetComponent <ItemEntity>().amount = 1; } }
protected override void endOfLife() { Debug.Log("Loot de :" + count + " item d'id :" + idMineral); for (int i = 0; i < count; i++) { shipInventoryController.AddItem(idMineral, 1); } if (particlePrefab != null) { GameObject Particle = Instantiate(particlePrefab, this.transform.position, Random.rotation); Particle.transform.localScale = this.transform.localScale; } FindObjectOfType <Data>().GetComponentInChildren <OtherStats>().DestroyedAsteroids++; }
/// <summary> /// Pick up a collectable item and put it in the inventory /// A collected item is no longer visible to other AIs with the exception of the flag /// </summary> /// <param name="item">The item to pick up</param> public void CollectItem(GameObject item) { if (item != null) { if (_agentSenses.IsItemInReach(item)) { // If its collectable add it to the inventory if (item.GetComponent <Collectable>() != null) { item.GetComponent <Collectable>().Collect(_agentData); _agentInventory.AddItem(item); } } } }
private void ImportSaveData() { for (int i = 0; i < SL.serializableList.Count; i++) { string name = SL.serializableList[i].name; int count = SL.serializableList[i].count; ShopItem item = itemDB.GetItem(name); if (item) { inventory.AddItem(item, count); } else { Debug.LogError("item não encontrado: " + SL.serializableList[i].name); } } }
public void PerformAction(string action) { switch (action) { case "GRAB": if (playerNear) { Destroy(gameObject); Inventory.SetText("Got Axe!"); Inventory.AddItem("WOOD_AXE"); Inventory.DeselectItem(); } else { Inventory.SetText("Object is Too Far"); } break; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.E)) { var selection = _selector.GetSelection(); if (selection != null) { if (selection.gameObject.layer == LayerMask.NameToLayer("Collectable")) { var droppedItem = selection.gameObject.GetComponent <DroppedItem>(); if (droppedItem != null) { _inventoryScript.AddItem(droppedItem.Item, droppedItem.Amount); Destroy(selection.gameObject); } } } } }
public void PerformAction(string action) { if (playerNear) { switch (action) { case "GRAB": Inventory.DeselectItem(); Inventory.AddItem("TORCH"); Inventory.SetText("Got a torch"); Destroy(gameObject); break; } } else { Inventory.SetText("Object is Too Far"); } }
public void PerformAction(string action) { switch (action) { case "WOOD_AXE": if (playerNear) { Destroy(gameObject); Inventory.SetText("Chopped some wood"); Inventory.AddItem("WOOD_CHUNK"); Inventory.DeselectItem(); } else { Inventory.SetText("Object is Too Far"); } break; } }
public void PerformAction(string action) { switch (action) { case "GRAB": if (playerNear) { Destroy(gameObject); Inventory.DeselectItem(); Inventory.SetText("Unburied a key"); Inventory.AddItem("CHEST_KEY"); } else { Inventory.SetText("Object is Too Far"); } break; } }