Beispiel #1
0
 // Fetches the item corresponding to itemID or itemName
 // Hence itemID has higher priority, the resulting Item
 // might not have the name specified in itemName.
 // If neither itemId, nor itemName are found, the
 // function returns the defaulf Item
 private Item FetchItem()
 {
     // first try fetching by set id
     try {
         item = ItemDatabase.FetchItemById(itemID);
         return(item);
     } catch (KeyNotFoundException) {
         // Log exeption
         Debug.LogFormat("ItemController: Item ID {0} not found in Database.", itemID);
         item = new Item();
         return(item);
     }
 }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        // get the corresponding item stats from database
        item = FetchItem();

        // set name
        gameObject.name = item.Name;

        inventory = FindObjectOfType(typeof(Inventory)) as Inventory;
        if (inventory == null)
        {
            Debug.LogError("Cannot find InventoryController in scene.");
        }
    }