void Start() { inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(102)); inv.Add(ItemData.CreateItem(200)); inv.Add(ItemData.CreateItem(201)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(302)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(401)); inv.Add(ItemData.CreateItem(402)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(501)); inv.Add(ItemData.CreateItem(502)); }
// Update is called once per frame void Update() { // check if inventory button is hit if (Input.GetButtonDown("Inventory") && !PauseMenu.isPaused) { showInv = !showInv; if (showInv) { ShowScrollInventory(); if (selectedItem != null) { SelectItem(selectedItem); } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; Time.timeScale = 0; inventoryPanel.SetActive(true); } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; Time.timeScale = 1; inventoryPanel.SetActive(false); selectedItem = null; } } //test key to add inventory items if (Input.GetKey(KeyCode.I)) { inv.Add(ItemData.CreateItem(UnityEngine.Random.Range(0, 3))); } //test key to add more of the same item (quanity) if (Input.GetKey(KeyCode.KeypadPlus)) { selectedItem.Amount++; } }
private void Update() { if (Input.GetKeyDown(KeyCode.I)) //Generate item for testing scrolling bar { inv.Add(ItemData.CreateItem(Random.Range(100, 103))); inv.Add(ItemData.CreateItem(Random.Range(200, 203))); inv.Add(ItemData.CreateItem(Random.Range(300, 303))); inv.Add(ItemData.CreateItem(Random.Range(400, 403))); inv.Add(ItemData.CreateItem(Random.Range(500, 503))); inv.Add(ItemData.CreateItem(Random.Range(600, 603))); inv.Add(ItemData.CreateItem(Random.Range(700, 703))); inv.Add(ItemData.CreateItem(Random.Range(800, 803))); inv.Add(ItemData.CreateItem(Random.Range(900, 903))); } if (Input.GetKeyDown(KeyCode.Tab)) { showInv = !showInv; //Set the show inventory to false if (showInv) { Time.timeScale = 1; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; return; } else { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; return; } } if (Input.GetKeyDown(KeyCode.P)) { if (selectedItem != null) { selectedItem.Amount += 3; } } }
private void OnGUI() { Vector2 scr = new Vector2(Screen.width / 16, Screen.height / 9); if (showShop) { GUI.Box(new Rect(6.5f * scr.x, 0.25f * scr.y, 3 * scr.x, 0.5f * scr.y), "Money: $" + LinearInventory.money.ToString()); for (int i = 0; i < itemsInShop.Count; i++) { if (GUI.Button(new Rect(12.75f * scr.x, 0.25f * scr.y + i * (scr.y * 0.25f), 3 * scr.x, 0.25f * scr.y), itemsInShop[i].Name)) { selectedShopItem = itemsInShop[i]; } } if (selectedShopItem == null) { return; } else { float newPrice = (Mathf.Round(selectedShopItem.Value * 1.25f)); int newPriceInt = (int)newPrice; GUI.Box(new Rect(6.5f * scr.x, 0.75f * scr.y, 3 * scr.x, 0.5f * scr.y), "Cost: $" + newPriceInt.ToString()); if (LinearInventory.money >= selectedShopItem.Value) { if (GUI.Button(new Rect(12.5f * scr.x, 6.5f * scr.y, 1.5f * scr.x, 0.25f * scr.y), "Buy")) { LinearInventory.inventory.Add(ItemData.CreateItem(selectedShopItem.ID)); itemsInShop.Remove(selectedShopItem); selectedShopItem = null; LinearInventory.money -= newPriceInt; } } } } }
private void Update() { if (Input.GetKeyDown(KeyCode.D)) { inv[21].Amount += 3; } if (Input.GetKey(KeyCode.A)) { int o = Random.Range(0, 29); inv.Add(ItemData.CreateItem(o)); GameObject newButton = Instantiate(invButton, content); newButton.GetComponentInChildren <Text>().text = inv[o].Name; Item item = inv[o]; newButton.GetComponent <Button>().onClick.AddListener(() => SelectItem(item)); content.sizeDelta = new Vector2(208.3f, 30 * inv.Count); } if (Input.GetKeyDown(KeyCode.I)) { showInv = !showInv; if (showInv) { inventory.SetActive(true); Time.timeScale = 0; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; return; } else { inventory.SetActive(false); Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; return; } } invshow(); }
private void OnGUI() { if (showShop) { Vector2 scr = new Vector2(Screen.width / 16, Screen.height / 9); GUI.Box(new Rect(6.5f * scr.x, scr.y, 3 * scr.x, 0.25f * scr.y), "$" + LinearInventory.money); for (int i = 0; i < shopInv.Count; i++) { if (GUI.Button(new Rect(12.75f * scr.x, 0.25f * scr.y + i * (0.25f * scr.y), 3 * scr.x, 0.25f * scr.y), shopInv[i].Name)) { selectedShopItem = shopInv[i]; } } if (selectedShopItem == null) { return; } else { int cost = (int)System.Math.Round(selectedShopItem.Value * 1.25f, 0); GUI.Box(new Rect(9.5f * scr.x, scr.y, 3 * scr.x, 0.25f * scr.y), "$" + cost); if (LinearInventory.money > cost) { if (GUI.Button(new Rect(12.5f * scr.x, 6.5f * scr.y, 1.5f * scr.x, 0.25f * scr.y), "Purchase")) { LinearInventory.inv.Add(ItemData.CreateItem(selectedShopItem.ID)); shopInv.Remove(selectedShopItem); selectedShopItem = null; LinearInventory.money -= cost; } } } } }
private void OnGUI() { if (showShop) { Vector2 scr = new Vector2(Screen.width / 16, Screen.height / 9); GUI.Box(new Rect(scr.x * 6.5f, scr.y * .25f, scr.x * 3, scr.y * .25f), "$" + LinearInventory.money); for (int i = 0; i < shopInv.Count; i++) { if (GUI.Button(new Rect(12.75f * scr.x, 0.25f * scr.y + i * (0.25f * scr.y), 3 * scr.x, 0.25f * scr.y), shopInv[i].Name)) { selectedShopItem = shopInv[i]; } } if (selectedShopItem == null) { return; } else { //Display item box with value +25% GUI.Box(new Rect(scr.x * 9.65f, scr.y * 1.5f, scr.x * 3, scr.y * 3), selectedShopItem.IconName); GUI.Box(new Rect(scr.x * 9.65f, scr.y * 0.5f, scr.x * 3, scr.y * .25f), selectedShopItem.Name); GUI.Box(new Rect(scr.x * 9.65f, scr.y * 1, scr.x * 3, scr.y * .25f), selectedShopItem.Description); GUI.Box(new Rect(scr.x * 9.65f, scr.y * 5, scr.x * 3, scr.y * .25f), "$" + (int)(selectedShopItem.Value + selectedShopItem.Value * 0.25f)); //if inv.money >= value + 25% if (LinearInventory.money >= (selectedShopItem.Value + (int)selectedShopItem.Value * 0.25f)) { if (GUI.Button(new Rect(12.5f * scr.x, 6.5f * scr.y, 1.5f * scr.x, 0.25f * scr.y), "Buy")) { LinearInventory.inv.Add(ItemData.CreateItem(selectedShopItem.ID)); shopInv.Remove(selectedShopItem); //inv.money -= value+25% LinearInventory.money -= (int)(selectedShopItem.Value + selectedShopItem.Value * 0.25f); selectedShopItem = null; } } } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Tab)) { //if game if not paused if (PauseMenu.GameIsPause == false) { ToggleInv(); } } if (Input.GetKeyDown(KeyCode.I)) { inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(102)); inv.Add(ItemData.CreateItem(200)); inv.Add(ItemData.CreateItem(201)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(302)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(401)); inv.Add(ItemData.CreateItem(402)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(501)); inv.Add(ItemData.CreateItem(502)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(601)); inv.Add(ItemData.CreateItem(602)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(701)); inv.Add(ItemData.CreateItem(702)); } }
public void CheckForDuplicates() { List <Item> itemsToAdd = new List <Item>(); //Creates a list to store the items being added to the inventory for (int i = 0; i < (int)Random.Range(0, 10); i++) //For statement for finding all items being added { itemsToAdd.Add(ItemData.CreateItem((int)Random.Range(0, 10) * 100)); //Adds the items to the list } for (int i = 0; i < itemsToAdd.Count; i++) //Checks for each item within the list { if (inv.Count != 0) //Checks if the inventory is full to allow for the first item to be added. { for (int j = 0; j < inv.Count; j++) //Used to load each item within the inventory to allow it to be checked { if (inv[j].Name == itemsToAdd[i].Name && inv[j].Type != ItemType.Armour && inv[j].Type != ItemType.Weapon) //Used to check if the name of the item in the inventory is the same as the item attempting to be added to allow for the removal of duplicate items { inv[j].Amount++; //Adds the duplicate item to the existing item's count itemsToAdd[i] = null; //Sets the item to null to remove it from the list j = inv.Count; //Jumps to the null item to end the for loop } else if (j == inv.Count - 1) //Checks if j has reached the last item within the list of items to add so that it can create a new non-duplicate entry { inv.Add(itemsToAdd[i]); //Adds the new item to the inventory itemsToAdd[i] = null; //Sets the item to null to remove it from the list j = inv.Count; //Jumps to the null item to end the for loop } Debug.Log(i); } } else //Used to add the first item in the inventory { inv.Add(itemsToAdd[i]); //Adds the item to the inventory itemsToAdd[i] = null; //Sets the item to null to remove it from the list } } }
public GameObject sack; //The gameobject prefab for items #endregion private void Start() { //Add 100 to the money money += 100; //Used to add Items to the inventory inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(3)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(102)); inv.Add(ItemData.CreateItem(200)); inv.Add(ItemData.CreateItem(201)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(302)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(401)); inv.Add(ItemData.CreateItem(402)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(501)); inv.Add(ItemData.CreateItem(502)); }
private void OnGUI() { if (showShop) { Vector2 scr = new Vector2(Screen.width / 16, Screen.height / 9); GUI.Box(new Rect(6.5f * scr.x, 0.25f * scr.y, 3 * scr.x, 0.25f * scr.y), "$" + LinearInventory.money); for (int i = 0; i < shopInv.Count; i++) { if (GUI.Button(new Rect(12.75f * scr.x, 0.25f * scr.y + i * (0.25f * scr.y), 3 * scr.x, 0.25f * scr.y), shopInv[i].Name)) { selectedShopItem = shopInv[i]; } } if (selectedShopItem == null) { return; } else { //Display Box with item value +25% GUI.Box(new Rect(12.5f * scr.x, 6.25f * scr.y, 3 * scr.x, 0.25f * scr.y), "$" + (selectedShopItem.Value + (int)selectedShopItem.Value / 4)); //if inv.money >= item Value + 25% if (LinearInventory.money >= (selectedShopItem.Value + (int)selectedShopItem.Value / 4)) { if (GUI.Button(new Rect(12.5f * scr.x, 6.5f * scr.y, 1.5f * scr.x, 0.25f * scr.y), "Buy")) { LinearInventory.inv.Add(ItemData.CreateItem(selectedShopItem.ID)); shopInv.Remove(selectedShopItem); //inv.money -= item value +25% LinearInventory.money -= (selectedShopItem.Value + (int)selectedShopItem.Value / 4); selectedShopItem = null; } } } } }
void Start() { inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(0)); scrH = Screen.height / 9; scrW = Screen.width / 16; //setting the center of circle to the center of screen circleCenter.x = Screen.width / 2; circleCenter.y = Screen.height / 2; sectorDegree = 360 / numOfSectors; iconOffset = sectorDegree / 2; MakeCircleBigger(circleSize); CalculateMouseAngles(); slotPos = SlotPositions(numOfSectors); }
private void Update() { if (Input.GetButtonDown("Inventory") && !PauseMenu.isPaused) { showInv = !showInv; if (showInv) { Time.timeScale = 0; Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } else { Time.timeScale = 1; Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; selectedItem = null; } } if (Input.GetKey(KeyCode.I)) { inv.Add(ItemData.CreateItem(Random.Range(0, 3))); } }
private void Update() { //If the tab key is pushed down and the bool is false if (Input.GetKeyDown("tab") && !PauseMenu.isPaused) { //Switch the state of showInv showInv = !showInv; //If showInv is true if (showInv) { //Set the cursor visible Cursor.visible = true; //Set the lockState for the cursor to none Cursor.lockState = CursorLockMode.None; //Set the timeScale to zero Time.timeScale = 0; //Run void TurnOnGUI TurnOnGUI(); } else { //Set the cursor visible state to false Cursor.visible = false; //Set the cursor lockState to be locked Cursor.lockState = CursorLockMode.Locked; //Set the timeScale to one Time.timeScale = 1; //New GameObject array to be the ammount of itemButtons GameObject[] temp = new GameObject[itemButtons.Count]; //For all itemButtons for (int i = 0; i < itemButtons.Count; i++) { //Set the temp to the itemButtons gameObject temp[i] = itemButtons[i].gameObject; } //For all temp for (int i = 0; i < temp.Length; i++) { //Destroy temp Destroy(temp[i]); } //Remove all the buttons from the list itemButtons.RemoveRange(0, itemButtons.Count); //Set sortType to All sortType = "All"; //Set Displaystats to true DisplayStats(true); //Set inventory panel active state to false invPanel.SetActive(false); } } //If the key I is pushed if (Input.GetKeyDown(KeyCode.I)) { //Add an item to the invintory between item id 0 and 3 inv.Add(ItemData.CreateItem(UnityEngine.Random.Range(0, 3))); } //If Keypad PLus is pushed if (Input.GetKey(KeyCode.KeypadPlus)) { //Set the inv amount to 52 inv[0].Amount = 52; } }
// Update is called once per frame void Update() { scr.x = Screen.width / 16; scr.y = Screen.height / 9; if (Input.GetKeyDown(KeyCode.Tab)) { if (currentShop == null) { showInv = !showInv; if (showInv) { Time.timeScale = 0; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; inventoryScreen.SetActive(true); return; } else { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; //currentChest.showChestInv = false; currentChest = null; inventoryScreen.SetActive(false); return; } } } if (Input.GetKeyDown(KeyCode.Tab)) { showInv = !showInv; if (showInv) { Time.timeScale = 0; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; inventoryScreen.SetActive(true); /*int CountOfItemtypes = Enum.GetNames(typeof(ItemType)).Length; * { * for (int i = 0 < CountOfItemtypes; i++) * { * Instantiate(Button, 0,0,0); * } * } */ return; } else { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; currentChest.showChestInv = false; currentChest = null; inventoryScreen.SetActive(false); return; } } if (selectedItem != null) { if (selectedItem.Amount < 1 || selectedItem == null) { objectInfo.SetActive(false); } else { objectInfo.SetActive(true); } } #if UNITY_EDITOR if (Input.GetKey(KeyCode.I)) { AddItem(ItemData.CreateItem(Random.Range(0, 1))); AddItem(ItemData.CreateItem(Random.Range(200, 202))); } if (Input.GetKey(KeyCode.N)) { sortType = "Food"; } if (Input.GetKey(KeyCode.M)) { sortType = "All"; } #endif }
public int amount = 1; //Ammount of the item //On collection of the object public void OnCollection() { //If the itemType is equal to type money if (itemType == ItemTypes.Money) { //Access the LinerInventory's money and add the ammount to it LinearInventory.money += amount; } //Checks if the itemType matches craftable or ingredient else if (itemType == ItemTypes.Craftable || itemType == ItemTypes.Ingredient) { //Int for if the item is found int found = 0; //Index of the item int addIndex = 0; //For all inventory items for (int i = 0; i < LinearInventory.inv.Count; i++) { //If the itemId is equal to the linearInventory ID if (itemId == LinearInventory.inv[i].ID) { //Set found to 1 found = 1; //Set the index to i addIndex = i; //End the for loop break; } } //If found equals one if (found == 1) { //Add add amount to the amount in the linearInventory LinearInventory.inv[addIndex].Amount += amount; } else { //Add item to the liner inventory LinearInventory.inv.Add(ItemData.CreateItem(itemId)); //If the ammount is greater than 1 if (amount > 1) { //For all items in the inventory for (int i = 0; i < LinearInventory.inv.Count; i++) { //If the item id matches the it in the inventory if (itemId == LinearInventory.inv[i].ID) { LinearInventory.inv[i].Amount = amount; i = LinearInventory.inv.Count; } } } } } else { //Add item to the Linear Inventory LinearInventory.inv.Add(ItemData.CreateItem(itemId)); } //Destory the gameObject Destroy(gameObject); }
public void OnCollection() { if (linearInventory != null) { Debug.Log("Linear Inventory Collection"); if (ItemTypes.Money == itemType) { // Money LinearInventory.money += amount; } else if (itemType == ItemTypes.Craftable || itemType == ItemTypes.Food || itemType == ItemTypes.Potion || itemType == ItemTypes.Ingredient) { // Is Stackable bool found = false; int addIndex = -1; for (int i = 0; i < LinearInventory.inventory.Count; i++) { if (itemID == LinearInventory.inventory[i].ID) { found = true; addIndex = i; break; } } if (found) { LinearInventory.inventory[addIndex].Amount += amount; } else { LinearInventory.inventory.Add(ItemData.CreateItem(itemID)); if (amount > 1) { for (int i = 0; i < LinearInventory.inventory.Count; i++) { if (itemID == LinearInventory.inventory[i].ID) { LinearInventory.inventory[i].Amount = amount; break; } } } } } else { LinearInventory.inventory.Add(ItemData.CreateItem(itemID)); } Destroy(gameObject); } else { Debug.Log("UIInventory Collection"); if (ItemTypes.Money == itemType) { // Money UIInventory.money += amount; } else if (itemType == ItemTypes.Craftable || itemType == ItemTypes.Food || itemType == ItemTypes.Potion || itemType == ItemTypes.Ingredient) { // Is Stackable bool found = false; foreach (Item item in UIInventory.inventory) { if (itemID == item.ID) { found = true; item.Amount += amount; break; } } if (!found) { uIInventory.AddButtonInventory(ItemData.CreateItem(itemID)); if (amount > 1) { for (int i = 0; i < UIInventory.inventory.Count; i++) { if (itemID == UIInventory.inventory[i].ID) { UIInventory.inventory[i].Amount = amount; break; } } } } } else { uIInventory.AddButtonInventory(ItemData.CreateItem(itemID)); } Destroy(gameObject); } }
private void Start() { shopInv.Add(ItemData.CreateItem(Random.Range(0, 2))); shopInv.Add(ItemData.CreateItem(Random.Range(100, 103))); }
public int amount; // Change this in the Inspector (how many of this item are we picking up). #endregion // Where we make it possible to pick up and add an item to your inventory (it's used in Interact.cs). #region +void OnCollection() - Pick Up / Add To Inventory /// Foreword /// After carefully reading and re-reading the Craftable / Consumables section, /// I can safely say I understand what's happening there (it's pretty clever). public void OnCollection() { #region Money // If we're picking up Money... increase our character's amount of money in their Inventory by amount's value. if (itemType == ItemTypes.Money) { Inventory.money += amount; } #endregion #region Craftable / Consumables // Or else if we're picking up a craftable or a consumable... else if (itemType == ItemTypes.Craftable || itemType == ItemTypes.Consumables) { // These two ints are used pretty much like bools to check if... int found = 0; // ... we do not have any of this item... int addIndex = 0; // ... how much of this item we have (we don't have any of the item). #region Mark All Items in Inventory as Valid // For everything from (the first element; to the last element (in the Inventory List); 0 → 1 → 2...), do this: for (int i = 0; i < Inventory.inv.Count; i++) { // If itemId matches a valid itemId from the Inventory Item List... if (itemId == Inventory.inv[i].Id) { // Then we already have an instance of this item in our Inventory with an additive quantity (addIndex). found = 1; addIndex = 1; break; } } #endregion #region When we DO have an Item // If we have an instance of this item in our Inventory... if (found == 1) { // Increase our item's current quantity (addIndex) by amount. Inventory.inv[addIndex].Amount += amount; } #endregion #region When we DON'T have an Item // Otherwise (found == 0 (we DON'T have an any of this item in our Inventory))... else { // Create an instance of this item in our Inventory. Inventory.inv.Add(ItemData.CreateItem(itemId)); // if the item we're picking up is a stacked item (it has more than one)... if (amount > 1) // Without this, you can only go from 0 to 1. { // That for loop from before (check through everything in the Inventory). for (int i = 0; i < Inventory.inv.Count; i++) { // If itemId matches a valid itemId from the Inventory List... if (itemId == Inventory.inv[i].Id) { // Then we get more than one of this brand new item. Inventory.inv[i].Amount = amount; } } } } #endregion } #endregion #region Everything Else (Non-Stackables) // Otherwise (it's a weapon, piece of armour, or something, so...)... else { // Create an instance of this item in our Inventory. Inventory.inv.Add(ItemData.CreateItem(itemId)); } #endregion //DragAndDropInventory.AddItem(itemId); // Add to a slot in the DragAndDropInventory. Destroy(gameObject); // Delete the item from the world (it's in our pocket-universe - err, inventory now). }
private void Start() { Closed(); chestInv.Add(ItemData.CreateItem(Random.Range(0, 2))); chestInv.Add(ItemData.CreateItem(Random.Range(100, 102))); }
// Start is called before the first frame update void Start() { inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); inv.Add(ItemData.CreateItem(0)); inv.Add(ItemData.CreateItem(1)); inv.Add(ItemData.CreateItem(2)); inv.Add(ItemData.CreateItem(100)); inv.Add(ItemData.CreateItem(101)); inv.Add(ItemData.CreateItem(202)); inv.Add(ItemData.CreateItem(300)); inv.Add(ItemData.CreateItem(301)); inv.Add(ItemData.CreateItem(400)); inv.Add(ItemData.CreateItem(500)); inv.Add(ItemData.CreateItem(600)); inv.Add(ItemData.CreateItem(700)); inv.Add(ItemData.CreateItem(800)); }
// Update is called once per frame void Update() { scr.x = Screen.width / 16; scr.y = Screen.height / 9; if (currentShop == null) { if (Input.GetKeyDown(KeyCode.Tab))//self explanitory { showInv = !showInv; if (showInv) { Time.timeScale = 0; //time stops Cursor.lockState = CursorLockMode.None; //cursor can be seen and is not locked in place Cursor.visible = true; UpdateInventory(); invPanel.SetActive(true);//activate the inventory return; } else { if (!PauseMenu.isPaused)// reverses the functions above { Time.timeScale = 1; Cursor.lockState = CursorLockMode.Locked; invPanel.SetActive(false); Cursor.visible = false; if (currentChest != null) { currentChest.showChestInv = false; currentChest = null; } UpdateInventory(); } return; } } } #if UNITY_EDITOR if (Input.GetKey(KeyCode.I)) { inv.Add(ItemData.CreateItem(Random.Range(0, 3))); inv.Add(ItemData.CreateItem(Random.Range(100, 103))); inv.Add(ItemData.CreateItem(Random.Range(200, 203))); } if (Input.GetKeyDown(KeyCode.N)) { sortType = "Food"; UpdateInventory(); } if (Input.GetKeyDown(KeyCode.M)) { sortType = "All"; UpdateInventory(); } #endif }
private void Start() { playerInventory = (LinearInventory)FindObjectOfType <LinearInventory>(); shopInv.Add(ItemData.CreateItem(Random.Range(0, 2))); shopInv.Add(ItemData.CreateItem(Random.Range(100, 102))); }