Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. class Inventory
  2. {
  3.  
  4.     private Item lastItemCollected;
  5.     public Item lastItemCollected()
  6.     {
  7.         return lastItemCollected;
  8.     }
  9.  
  10.     Dictionary<int, int> items = new Dictionary<int, int>();
  11.     Dictionary<int, int> questItems = new Dictionary<int, int>();
  12.  
  13.     public void getitem(Item i, int quanitity)
  14.     {
  15.         if (quanitity < 0)
  16.         {
  17.             Console.Write("Error: recieved invalid item quanitity to getitem(). No item will be collected.");
  18.             return;
  19.         }
  20.  
  21.         if (i.IsQuestItem())
  22.         {            
  23.             questItems[i.identifier] += quanitity;
  24.         }
  25.         else
  26.         {
  27.             items[i.identifier] += quanitity;
  28.         }
  29.     }
  30.  
  31.     public void loseitem(Item i, int quantity)
  32.     {
  33.         if (quantity < 0)
  34.         {
  35.             Console.Write("Error: recieved invalid item quanitity to loseitem(). No item will be lost.");
  36.             return;
  37.         }
  38.  
  39.         if (i.IsQuestItem())
  40.         {
  41.             questItems[i.identifier] -= quantity;
  42.         }
  43.         else
  44.         {
  45.             normalItems[i.identifier] -= quantity;
  46.         }
  47.  
  48.         if (lastItemCollected == i)
  49.         {
  50.             lastItemCollected = null;
  51.         }
  52.  
  53.         AchievementSystem.instance.DidModifyItem("lose", i.identifier, quantity);
  54.     }
  55.  
  56.     public void didpickupitem(Item i)
  57.     {
  58.         lastItemCollected = i;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement