GetItem() 공개 메소드

public GetItem ( string itemName ) : Item
itemName string
리턴 Item
예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.S))
        {
            Debug.Log("switching");
            if (upperArm == null)
            {
                upperArm = manger.focusedUnit.transform.FindChild("ARMS");
            }
            if (armed)
            {
                //upperArm.GetComponent<SkinnedMeshRenderer>(	).sharedMesh = WithOutArmor;


                SquadManager.Instance.focusedUnit.GetComponent <EquipmentSet>().EquipArmor((EquipmentItem)itemDB.GetItem(0, 0));
                //charBlock.UpdateChar();
                upperArm.GetComponent <SkinnedMeshRenderer>(     ).material = skinMat;
                armed = false;
            }
            else
            {
                //EquipmentItem temp = (EquipmentItem)ItemDatabase.Instance.GetItem(1,0);
                //upperArm.GetComponent<SkinnedMeshRenderer>(	).sharedMesh = Witharmor;
                SquadManager.Instance.focusedUnit.GetComponent <EquipmentSet>().EquipArmor((EquipmentItem)itemDB.GetItem(1, 0));
                //charBlock.UpdateChar();
                upperArm.GetComponent <SkinnedMeshRenderer>(     ).material = steelMat;
                armed = true;
            }
        }
    }
예제 #2
0
    // Equip the item to the appropriate slot
    public void EquipItem(string name)
    {
        // Get the item dictionary from the database
        Dictionary <string, string> tempDict;

        tempDict = itemDatabase.GetItem(name);

        // Figure out what type of item it is and equip
        if (tempDict != null)
        {
            switch (tempDict ["ItemSubtype"])
            {
            case "WEAPON":
                EquipItem tempEquip = new EquipItem(tempDict);
                weapon = tempEquip;
                break;

            case "ARMOR":
                EquipItem tempArmor = new EquipItem(tempDict);
                armor = tempArmor;
                break;

            case "BOOTS":
                EquipItem tempBoots = new EquipItem(tempDict);
                boots = tempBoots;
                break;
            }
        }

        // Make sure our stat modifiers reflect the new equipment
        UpdateStats();
    }
예제 #3
0
    public bool GiveItem(int id, int inventoryId)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        if (itemToAdd.isStackable && CheckIfItemInInventory(itemToAdd))
        {
            for (int i = 0; i < InventoryDatabase.inventoryUI[inventoryId].itemsUI.Count; i++)
            {
                if (InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].item != null)
                {
                    if (InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].item.id == id && InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].amount < itemToAdd.maxStackSize)
                    {
                        InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].amount++;
                        InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].transform.GetChild(0).GetComponent <Text>().text = InventoryDatabase.inventoryUI[inventoryId].itemsUI[i].amount.ToString();
                        return(true);
                    }
                }
            }
        }

        if (inventoryItems.Count < inventoryUI.numberOfSlots)
        {
            InventoryDatabase.inventory[inventoryId].inventoryItems.Add(itemToAdd);
            InventoryDatabase.inventoryUI[inventoryId].AddNewItem(itemToAdd);
            Debug.Log("Item (" + id + ")" + " has been added to inventory (" + inventoryId + ")");
            return(true);
        }
        else
        {
            Debug.Log("Inventory is full.");
            return(false);
        }
    }
예제 #4
0
    void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        characterItems.Add(itemToAdd);
        Debug.Log("Added item: " + itemToAdd.title);
    }
    public void AddItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        inventoryUI.AddItemToUI(itemToAdd);
        playerItems.Add(itemToAdd);
    }
예제 #6
0
    public void Init()
    {
        itemDatabase = ItemDatabase.instance;

        // Find what item this recipe is to help craft, based on the ID passed in the inspector
        ItemInfo itemToCraft = itemDatabase.GetItem(resultID);

        if (itemToCraft == null)
        {
            throw new System.ApplicationException("Item with ID " + id + " is not in the item database.");
        }

        result = itemToCraft;

        ItemInfo mat;

        // now find the materials
        foreach (int matId in materialIDs)
        {
            mat = itemDatabase.GetItem(matId);

            if (mat == null)
            {
                throw new System.ApplicationException("Item with ID " + id + " is not in the item database.");
            }

            materials.Add(mat);
        }
    }
예제 #7
0
    public void LoadGame(SideMissionSaveData info, Sprite personInfo)
    {
        MissionSaveData temp = JsonUtility.FromJson <MissionSaveData>(info.missionSaveData);

        myHandinSlot.LoadGame(temp);

        p_numWanted = temp.totalNeeded;
        p_itemID    = temp.TurnInItemID;
        Reward      = info.reward;

        nameDisplay.text      = info.name;
        personDisplay.sprite  = personInfo;
        numWantedDisplay.text = p_numWanted.ToString();
        Item tempItem = itemDatabase.GetItem(p_itemID);

        itemDisplay.sprite     = tempItem.itemImage;
        goldRewardDisplay.text = Reward.ToString();

        beforeAcceptGroup.SetActive(info.beforeAcceptGroup);
        HandinGroup.SetActive(info.HandinGroup);
        CompletedGroup.SetActive(info.CompletedGroup);

        if (info.beforeAcceptGroup == false)
        {
            myHandinSlot.SetRequirements(p_itemID, temp.currentHandinNeeded);
            myHandinSlot.overlayImage.sprite = tempItem.itemImage;
            acceptButton.interactable        = false;
        }
    }
예제 #8
0
    public void AddItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        inventoryui.AddItemToUi(itemToAdd);
        PlayerItems.Add(itemToAdd);
    }
예제 #9
0
    // Loads inventory from xml file
    void LoadInvetory()
    {
        XmlDocument xmlDocument = new XmlDocument();

        xmlDocument.LoadXml(INVENTORY_XML.text);
        XmlNodeList itemNodeList = xmlDocument.GetElementsByTagName("Item");

        // Read items from xml, copy from database, and add to inventory
        foreach (XmlNode itemInfo in itemNodeList)
        {
            XmlNodeList itemContent = itemInfo.ChildNodes;
            string      tempName    = "";
            string      tempCount   = "";

            foreach (XmlNode content in itemContent)
            {
                switch (content.Name)
                {
                case "ItemName":
                    tempName = content.InnerText;
                    break;

                case "ItemCount":
                    tempCount = content.InnerText;
                    break;
                }
            }

            // Get item dictionary, set count, and add item to list
            Dictionary <string, string> tempDict;

            if (itemDatabase != null)
            {
                tempDict = itemDatabase.GetItem(tempName);
                if (tempDict != null)
                {
                    switch (tempDict ["ItemType"])
                    {
                    case "EQUIP":
                        EquipItem tempEquip = new EquipItem(tempDict);
                        tempEquip.Count = int.Parse(tempCount);
                        playerEquipItems.Add(tempEquip);
                        break;

                    case "CONSUMABLE":
                        ConsumableItem tempConsumable = new ConsumableItem(tempDict);
                        tempConsumable.Count = int.Parse(tempCount);
                        playerConsumableItems.Add(tempConsumable);
                        break;

                    case "STORY":
                        StoryItem tempStory = new StoryItem(tempDict);
                        tempStory.Count = int.Parse(tempCount);
                        playerStoryItems.Add(tempStory);
                        break;
                    }
                }
            }
        }
    }
예제 #10
0
    public void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        inventoryManager.characterItems.Add(itemToAdd);
        inventoryUI.AddNewItem(itemToAdd);
    }
예제 #11
0
    public void AddItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        uiInventory.AddItemToUI(itemToAdd);
        inventoryItems.Add(itemToAdd);
    }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        itemsToSpawn[0] = itemDatabase.GetItem(3);
        itemsToSpawn[1] = itemDatabase.GetItem(4);
        itemsToSpawn[2] = itemDatabase.GetItem(5);

        SpawnWeapons();
    }
예제 #13
0
    // Give a player an item via id
    public void GiveItem(int id)
    {
        Item itemAdd = itemDatabase.GetItem(id);

        inventItems.Add(itemAdd);
        inventUI.AddItem(itemAdd);
        Debug.Log("Added item: " + itemAdd.title);
    }
예제 #14
0
    public void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        playerItems.Add(itemToAdd);
        inventoryUI.AddNewItem(itemToAdd);
        Debug.Log("Added item: " + itemToAdd.type);
    }
예제 #15
0
    public void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        characterItems.Add(itemToAdd);
        inventoryUI.AddNewItem(itemToAdd);
        //Debug.Log("Added Item: " + itemToAdd.title);
    }
    public void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        Debug.Log(itemToAdd.title);
        inventoryUI.AddItemToUI(itemToAdd);
        playerItems.Add(itemToAdd);
    }
        /*
         * Creator: Yunzheng Zhou
         * Use potion from inventary and play sound effect
         */
        public void UsePotion()
        {
            playSFX(onConsumeSFX);
            Test_UIEquipSlot_Assign equipItem = this.GetComponent <Test_UIEquipSlot_Assign>();
            Item consumable = backupitemDataBase.GetItem(equipItem.assignItem);

            consumable.Use();
            (this as UIEquipSlot).Assign(itemdatabase.GetByID(0));
            fillinPotionslot((this as UIEquipSlot), equipItem.assignItem, equipItem);
        }
예제 #18
0
    //아이템을 인벤토리에 넣어주는 코드
    public void GiveItem(int id)
    {
        //데이터베이스에서 이 id 값을 가진 아이템을 가져오고
        //캐릭터 인벤에 이 아이템을 추가해준다.
        Item itemToAdd = Database.GetItem(id);

        characterItems.Add(itemToAdd);
        inventoryUI.AddNewItem(itemToAdd);
        Debug.Log("Added Item : " + itemToAdd.name);
    }
예제 #19
0
    public GameObject SpawnItem(string item)
    {
        ItemData   data = Database.GetItem(item);
        GameObject ret  = GameObject.Instantiate(MapObjectPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        ret.GetComponent <MapObject>().SetData(data);

        OnSpawnObject(ret, data);

        return(ret);
    }
예제 #20
0
    public void GiveItem(int id)
    {
        Item itemToAdd = itemDatabase.GetItem(id);

        characterItems.Add(itemToAdd);
        inventoryUI.AddNewItem(itemToAdd);
        numberOfItems++;
        DisplayNotif();
        EditNotifText("Added Item: " + itemToAdd.title + ",  number Of Items: " + numberOfItems);
        Debug.Log("Added Item: " + itemToAdd.title + ",  number O fItems: " + numberOfItems);
    }
예제 #21
0
 public void AddItem(int id)
 {
     if (chacacterItems.Count < inventoryUI.numberOfSlots)
     {
         Item itemToAdd = itemDatabase.GetItem(id);
         addNewItem(itemToAdd);
     }
     else
     {
         print("INVENTARIO CHEIO :(");
     }
 }
 /*
  * Function: OnAfterDeserialize
  * Description: convert item IDs to scriptable objects that
  * represent items in the inventory
  *
  * Creator: Myles Hagen
  */
 public void OnAfterDeserialize()
 {
     //Debug.Log("After " + itemIDs.Count);
     items.Clear();
     // add inventoryGUI clear function
     //InventoryGUI.instance.Clear();
     foreach (int i in itemIDs)
     {
         var item = itemDatabase.GetItem(i);
         items.Add(item);
         //InventoryGUI.instance.Add(i); refill the inventory gui with item ids
     }
 }
예제 #23
0
    /*
     * Retrieve all the owned items and get the item names to display in
     * the shopping gui.
     */
    private string[] RetrieveItemNames(Inventory inventory)
    {
        string[] itemNames = new string[inventory.GetItems().Count];
        int      index     = 0;
        Item     item;

        foreach (int itemID in inventory.GetItems().Keys)
        {
            item = itemDB.GetItem(itemID);
            itemNames [index] = item.itemName;
            index++;
        }
        return(itemNames);
    }
예제 #24
0
 public void SetReward()
 {
     goldReward       = Random.Range(0, 150);
     foodReward       = Random.Range(0, 5);
     cannonballReward = Random.Range(0, 3);
     if (Random.Range(0, 100) < 25)
     {
         itemReward = itemDtb.GetItem(Random.Range(3, 6));
     }
     else
     {
         itemReward = null;
     }
 }
예제 #25
0
    public void AddItem(int ID, int n)
    {
        Item item  = dataBase.GetItem(ID);
        Item item2 = new Item(item.ID, item.title, item.desc, item.sellValue, item.stack, item.maxStack);

        int slot = slotUi.slots.FindIndex(k => k.uItem.item != null &&
                                          k.uItem.item.ID == item.ID &&
                                          k.uItem.item.stack < item.maxStack);

        Debug.Log(slot);

        if (slot == -1)
        {
            slot = slotUi.slots.FindIndex(k => k.uItem.item == null);
            if (slot == -1)
            {
                Debug.Log("INVENTORY FULL");
                return;
            }

            slotUi.slots[slot].uItem.item = item2;
            slotUi.UpdateSlot(slot, item2);
            n -= 1;
        }
        Debug.Log("slot pos if" + slot);

        for (int i = 0; i < n; i++)
        {
            if (slotUi.slots[slot].uItem.item.stack < slotUi.slots[slot].uItem.item.maxStack)
            {
                slotUi.slots[slot].uItem.item.stack += 1;
                slotUi.UpdateSlot(slot, slotUi.slots[slot].uItem.item);
                Debug.Log("stack " + slotUi.slots[slot].uItem.item.stack);
            }

            else
            {
                Debug.Log("Adding Item" + item2);
                item2 = new Item(item.ID, item.title, item.desc, item.sellValue, item.stack, item.maxStack);
                slot  = slotUi.slots.FindIndex(k => k.uItem.item == null);
                slotUi.slots[slot].uItem.item = item2;
                Debug.Log("slot pos add for" + slot);
                slotUi.UpdateSlot(slot, item2);
            }
        }

        Debug.Log(slotUi.slots[slot].uItem.item.stack);
        Debug.Log("Added item: " + item.title);
    }
예제 #26
0
    public void AddItem(string itemName, int itemAmount = 1)
    {
        Item newItem = ItemDatabase.GetItem(itemName); // Find the item name
        Slot newSlot = GetEmptySlot();                 // Find empty slot

        if (newItem != null && newSlot != null)
        {
            if (HasStacked(newItem, itemAmount))
            {
                return;
            }
            // Set the empty slot
            newSlot.item = newItem;
            //Create a new item instance
            GameObject item = Instantiate(itemPrefab);
            item.transform.position = newSlot.gameObject.transform.position;
            item.transform.SetParent(newSlot.gameObject.transform);
            item.name = newItem.Title;
            //Set the item's gameobject
            newItem.gameobject = item;
            //Get the image component from the item
            Image image = item.GetComponent <Image>();
            image.sprite = newItem.Sprite;
            ItemData itemData = item.GetComponent <ItemData>();
            itemData.item = newItem;
            itemData.slot = newSlot;
        }
    }
예제 #27
0
    public void TriggerDialogue(Actor actor, Item item)
    {
        if (item == ItemDatabase.GetItem(ItemId.ID))
        {
            if (actor == ActorDatabase.BLOCKING_GUARD)
            {
                if (FlagManager.Instance.SHOWN_GUARD_ID)
                {
                    TriggerDialogue(DialogueKeys.SHOWN_ID_TO_GUARD, true);
                }
                else
                {
                    TriggerDialogue(DialogueKeys.GUARD_SHOWING_ID, true);
                }
            }
            return;
        }

        if (item == ItemDatabase.GetItem(ItemId.Box))
        {
            if (actor == ActorDatabase.BLOCKING_GUARD)
            {
                TriggerDialogue(DialogueKeys.WHAT_A_LOVELY_BOX, true);
            }
            return;
        }
    }
예제 #28
0
    // Adiciona Item ao inventário (exceção criada na origem itemDatabase.GetItem(itemName))
    public void AddItem(string itemName)
    {
        Item itemToAdd = itemDatabase.GetItem(itemName);

        characterItems.Add(itemToAdd);
        InventoryUpdate();
    }
예제 #29
0
    public bool Remove(ItemStack itemStack)
    {
        for (int i = 0; i < inventory.Count; i++)
        {
            if (inventory[i].id == itemStack.id)
            {
                int amount = inventory[i].count;

                inventory[i].count -= itemStack.count;

                if (inventory[i].count <= 0)
                {
                    itemCount -= amount;
                    weight    -= amount * ItemDatabase.GetItem(itemStack.id).weight;
                    inventory.RemoveAt(i);
                }
                else
                {
                    itemCount -= itemStack.count;
                    weight    -= itemStack.GetWeight();
                }

                return(true);
            }
        }

        return(false);
    }
예제 #30
0
    public void AddItem(string itemName, int itemAmount = 1) //Adds item to inventory
    {
        Item newItem = ItemDatabase.GetItem(itemName);       //Get an item from the database

        if (newItem != null)                                 //Check if item is valid
        {
            if (HasStacked(newItem, itemAmount))             //Check to see if the item is stackable
            {
                return;
            }

            SlotData newSlot = GetEmptySlot(); //Gets an empty slot
            if (newSlot != null)
            {
            }
            GameObject item = Instantiate(itemPrefab);                       //Creates a new prefab of the item
            item.transform.position = newSlot.gameObject.transform.position; //Set new item's gameObject
            item.transform.SetParent(newSlot.gameObject.transform);
            item.name          = newItem.Title;
            newItem.gameObject = item;                 //set the item's gameObject
            Image image = item.GetComponent <Image>(); //Get the image component and set new image to item sprite
            image.sprite = newItem.Sprite;             //Get ItemData Component
            ItemData itemData = item.GetComponent <ItemData>();
            itemData.item = newItem;
        }
    }
 // Use this for initialization
 void Start()
 {
     inventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
     tempInventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<TempInventory>();
     databaseSCR = GameObject.FindGameObjectWithTag ("ItemDatabase").GetComponent<ItemDatabase> ();
     tooltip = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").transform.GetChild (0).GetComponent<RectTransform>();
     tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> ();
     tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>();
     for (int i = 0; i < 5; i++)
     {
         heroInventory.Add (databaseSCR.GetItem(0));
     }
     for (int i = 0; i < heroInventory.Count; i++)
     {
         heroInventoryStacks.Add(0);
     }
 }