Ejemplo n.º 1
0
    }     // end : Add to Inventory

    /* DumpItem()
     *  Removes the fetched item from the inventory or stack
     *  and places a copy of the assigned prefab on the
     *  player position.
     *  If no item with id is left, nothing happens.
     */
    public void DumpItem(int id)
    {
        GameObject objItem;
        Item       dataItem;

        if (RemoveFromInventory(id, out dataItem))
        {
            // copy the prefab to player's location
            objItem = ItemPrefabRegister.GetInstance().GetClone(dataItem.Prefab);
            objItem.transform.position = player.transform.position;
        }
    }     // end : DumpItem
Ejemplo n.º 2
0
    void Awake()
    {
        bool   success;
        string filename = Application.dataPath + ITEM_FILE;

        database = InvokeDatabase(filename);

        // load every prefab data to the database
        foreach (Item item in database.Values)
        {
            ItemPrefabRegister.GetInstance().AddPrefab(item.Prefab);
            ItemIconRegister.GetInstance().AddIcon(item.Handle);
        }
        success  = ItemPrefabRegister.GetInstance().LoadPrefabs();
        success &= ItemIconRegister.GetInstance().LoadIcons();
        if (!success)
        {
            Debug.Log("Some item prefabs could not be loaded. See Error Log!");
        }
    }     // end : Awake