public void AddFruit(string fruitName, int islandID)
    {
        for (int i = 0; i < inventory.islands.Count; i++)
        {
            bool             isNewFruit  = true;
            FruitInInventory fruitToEdit = new FruitInInventory();
            for (int j = 0; j < inventory.islands[i].fruitInStorage.Count; j++)
            {
                if (inventory.islands[i].fruitInStorage[j].name == fruitName)
                {
                    isNewFruit  = false;
                    fruitToEdit = inventory.islands[i].fruitInStorage[j];

                    fruitToEdit.amt += 1;
                    inventory.islands[i].fruitInStorage.RemoveAt(j);
                    inventory.islands[i].fruitInStorage.Insert(j, fruitToEdit);
                    break;
                }
            }

            if (isNewFruit)
            {
                fruitToEdit.name = fruitName;
                fruitToEdit.amt  = 1;
                inventory.islands[islandID].fruitInStorage.Add(fruitToEdit);
            }
        }
        SaveInventory();
    }
    public void RemoveFruit(FruitInInventory fruit)
    {
        for (int i = 0; i < inventory.islands.Count; i++)
        {
            for (int j = 0; j < inventory.islands[i].fruitInStorage.Count; j++)
            {
                FruitInInventory fruitToEdit = new FruitInInventory();
                if (inventory.islands[i].fruitInStorage[j].name == fruit.name)
                {
                    fruitToEdit = inventory.islands[i].fruitInStorage[j];

                    fruitToEdit.amt -= 1;
                    inventory.islands[i].fruitInStorage.RemoveAt(i);
                    inventory.islands[i].fruitInStorage.Insert(i, fruitToEdit);
                    break;
                }
            }
        }
    }
    public void RemoveFruit(string fruitName, int islandID)
    {
        for (int i = 0; i < inventory.islands.Count; i++)
        {
            FruitInInventory fruitToEdit = new FruitInInventory();
            for (int j = 0; j < inventory.islands[i].fruitInStorage.Count; j++)
            {
                if (inventory.islands[i].fruitInStorage[j].name == fruitName)
                {
                    fruitToEdit = inventory.islands[i].fruitInStorage[j];

                    fruitToEdit.amt -= 1;
                    inventory.islands[i].fruitInStorage.RemoveAt(j);
                    inventory.islands[i].fruitInStorage.Insert(j, fruitToEdit);
                    break;
                }
            }
        }

        SaveInventory();
    }
    void LoadInventory()
    {
        //Debug.Log("LOADING INVENTORY");
        string filePath = Application.persistentDataPath + fileName;

        //string filePath = fileName;

        if (File.Exists(filePath))
        {
            string        dataAsJson    = File.ReadAllText(filePath);
            JsonInventory jsonInventory = JsonUtility.FromJson <JsonInventory>(dataAsJson);

            Inventory newInventory = new Inventory()
            {
                eggs    = new List <EggInInventory>(),
                seeds   = new List <SeedInInventory>(),
                islands = new List <IslandStorage>(),
                chests  = new List <ChestInInventory>()
            };

            newInventory.currency = jsonInventory.currencyAmt;
            currencyUI.GetComponent <Text>().text = newInventory.currency.ToString();

            for (int i = 0; i < jsonInventory.eggs.Length; i++)
            {
                EggInInventory newEgg = new EggInInventory()
                {
                    name = jsonInventory.eggs[i],
                    amt  = jsonInventory.eggAmts[i]
                };
                newInventory.eggs.Add(newEgg);
            }

            for (int i = 0; i < jsonInventory.seeds.Length; i++)
            {
                SeedInInventory newSeed = new SeedInInventory()
                {
                    name = jsonInventory.seeds[i],
                    amt  = jsonInventory.seedAmts[i]
                };
                newInventory.seeds.Add(newSeed);
            }

            for (int i = 0; i < jsonInventory.chests.Length; i++)
            {
                ChestInInventory newChest = new ChestInInventory()
                {
                    name = jsonInventory.chests[i],
                    amt  = jsonInventory.chestAmts[i]
                };
                newInventory.chests.Add(newChest);
            }

            IslandStorage newStorage = new IslandStorage()
            {
                fruitInStorage = new List <FruitInInventory>()
            };
            for (int i = 0; i < jsonInventory.fruits0.Length; i++)
            {
                FruitInInventory newFruitInInventory = new FruitInInventory();
                newFruitInInventory.name = jsonInventory.fruits0[i];
                newFruitInInventory.amt  = jsonInventory.fruitAmts0[i];
                newStorage.fruitInStorage.Add(newFruitInInventory);
                //Debug.Log("Added fruit");
            }
            newInventory.islands.Add(newStorage);

            newStorage = new IslandStorage()
            {
                fruitInStorage = new List <FruitInInventory>()
            };
            for (int i = 0; i < jsonInventory.fruits1.Length; i++)
            {
                FruitInInventory newFruitInInventory = new FruitInInventory();
                newFruitInInventory.name = jsonInventory.fruits1[i];
                newFruitInInventory.amt  = jsonInventory.fruitAmts1[i];
                newStorage.fruitInStorage.Add(newFruitInInventory);
                //Debug.Log("Added fruit");
            }
            newInventory.islands.Add(newStorage);

            newStorage = new IslandStorage()
            {
                fruitInStorage = new List <FruitInInventory>()
            };
            for (int i = 0; i < jsonInventory.fruits0.Length; i++)
            {
                FruitInInventory newFruitInInventory = new FruitInInventory();
                newFruitInInventory.name = jsonInventory.fruits2[i];
                newFruitInInventory.amt  = jsonInventory.fruitAmts2[i];
                newStorage.fruitInStorage.Add(newFruitInInventory);
                //Debug.Log("Added fruit");
            }
            newInventory.islands.Add(newStorage);

            inventory = newInventory;

            //Debug.Log("LOADED INVENTORY");
        }
        else
        {
            SaveInventory();
        }
    }