Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 22.64 KB | None | 0 0
  1. //  InventoryManager.js
  2. //  Manages all the inventory items, looting and other item related systems for the player
  3. //  Attach to your Inventory Manager object
  4.  
  5. //  C# doesn't support Array. You could use ArrayList instead.
  6.  
  7.  
  8. using UnityEngine;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11.  
  12. public class InventoryManager : MonoBehaviour {
  13.  
  14. #region Variables
  15.     public UIButton emptyInventorySlot;
  16.    
  17.     public UIButtonDetails bagSlots;
  18.     public UIButtonDetails packSlots;
  19.     public UIButtonDetails equippedSlots;
  20. //  public UIButton[] equippedSlotUIButton;                         //  The array with button refs WHAT?? Bad Idea. Fixed. Walk away.
  21.     public EquipmentSlot[] equippedSlot;                            //  Our list to keep track of our Equipment Slots
  22.    
  23.     public ListPanel lootPanel;
  24. //  public UIListItemContainer[] lootPanelContainers;
  25.     public UIListButton[] lootPanelItems;
  26.    
  27.     private InventoryItem[] inventory;                              //  Our master inventory (private)
  28.     private InventoryItem[] equipped;                               //  Our equipped inventory (private)
  29.     private InventoryItem[] currentLootArray;                               //  The array to contain the loot being passed to and from the LootableObject
  30.    
  31.     private CurrentBag currentBag;
  32.    
  33.     //  Combat System                                               //  Do we want to pass on the target icon for the lootable object?
  34. //  private GameObject currentTarget;                               //  The Current Target for the player
  35. //  public GameObject currentTargetIcon;
  36.    
  37.     private bool openInventoryPanel;                                //  Controls OnGUI and opens/closes the Inventory window
  38.     private bool openCharacterPanel;                                //  Controls OnGUI and opens/closes the Character window        - assigned but its value is never used
  39.     private bool openLootPanel;                                     //  Controls OnGUI and opens/closes the Loot window
  40.    
  41.     private LootableObject currentLootableObject;                   //  The pointer to the current lootable object being processed
  42.     private LootableObject newLootableObject;                       //  The pointer to a new lootable object to be processed
  43.    
  44.     private MessageManager messageManager;
  45.     private PanelManager panelManager;
  46.     private QuestManager questManager;
  47.     private GameManager gameManager;
  48.    
  49.     static private InventoryManager inventoryManager;
  50.  
  51. #endregion
  52.        
  53.     //  Singleton Support
  54.     //  This can be cached on start as private InventoryManager inventoryManager;
  55.     //  & in Start() inventoryManager = InventoryManager.Instance();
  56.     //  Once cached, requires function calls as: inventoryManager.SomeFunction ();
  57.    
  58.     public static InventoryManager Instance () {
  59.          if (! inventoryManager) {
  60.              inventoryManager = FindObjectOfType(typeof (InventoryManager)) as InventoryManager;
  61.              if (! inventoryManager)
  62.                  Debug.LogError ("There needs to be one active InventoryManager script on a GameObject in your scene.");
  63.         }
  64.        
  65.          return inventoryManager;
  66.     }
  67.    
  68.    
  69.     void Awake () {
  70.         currentLootableObject = null;
  71.         currentBag = CurrentBag.Bag1;
  72.        
  73.         openInventoryPanel = false;                                         //  Move these to PanelManager?
  74.         openCharacterPanel = false;                                         //  Move these to PanelManager?
  75.         openLootPanel = false;                                              //  Move these to PanelManager?
  76.  
  77.         inventory = new InventoryItem [80];                                 //  Create & init the array to hold the inventory. 4 bags of 20 slots = 80 items.
  78.         for (int i = 0; i < inventory.Length; i++) {
  79.             inventory[i] = null;
  80.         }
  81.    
  82.         equipped = new InventoryItem [12];                                  //  Create & init the array to hold the equipped items. 12 set slots.
  83.         for (int j = 0; j < equipped.Length; j++) {
  84.             equipped[j] = null;
  85.         }
  86.     }
  87.    
  88.    
  89.     void Start () {
  90.         messageManager = MessageManager.Instance();
  91.         panelManager = PanelManager.Instance();
  92.         questManager = QuestManager.Instance();
  93.         gameManager = GameManager.Instance();
  94.         CreateInventorySlots ();
  95.         CreateCharacterSlots ();
  96.         CreateLootPanelItems ();
  97.     }
  98.    
  99.    
  100.     void CreateInventorySlots () {
  101. //      int inventoryLength = inventorySlots.arrayLength;
  102. //      inventorySlots.array = new UIButton [inventoryLength];
  103.         bagSlots.array = new UIButton [bagSlots.arrayLength];   //  Refactor inventorySlots as this is not correct. It's really bagSlots or something
  104.         int j;
  105.         int k;
  106.         Vector3 offset;
  107. //      for (int i = 0; i < inventoryLength; i ++) {
  108.         for (int i = 0; i < bagSlots.array.Length; i ++) {
  109.             bagSlots.array[i] = (UIButton)Instantiate(bagSlots.slot, bagSlots.parentTransform.position, Quaternion.identity);
  110.             offset = bagSlots.array[i].transform.localPosition;
  111.             offset.z = offset.z -12;
  112.             bagSlots.array[i].transform.localPosition = offset;
  113.             bagSlots.array[i].transform.parent = bagSlots.parentTransform;
  114.             bagSlots.array[i].renderCamera = bagSlots.renderCamera;
  115.             bagSlots.array[i].SetValueChangedDelegate(UseAttempt);
  116.             j = i % bagSlots.gridWidth;
  117.             k = i / bagSlots.gridWidth;
  118.             bagSlots.array[i].offset.x = bagSlots.startPositon.x + j * (bagSlots.slotSize + bagSlots.slotSpacing);
  119.             bagSlots.array[i].offset.y = bagSlots.startPositon.y - k * (bagSlots.slotSize + bagSlots.slotSpacing);
  120.         }
  121.        
  122.         int bagsLength = packSlots.arrayLength;
  123.         packSlots.array = new UIButton [bagsLength];
  124.         for (int i = 0; i < bagsLength; i ++) {
  125.             packSlots.array[i] = (UIButton)Instantiate(packSlots.slot, packSlots.parentTransform.position, Quaternion.identity);
  126.             offset = packSlots.array[i].transform.localPosition;
  127.             offset.z = offset.z -12;
  128.             packSlots.array[i].transform.localPosition = offset;
  129.             packSlots.array[i].transform.parent = packSlots.parentTransform;
  130.             packSlots.array[i].renderCamera = packSlots.renderCamera;
  131.             packSlots.array[i].scriptWithMethodToInvoke = packSlots.script;
  132.             packSlots.array[i].methodToInvoke = packSlots.method;
  133.             j = i % packSlots.gridWidth;
  134.             k = i / packSlots.gridWidth;
  135.             packSlots.array[i].offset.x = packSlots.startPositon.x + j * (packSlots.slotSize + packSlots.slotSpacing);
  136.             packSlots.array[i].offset.y = packSlots.startPositon.y - k * (packSlots.slotSize + packSlots.slotSpacing);
  137.         }
  138.        
  139.         bagSlots.parentTransform.gameObject.SetActiveRecursively(false);
  140.     }
  141.    
  142.    
  143.     void CreateCharacterSlots () {
  144.         int equippedLength = equippedSlots.arrayLength;
  145.         equippedSlots.array = new UIButton[equippedLength];
  146.        
  147.         for (int i = 0; i < equippedLength; i++) {
  148.             equippedSlots.array[i] = (UIButton)Instantiate(equippedSlot[i].slotIcon, equippedSlots.parentTransform.position, Quaternion.identity);
  149.             equippedSlots.array[i].transform.parent = equippedSlots.parentTransform;
  150.             equippedSlots.array[i].transform.localPosition = equippedSlot[i].slotOffset;
  151.             equippedSlots.array[i].renderCamera = equippedSlots.renderCamera;
  152.             equippedSlots.array[i].scriptWithMethodToInvoke = equippedSlots.script;
  153.             equippedSlots.array[i].methodToInvoke = equippedSlots.method;
  154.    
  155.         }
  156.         equippedSlots.parentTransform.gameObject.SetActiveRecursively(false);
  157.     }
  158.  
  159.    
  160.     void CreateLootPanelItems () {
  161.         lootPanelItems = new UIListButton[lootPanel.listLength];
  162.         for (int i = 0; i < lootPanelItems.Length; ++i) {
  163.             lootPanelItems[i] = (UIListButton)Instantiate(lootPanel.listButton, lootPanel.parentTransform.position, Quaternion.identity);
  164.             lootPanelItems[i].transform.parent = lootPanel.parentTransform;
  165.             lootPanelItems[i].SetValueChangedDelegate(LootAttempt);
  166.            
  167.             lootPanelItems[i].gameObject.SetActiveRecursively(false);
  168.         }
  169.         lootPanel.list.gameObject.SetActiveRecursively(false);
  170.     }
  171.    
  172.    
  173.     public void LootRequest (LootableObject newLootableObject, InventoryItem[] newLootArray) {
  174.         if (currentLootableObject != newLootableObject) {                   //  If the LootableObject has changed...
  175.             if (currentLootableObject != null) {                            //  ... and if the current Lootable is not Null ...
  176.                 currentLootableObject.LootArray = currentLootArray;         //  ... replace the contents with the updated contents. (Refactored from lootArray)
  177. //              currentLootableObject.UpdateLootArray(lootArray);           //  ... replace the contents with the updated contents.
  178.             }
  179.             currentLootableObject = newLootableObject;                      //  Set the new Lootable Item the Current Lootable Item
  180.             currentLootArray = newLootArray;                                        //  Set the Content Array to the new Content Array
  181.             openLootPanel = true;                                           //  Set the open trap on the Loot Window to "true", so if it's open is stays open, if not, it opens it
  182.             openInventoryPanel = true;                                      //  Set the open trap to the Inventory Window "true", so if it's open is stays open, if not, it opens it
  183.         } else {
  184.             openLootPanel = !openLootPanel;                                 //  This toggles the loot window
  185.             if (openLootPanel)                                              //  If the user clicks on the same Lootable Object, the window closes
  186.                 openInventoryPanel = true;
  187.         }
  188.         ToggleLootPanel(openLootPanel);
  189.         ToggleInventoryPanel(openInventoryPanel);
  190.     }
  191.    
  192.    
  193.     void ToggleLootPanel (bool open) {
  194.         GameObject newUIButtonObject;
  195.         UIButton newUIButton;
  196.         if (open) {
  197.             lootPanel.list.gameObject.active = true;
  198.             lootPanel.list.ClearList(false);
  199.             lootPanel.list.ScrollListTo(0);
  200.             for (int i = 0; i < currentLootArray.Length; i ++) {
  201.                 newUIButtonObject = (currentLootArray[i] as InventoryItem).itemIcon as GameObject;
  202.                 newUIButton = newUIButtonObject.GetComponent<UIButton>();
  203.                 if (newUIButton != null) {
  204.                     lootPanelItems[i].gameObject.SetActiveRecursively(true);
  205.                     lootPanelItems[i].Copy((SpriteRoot)newUIButton, ControlCopyFlags.Appearance | ControlCopyFlags.Data);
  206.                     lootPanelItems[i].data = currentLootArray[i];
  207.                     lootPanel.list.AddItem (lootPanelItems[i], currentLootArray[i].itemName);
  208.                    
  209.                 } else {
  210.                     Debug.Log ("GameManager.ToggleLootPanel is Null at " + i);
  211.                 }
  212.             }
  213.         } else {
  214.             lootPanel.list.ClearList(false);
  215.             lootPanel.list.ScrollListTo(0);
  216.             lootPanel.list.gameObject.SetActiveRecursively(false);
  217.             for (int j = 0; j < lootPanelItems.Length; ++j) {
  218.                 lootPanelItems[j].transform.parent = lootPanel.parentTransform;
  219.             }
  220.         }
  221.     }
  222.    
  223.    
  224.     public void RefreshInventoryPanel () {
  225.         int j = ((int)currentBag) * 20;                                                     //  Sets the Range of the Current Open Bag [0, 1, 2, 3, 4 => 0, 20, 40, 60, 80]
  226.         Debug.Log ("bagSlots.array.Length: " + bagSlots.array.Length);
  227.         for (int i = 0; i < bagSlots.array.Length; i++) {
  228.             if (inventory[i+j] == null) {
  229.                 Debug.Log("Inventory Slot is null at: " + (i+j));
  230.                 bagSlots.array[i].Copy((SpriteRoot)emptyInventorySlot, ControlCopyFlags.Appearance | ControlCopyFlags.State);
  231.                 bagSlots.array[i].UpdateCollider();
  232.             } else {
  233.                 Debug.Log("Inventory Slot is else at: " + (i+j));
  234.                 bagSlots.array[i].Copy((SpriteRoot)inventory[i+j].itemIconButton, ControlCopyFlags.Appearance | ControlCopyFlags.State);
  235.                 bagSlots.array[i].UpdateCollider();
  236.             }
  237.         }
  238.        
  239.     }
  240.    
  241.    
  242.     void LootAttempt (IUIObject obj) {
  243.         UIListButton newUILIstButton = (UIListButton)obj;                                   //  Extract the UIListButton from the IUIObject
  244.         InventoryItem item = (InventoryItem)newUILIstButton.data;                           //  Get the Inventory Item (This means the InventoryItem must be saved to the base .data)
  245.         bool success = AddItem(item);
  246.         if (success)
  247.             lootPanel.list.RemoveItem (newUILIstButton, false);
  248.     }
  249.    
  250.    
  251.     void UseAttempt  (IUIObject obj) {
  252.         UIButton thisUIButton = (UIButton)obj;                                              //  Extract the UIButton from the IUIObject
  253.         if (thisUIButton == null)
  254.             Debug.Log ("No UIButton");
  255.         else {                                                                              //  CONTINUE
  256.             InventoryItem thisItem = (InventoryItem)thisUIButton.data;                          //  Get the Inventory Item
  257.             if (thisItem == null)
  258.                 Debug.Log ("This Button Contains No Item!");
  259.             else {                                                                          //  CONTINUE
  260.                 if (thisItem.slotType == SlotType.Bag) {                                        //  Is this the BEST solution?
  261.                     bool success = UseItem(thisItem);
  262.                     if (success) {
  263.                         // remove item from the inventory array
  264.                         int thisItemsIndex = InventoryItem[].IndexOf(inventory, thisItem);
  265. //                      int myIndex = Array.IndexOf( myArray, myString );
  266. //                      int thisItemsIndex = InventoryItem[].IndexOf(inventory, thisItem);
  267. //                      Debug.Log("This item's index is " + thisItemsIndex);
  268.                         inventory[thisItemsIndex] = null;
  269.                         // remove image from the button
  270.                         thisUIButton.Copy((SpriteRoot)emptyInventorySlot, ControlCopyFlags.Appearance | ControlCopyFlags.State);
  271.                         thisUIButton.UpdateCollider();
  272.                         messageManager.Message(thisItem.itemName + " has been used.\nRemoving " + thisItem.itemName);
  273.                     }
  274.                 } else {
  275.                     bool success = EquipItem(thisItem);
  276.                     if (success) {
  277.                         // remove item from the inventory array
  278. //                      int thisItemsIndex = InventoryItem[].IndexOf(inventory, thisItem);
  279. //                      Debug.Log("This item's index is " + thisItemsIndex);
  280.                         // remove image from the button
  281.                         thisUIButton.Copy((SpriteRoot)emptyInventorySlot, ControlCopyFlags.Appearance | ControlCopyFlags.State);
  282.                         thisUIButton.UpdateCollider();
  283.                         messageManager.Message(thisItem.itemName + " has been equipped.\nRemoving " + thisItem.itemName);
  284.                     }
  285.                 }
  286.             }
  287.         }
  288.     }
  289.    
  290.    
  291.     bool AddItem (InventoryItem item) {
  292.         for (int i = 0; i < inventory.Length; i ++) {                                       //  Go through each row
  293.             if (inventory[i] == null) {                                                     //  If the position is empty...
  294.                 inventory[i] = item;                                                        //  ... add the new item....
  295.                 Debug.Log ("Adding Item " + item.itemName + " to the inventory");
  296.                 Debug.Log ("Item " + inventory[i].itemName + " is in the inventory at index " + i);
  297.                 bagSlots.array[i].Copy((SpriteRoot)item.itemIconButton, ControlCopyFlags.Appearance | ControlCopyFlags.Data | ControlCopyFlags.State);
  298.                 bagSlots.array[i].UpdateCollider();
  299.                 bagSlots.array[i].data = item;
  300.                 if (item.isQuestObjective)                                                  //  ... check the item against the quest log...
  301.                     questManager.CheckQuests (item);
  302.                 return (true);                                                              //  ... and exit the function.
  303.             }
  304.         }
  305.        
  306.         Debug.Log ("Inventory is full");
  307.         messageManager.Message("Inventory is full!", Color.yellow);
  308.         return (false);
  309.     }
  310.    
  311.    
  312.     bool EquipItem (InventoryItem item) {
  313.         for (int i = 0; i < equipped.Length; i ++) {
  314.             if (equippedSlot[i].slotType == item.slotType) {
  315.                 if (equipped[i] == null) {
  316.                     equipped[i] = item;
  317.                     return (true);
  318.                 } else {
  319.                     Debug.Log ("Cannot Equip this Item - Slot is full");
  320.                     messageManager.Message("Cannot Equip this Item!", Color.yellow);
  321.                     messageManager.Message("The " + equipped[i].slotType + " slot is full.", Color.yellow);
  322.                     return (false);
  323.                 }
  324.             }
  325.         }
  326.         Debug.Log ("Cannot Equip this Item");
  327.         messageManager.Message("Cannot Equip this Item!", Color.yellow);
  328.         return (false);
  329.     }
  330.    
  331.     bool UseItem (InventoryItem item) {
  332.         messageManager.Message ("Using Item " + item.itemName, Color.red);
  333.         return (true);
  334.     }
  335.    
  336.    
  337.     void CloseLootPanel () {
  338.         ToggleLootPanel (false);
  339.         openLootPanel = false;
  340.     }
  341.    
  342.    
  343.     void ToggleInventoryPanel (bool open) {
  344.         panelManager.ToggleInventoryPanel (open);
  345.     }
  346.    
  347.    
  348.     public void LootableObjectOutofRange () {   //close the windows, clear the scrollList,etc.
  349.         openLootPanel = false;
  350.         openInventoryPanel = false;
  351.     }
  352.    
  353.    
  354.     public InventoryItem[] GetInventory () {
  355.         return inventory;
  356.     }
  357.    
  358.  
  359. #region OldCode
  360.    
  361.     //  With Containers:
  362. //  void CreateLootPanelItems () {
  363. //      lootPanelContainers = new UIListItemContainer[lootPanel.listLength];
  364. //      for (int i = 0; i < lootPanelItems.Length; ++i) {
  365. //          //  With Container:
  366. //          lootPanelContainers[i] = (UIListItemContainer)Instantiate(lootPanel.listContainer, lootPanel.parentTransform.position, Quaternion.identity);
  367. //          lootPanelContainers[i].transform.parent = lootPanel.parentTransform;
  368. //          lootPanelItems[i] = lootPanelContainers[i].GetComponentInChildren <UIListButton>();
  369. //          lootPanelItems[i].scriptWithMethodToInvoke = this;
  370. //          lootPanelItems[i].methodToInvoke = "AddItem";
  371. //          lootPanelContainers[i].gameObject.SetActiveRecursively(false);
  372. //      }
  373. //  }
  374.     //void AddItem (InventoryItem item) {
  375.     //  for (int i = 0; i < inventory.length; i ++) {                   //  Go through each row
  376.     //      if (inventory[i] == null) {                                 //  If the position is empty...
  377.     //          inventory[i] = item;                                    //  ... add the new item....
  378.     //          if (item.isQuestObjective)                              //  ... check the item against the quest log...
  379.     //              CheckQuests (item);
  380.     //          return (true);                                          //  ... and exit the function.
  381.     //      }
  382.     ////        itemButton.Copy(InvPalette.instance.list[inItem.btnIndex]);
  383.     //  }
  384.     // 
  385.     //  Debug.Log ("Inventory is full");
  386.     //  return (false);
  387.     //}
  388.    
  389.    
  390.     //void EquipItem (InventoryItem item) {
  391.     //  for (int i = 0; i < equipped.length; i ++) {
  392.     //      if (equippedSlot[i].slotType == item.slotType) {
  393.     //          if (equipped[i] == null) {
  394.     //              equipped[i] = item;
  395.     //              return (true);
  396.     //          }
  397.     //      }
  398.     //  }
  399.     //  Debug.Log ("Cannot Equip this Item");
  400.     //  return (false);
  401.     //}
  402.    
  403.     //  OLD CODE OLD CODE
  404.    
  405.     //void ToggleLootPanel ( bool open ){
  406.     //  GameObject newUIButtonObject;
  407.     //  UIButton newUIButton;
  408.     //  Debug.Log ("ToggleLootPanel");
  409.     //  if (open) {
  410.     //      lootPanel.list.gameObject.active = true;
  411.     //      lootPanel.list.ClearList(false);
  412.     //      lootPanel.list.ScrollListTo(0);
  413.     //      for (int i = 0; i < lootArray.length; i ++) {
  414.     //          Debug.Log ("Displaying Item: " + i + ". Current List Count: " + lootPanel.list.Count + ".");
  415.     //          newUIButtonObject = (lootArray[i] as InventoryItem).itemIcon as GameObject;
  416.     //          newUIButton = newUIButtonObject.GetComponent<UIButton>();
  417.     //          if (newUIButton != null) {
  418.     ////                lootPanelItems[i].gameObject.SetActiveRecursively(true);
  419.     ////                FIXME_VAR_TYPE clone= Instantiate (newUIButtonObject, transform.position + Vector3 (0 + (35 * i), 125, 0), Quaternion.identity);                //  Testing
  420.     ////                FIXME_VAR_TYPE clone2= Instantiate (newUIButton.gameObject, transform.position + Vector3 (0 + (35 * i), 75, 0), Quaternion.identity);           //  Testing
  421.     //             
  422.     //              lootPanelItems[i].Copy(newUIButton);        //  This is trying to copy a UIButton into a UIListButton but it doesn't work....
  423.     ////                FIXME_VAR_TYPE clone3= Instantiate (lootPanelItems[i].gameObject, transform.position + Vector3 (0 + (35 * i), 40, 0), Quaternion.identity); //  Testing
  424.     //              lootPanelItems[i].data = lootArray[i];
  425.     //              Debug.Log ("LootArray[" + i + "] = " + lootArray[i]);
  426.     //              lootPanel.list.AddItem (lootPanelItems[i], lootArray[i].itemName);
  427.     //          } else {
  428.     //              Debug.Log ("GameManager.ToggleLootPanel is Null at " + i);
  429.     //          }
  430.     //      }
  431.     //  } else {
  432.     //      lootPanel.list.ClearList(false);
  433.     //      lootPanel.list.ScrollListTo(0);
  434.     //      lootPanel.list.gameObject.SetActiveRecursively(false);
  435.     //      for (int j = 0; j < lootPanelItems.length; ++j) {
  436.     //          gameController.lootPanelItems[j].transform.parent = gameController.lootPanel.parentTransform;
  437.     //      }
  438.     //  }
  439.     //}
  440.     //
  441.     //
  442.     //void AddItem ( IUIObject obj ){
  443.     ////void AddLootItem ( UIObject obj ){
  444.     //  UIListButton btn = obj;
  445.     //  InventoryItem item = btn.data;
  446.     //  for (int i = 0; i < inventory.length; i ++) {               //  Go through each row
  447.     //      if (inventory[i] == null) {                                 //  If the position is empty...
  448.     //          inventory[i] = item;                                    //  ... add the new item....
  449.     //          Debug.Log ("Adding Item " + item.itemName + " to the inventory");
  450.     //          if (item.isQuestObjective)                              //  ... check the item against the quest log...
  451.     //              CheckQuests (item);
  452.     //          return (true);                                          //  ... and exit the function.
  453.     //      }
  454.     ////        itemButton.Copy( InvPalette.instance.list[inItem.btnIndex] );
  455.     //  }
  456.     // 
  457.     //  Debug.Log ("Inventory is full");
  458.     //  return (false);
  459.     //}
  460.     //
  461.     //
  462.     //void EquipItem ( InventoryItem item ){
  463.     //  for (int i = 0; i < equipped.length; i ++) {
  464.     //      if (equippedSlot[i].slotType == item.slotType) {
  465.     //          if (equipped[i] == null) {
  466.     //              equipped[i] = item;
  467.     //              return (true);
  468.     //          }
  469.     //      }
  470.     //  }
  471.     //  Debug.Log ("Cannot Equip this Item");
  472.     //  return (false);
  473.     //}
  474.     //
  475.     //
  476.     //void ToggleInventoryPanel ( bool open ){
  477.      // if (open) {
  478.     //      inventoryPanel.StartTransition(UIPanelManager.SHOW_MODE.BringInForward);
  479.     //  } else {
  480.     //      inventoryPanel.StartTransition(UIPanelManager.SHOW_MODE.DismissForward);
  481.     //  }
  482.     //}
  483.     //
  484.     //
  485.     //void LootableObjectOutofRange (){ //close the windows, clear the scrollList,etc.
  486.     //  openLootPanel = false;
  487.     //  openInventoryPanel = false;
  488.     //}
  489.    
  490.    
  491.     //void AddItem ( InventoryItem item ){
  492.     //  for (int i = 0; i < inventory.length; i ++) {               //  Go through each row
  493.     //      if (inventory[i] == null) {                                 //  If the position is empty...
  494.     //          inventory[i] = item;                                    //  ... add the new item....
  495.     //          if (item.isQuestObjective)                              //  ... check the item against the quest log...
  496.     //              CheckQuests (item);
  497.     //          return (true);                                          //  ... and exit the function.
  498.     //      }
  499.     ////        itemButton.Copy( InvPalette.instance.list[inItem.btnIndex] );
  500.     //  }
  501.     // 
  502.     //  Debug.Log ("Inventory is full");
  503.     //  return (false);
  504.     //}
  505.    
  506.    
  507.     //void EquipItem ( InventoryItem item ){
  508.     //  for (int i = 0; i < equipped.length; i ++) {
  509.     //      if (equippedSlot[i].slotType == item.slotType) {
  510.     //          if (equipped[i] == null) {
  511.     //              equipped[i] = item;
  512.     //              return (true);
  513.     //          }
  514.     //      }
  515.     //  }
  516.     //  Debug.Log ("Cannot Equip this Item");
  517.     //  return (false);
  518.     //}
  519.    
  520. //  void CreateCharacterSlots () {
  521. //  //  EquipmentSlot currentSlot;                                                  //  This seems to be here for the equip functions
  522. // 
  523. //      int equippedLength = equippedSlots.arrayLength;
  524. //      equippedSlots.array = new UIButton[equippedLength];
  525. //     
  526. //      UIButton currentUIButton;                                                   //  'currentUIButton' is declared but never used
  527. //      for (int i = 0; i < equippedLength; i++) {
  528. //          equippedSlots.array[i] = (UIButton)Instantiate(equippedSlotUIButton[i], equippedSlots.parentTransform.position, Quaternion.identity);
  529. //          equippedSlots.array[i].transform.parent = equippedSlots.parentTransform;
  530. ////            equippedSlots.array[i].transform.localPosition = equippedSlot[i].slotOffset;
  531. //  //      equippedSlots.array[i].transform.localPosition.z = -12;
  532. //  //      equippedSlots.array[i].transform.localRotation = Quaternion.identity;
  533. //          equippedSlots.array[i].renderCamera = equippedSlots.renderCamera;
  534. //          equippedSlots.array[i].scriptWithMethodToInvoke = equippedSlots.script;
  535. //          equippedSlots.array[i].methodToInvoke = equippedSlots.method;
  536. //  //      equippedSlots.array[i].offset.x = equippedSlot[i].slotOffset.x;
  537. //  //      equippedSlots.array[i].offset.y = equippedSlot[i].slotOffset.y;
  538. // 
  539. //      }
  540. //      equippedSlots.parentPanelObject.SetActiveRecursively(false);
  541. //          currentSlot = equippedSlot[i];
  542. //          currentRect = currentSlot.slotRect;
  543. //          if (equipped[i] == null) {
  544. //              GUI.DrawTexture (currentRect, currentSlot.slotIcon);                //  Slot Rect & Empty Slot Icon
  545. //          } else {
  546. //              GUI.DrawTexture (currentRect, equipped[i].itemIcon);                //  Slot Rect & Item Icon
  547. //              if (GUI.Button (currentRect, "", GUIStyle ("label"))) {
  548. //                  if (Input.GetMouseButtonUp (0)) {                               //  ... if that click is mouse button 0: Remove/Unequip it.
  549. //                      bool success = AddItem (equipped[i]);                       //  Remove/Unequip it.
  550. //                      if (success)                                                //  If it's successfully added to the inventory, remove it here
  551. //                          equipped[i] = null;
  552. //                  }
  553. //              }
  554. //          }
  555. //      GUI.DrawTexture (new Rect (64, 25, 64, 128), player.icon);                  //  characterIcon
  556. //  }
  557.  
  558. #endregion
  559. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement