/// <summary> /// Sets this inventory slot item to be selected /// </summary> public void SetSelectedItem() { // Clear currently highlighted items inventoryBar.ClearHighlightOnInventorySlots(); // Highlight item oninventory bar isSelected = true; // Set highlighted inventory slots inventoryBar.SetHighlightedInventorySlots(); // Set use radius for cursors gridCursor.ItemUseGridRadius = itemDetails.itemUseGridRadius; cursor.ItemUseRadius = itemDetails.itemUseRadius; // if item require a grid cursor then enable it if (itemDetails.itemUseGridRadius > 0) { gridCursor.EnableCursor(); } else { gridCursor.DisableCursor(); } // use cursor use radius to enable/ disable if (itemDetails.itemUseRadius > 0) { cursor.EnableCursor(); } else { cursor.DisableCursor(); } // Set item type gridCursor.SelectedItemType = itemDetails.itemType; cursor.SelectedItemType = itemDetails.itemType; // Set item selected in inventory InventoryManager.Instance.SetSelectedInventoryItem(InventoryLocation.player, itemDetails.itemCode); if (itemDetails.canBeCarried == true) { // show player carryin item Player.Instance.ShowCarriedItem(itemDetails.itemCode); } else { // show player carrying nothing Player.Instance.ClearCarriedItem(); } }
private void SetSelectedItem() { // Clear currently highlighted items inventoryBar.ClearHighlightOnInventorySlots(); // Highlight item on inventory bar isSelected = true; // Set highlighted inventory slots inventoryBar.SetHighlightedInventorySlots(); // Store the item's use radius for the cursors gridCursor.ItemUseGridRadius = itemDetails.itemUseGridRadius; cursor.ItemUseRadius = itemDetails.itemUseRadius; // If the item's itemUseGridRadius is greater than 0 we want to enable the grid cursor, else disable it if (itemDetails.itemUseGridRadius > 0) { gridCursor.EnableCursor(); } else { gridCursor.DisableCursor(); } // If the item's itemUseRadius is greater than 0 we want to enable the grid cursor, else disable it if (itemDetails.itemUseRadius > 0f) { cursor.EnableCursor(); } else { cursor.DisableCursor(); } // Set the cursors' SelectedItemType to the item's itemType gridCursor.SelectedItemType = itemDetails.itemType; cursor.SelectedItemType = itemDetails.itemType; // Set item selected in inventory InventoryManager.Instance.SetSelectedInventoryItem(InventoryLocation.player, itemDetails.itemCode); if (itemDetails.canBeCarried == true) { Player.Instance.ShowCarriedItem(itemDetails.itemCode); } else { Player.Instance.ClearCarriedItem(); } }
/// <summary> /// Sets this inventorySlot item to be selected /// </summary> private void SetSelectedItem() { // clear the currently highlighted items inventoryBar.ClearHighlightOnInventorySlots(); // Highlight the item on the inventory bar isSelected = true; // Set highlighted inventory slots inventoryBar.SetHighlightedInventorySlots(); // Set the use gridradius and radius for the cursors in GridCursor and Cursor gridCursor.ItemUseGridRadius = itemDetails.itemUseGridRadius; cursor.ItemUseRadius = itemDetails.itemUseRadius; // If the item requires a grid cursor (useRadius > 0), then enable it. Else, diable it if (itemDetails.itemUseGridRadius > 0) { gridCursor.EnableCursor(); } else { gridCursor.DisableCursor(); } // If the item requires a cursor (useRadius > 0), then enable it. Else, diable it if (itemDetails.itemUseRadius > 0) { cursor.EnableCursor(); } else { cursor.DisableCursor(); } // Set the item type for both cursors gridCursor.SelectedItemType = itemDetails.itemType; cursor.SelectedItemType = itemDetails.itemType; // Set item selected in inventory list InventoryManager.Instance.SetSelectedInventoryItem(InventoryLocation.player, itemDetails.itemCode); if (itemDetails.canBeCarried == true) { // Show the player carrying the item Player.Instance.ShowCarriedItem(itemDetails.itemCode); } else // Show the player carrying nothing { Player.Instance.ClearCarriedItem(); } }
public void ISaveableLoad(GameSave gameSave) { // Check the save data for the game object if (gameSave.gameObjectData.TryGetValue(ISaveableID, out GameObjectSave gameObjectSave)) { GameObjectSave = gameObjectSave; // Get the data from the main scene--this is where the inventory is stored if (gameObjectSave.SceneData.TryGetValue(Settings.MainScene, out SceneSave sceneSave)) { // Check if we have our inventory items list if (sceneSave.ListInvItemArray != null) { inventoryLists = sceneSave.ListInvItemArray; // Update the inventory for (int i = 0; i < (int)InventoryLocation.count; i++) { EventHandler.CallInventoryUpdatedEvent((InventoryLocation)i, inventoryLists[i]); } // Clear any carried items or highlights Player.Instance.ClearCarriedItem(); inventoryBar.ClearHighlightOnInventorySlots(); } // Check for the inventoryListCapacityIntArray if (sceneSave.intArrayDictionary != null && sceneSave.intArrayDictionary.TryGetValue("inventoryListCapacityArray", out int[] inventoryCapacityArray))
public void ISaveableLoad(GameSave gameSave) { if (gameSave.gameObjectData.TryGetValue(ISaveableUniqueID, out GameObjectSave gameObjectSave)) { GameObjectSave = gameObjectSave; // Need to find inventory lists - start by trying to locate saveScene for game object if (gameObjectSave.sceneData.TryGetValue(Settings.PersistentScene, out SceneSave sceneSave)) { // list inv items array exists for persistent scene if (sceneSave.listInvItemArray != null) { inventoryLists = sceneSave.listInvItemArray; // Send events that inventory has been updated for (int i = 0; i < (int)InventoryLocation.count; i++) { EventHandler.CallInventoryUpdatedEvent((InventoryLocation)i, inventoryLists[i]); } // Clear any items player was carrying Player.Instance.ClearCarriedItem(); // Clear any highlights on inventory bar inventoryBar.ClearHighlightOnInventorySlots(); } // int array dictionary exists for scene if (sceneSave.intArrayDictionary != null && sceneSave.intArrayDictionary.TryGetValue("inventoryListCapacityArray", out int[] inventoryCapacityArray))
// This is a required method for the ISaveable interface, which passes in a GameObjectSave dictionary, and restores the current scene from it // The SaveLoadManager script will loop through all of the ISaveableRegister GameObjects (all registered with their ISaveableRegister methods), and trigger this // ISaveableLoad, which will load that Save data (here for the persistent scene inventory information, which includes a list of inventory items, and // an int[] dict for the different inventory location capacities), for each scene (GameObjectSave is a Dict keyed by scene name) public void ISaveableLoad(GameSave gameSave) { // gameSave stores a Dictionary of items to save keyed by GUID, see if there's one for this GUID (generated on the InventoryManager GameObject) if (gameSave.gameObjectData.TryGetValue(ISaveableUniqueID, out GameObjectSave gameObjectSave)) { // Get the save data for the scene, if one exists for the PersistentScene (what the inventory info is saved under) if (gameObjectSave.sceneData.TryGetValue(Settings.PersistentScene, out SceneSave sceneSave)) { // Get the inventory item array dictionary, if the SceneSave listInvItemArray exists in the persistent scene if (sceneSave.listInvItemArray != null) { // Saved inventory list inventoryLists = sceneSave.listInvItemArray; // Send events that the inventory has been updated for each inventory location for (int i = 0; i < (int)InventoryLocation.count; i++) { EventHandler.CallInventoryUpdatedEvent((InventoryLocation)i, inventoryLists[i]); } // Clear out any items the player migth have been carrying Player.Instance.ClearCarriedItem(); // Clear out any highlights on the inventory bar inventoryBar.ClearHighlightOnInventorySlots(); } // Get the array of inventory capacities (i.e. for backpack, chest, etc) if it exists, and contains the "inventoryListCapacityArray" key. if (sceneSave.intArrayDictionary != null && sceneSave.intArrayDictionary.TryGetValue("inventoryListCapacityArray", out int[] inventoryCapacityArray))
/// <summary> /// Sets this inventory slot item to be selected /// </summary> private void SetSelectedItem() { // Clear currently highlighted items inventoryBar.ClearHighlightOnInventorySlots(); // Highlight item on inventory bar isSelected = true; // Set highlighted inventory slots inventoryBar.SetHighlightedInventorySlots(); // Set item type // Set item selected in inventory InventoryManager.Instance.SetSelectedInventoryItem(InventoryLocation.player, itemDetails.itemCode); }