public void OnDrop(PointerEventData eventData) { Slot dropSlot = eventData.pointerCurrentRaycast.gameObject.GetComponent <Slot>(); if (dropSlot.myItem == null && eventData.pointerCurrentRaycast.gameObject.CompareTag("Slot")) { AddItem(inventory.draggingItem, inventory.draggingAmount); inventory.EndDrag(); toolBelt.DragAndDropCheck(); } //else if(dropSlot != null && eventData.pointerCurrentRaycast.gameObject.CompareTag("Slot") && dropSlot.slotID == slotID) // { //print("Same slot as it was, currently and error!!"); //inventory.AddItemSpecific(inventory.draggingItem, inventory.draggingAmount, slotID); // inventory.EndDrag(); //} }
public void LoadGame(string saveFile, string saveType) { if (!Directory.Exists(Application.persistentDataPath + "/game_save/" + saveFile)) { return; } BinaryFormatter bf = new BinaryFormatter(); if (File.Exists(Application.persistentDataPath + "/game_save/" + saveFile + "/" + saveType)) { FileStream file = File.Open(Application.persistentDataPath + "/game_save/" + saveFile + "/" + saveType, FileMode.Open); //handle save types if (saveType == "inventory.txt") { JsonUtility.FromJsonOverwrite((string)bf.Deserialize(file), inventoryData); //removing old inventory for (int i = 0; i < inventorySize; i++) { Slot currentSlot = inventory.slots[i].GetComponent <Slot>(); currentSlot.myAmount = 0; if (currentSlot.myImage != null) { currentSlot.myImage.enabled = false; } currentSlot.myItem = null; currentSlot.ShowUI(); } //adding the new inventory for (int i = 0; i < inventorySize; i++) { if (inventoryData.itemIDs[i] > 0) { inventory.AddItemSpecific(database.GetItemById(inventoryData.itemIDs[i]), inventoryData.itemAMTs[i], i); } } } //handles loading for playerState if (saveType == "player.txt") { JsonUtility.FromJsonOverwrite((string)bf.Deserialize(file), playerStateData); playerObject.transform.position = playerStateData.playerPos; playerObject.transform.rotation = playerStateData.playerRot; //Destroy(playerObject); //playerObject = Instantiate(newPlayerObject, playerStateData.playerPos, playerStateData.playerRot); } toolBelt.DragAndDropCheck(); file.Close(); loadMenu.SetActive(false); pauseMenu.pauseMenu.SetActive(false); PauseMenu.isPaused = false; pauseMenu.UnpauseGame(); //set pickupPrompt to active harvest = GameObject.FindObjectOfType <Harvest>(); harvest.pickUpPrompt.SetActive(true); //set up player FPS Arms animator weaponChange.GetAnimatorComponent(); } }