/// <summary>
    ///
    /// </summary>
    private void ResearchTreeLoadSate(Save_State load)
    {
        for (int i = 0; i < Chef_Requirment_Purchasable.Count; i++)
        {
            Chef chef = Chef_Requirment_Purchasable[i];
            Chef_Research_Save_State loadState = load.Chef_Research_Save_State[i];

            chef.Name         = loadState.Name;
            chef.Unlocked     = loadState.Unlocked;
            chef.CurrentLevel = loadState.Current_Level;
        }
    }
    /// <summary>
    ///
    /// </summary>
    private void ResearchTreeSaveSate(Save_State save)
    {
        for (int i = 0; i < Chef_Requirment_Purchasable.Count; i++)
        {
            Chef chef = Chef_Requirment_Purchasable[i];
            Chef_Research_Save_State save_state = new Chef_Research_Save_State();

            save_state.Name          = chef.Name;
            save_state.Unlocked      = chef.Unlocked;
            save_state.Current_Level = chef.CurrentLevel;
            save.Chef_Research_Save_State.Add(save_state);
        }
    }
    /// <summary>
    ///
    /// </summary>
    public void LoadFile()
    {
        if (File.Exists(Save_Location))
        {
            BinaryFormatter format = new BinaryFormatter();
            FileStream      file   = File.Open(Save_Location, FileMode.Open);

            Save_State load = (Save_State)format.Deserialize(file);
            file.Close();

            if (load.FirstTime == 0)
            {
                FirstTime = true;
            }
            else
            {
                FirstTime = false;
            }

            //Calendar.Instance.Date = load.Date_Time;

            Current_Date_Time  = load.Current_Date_Time;
            Previous_Date_Time = load.Previous_Date_Time;

            int resource = load.AFK_Resource;

            TimeSpan Difference = DateTime.Now - Previous_Date_Time;

            Game.Instance.AddGold(load.Total_Gold);

            PlayerManager.Instance.TotalXp           = load.Player_Save_State.Total_Xp;
            PlayerManager.Instance.CurrentLevel      = load.Player_Save_State.Current_Level;
            PlayerManager.Instance.XpTillNextLevel   = load.Player_Save_State.Xp_Till_Next_Level;
            PlayerManager.Instance.CurrentExperience = load.Player_Save_State.Current_Experience;
            PlayerManager.Instance.ResearchPoints    = load.Player_Save_State.ResearchPoints;

            ResearchTreeLoadSate(load);

            for (int i = 0; i < load.Resource_Save_State.Count; i++)
            {
                Resource_Save_State itemSave = load.Resource_Save_State[i];
                Inventory.Instance.AddItemToSlot(itemSave.Slot_ID, itemSave.ID, itemSave.Count);

                //Debug.Log("added item to slot: " + itemSave.Slot_ID + " (" + itemSave.Count + ")");
            }

            for (int i = 0; i < load.Item_Save_State.Count; i++)
            {
                Item_Save_State item_Save = load.Item_Save_State[i];

                if (item_Save.Slot_Type == SlotType.Consumable)
                {
                    //create item from save
                    Item item = new Item(
                        item_Save.Name,
                        item_Save.ID,
                        item_Save.Image_ID,
                        item_Save.Stackable,
                        item_Save.Item_Rarity,
                        item_Save.Slot_Type,
                        item_Save.Resource_Type);

                    //for (int x = 0; x < load.Item_Save_State[i].Bonus_Save_State.Count; x++)
                    //{
                    //    BonusType bType = load.Item_Save_State[i].Bonus_Save_State[x].Bonus_Type;
                    //    float bAmount = load.Item_Save_State[i].Bonus_Save_State[x].Amount;

                    //    item.AddBonus(bType, bAmount);
                    //}

                    //add to database
                    Item_Database.Add(item);
                    Inventory.Instance.Items.Add(item);
                    Inventory.Instance.AddItemToSlot(item_Save.Slot_ID, item_Save.ID, item_Save.Count);
                }
            }

            load.Fish_Manager_Research_Points      = FishManager.Instance.Research_Points;
            load.Larder_Manager_Research_Points    = LarderManager.Instance.Research_Points;
            load.Meat_Manager_Research_Points      = MeatManager.Instance.Research_Points;
            load.Pastry_Manager_Research_Points    = PastryManager.Instance.Research_Points;
            load.Sauce_Manager_Research_Points     = SauceManager.Instance.Research_Points;
            load.Vegetable_Manager_Research_Points = VegetableManager.Instance.Research_Points;

            ItemLoadState(load.Fish_Manager_Save_Sate, Fish_Item);
            ItemLoadState(load.Larder_Manager_Save_Sate, Larder_Item);
            ItemLoadState(load.Meat_Manager_Save_Sate, Meat_Item);
            ItemLoadState(load.Pastry_Manager_Save_Sate, Pastry_Item);
            ItemLoadState(load.Sauce_Manager_Save_Sate, Sauce_Item);
            ItemLoadState(load.Vegetable_Manager_Save_Sate, Vegetable_Item);

            RecipeLoadState(load.Recipe_Save_State, Recipe_Item);

            //MessageBox.Instance.SetText("Welcome Back!", "You earned $" + afkR + " while you where away.");
        }
        else
        {
            SaveFile();
        }

        //Debug.Log("loaded");
    }
    /// <summary>
    ///
    /// </summary>
    public void SaveFile()
    {
        BinaryFormatter format = new BinaryFormatter();
        FileStream      file   = File.Create(Save_Location);

        Save_State save = new Save_State();

        if (FirstTime == true)
        {
            save.FirstTime = 0;
        }
        else
        {
            save.FirstTime = 1;
        }

        //save.Date_Time = Calendar.Instance.Date;

        save.Current_Date_Time  = Current_Date_Time;
        save.Previous_Date_Time = Previous_Date_Time;

        save.Total_Gold = Game.Instance.TotalGold;

        save.Player_Save_State                    = new Player_Save_State();
        save.Player_Save_State.Total_Xp           = PlayerManager.Instance.TotalXp;
        save.Player_Save_State.Current_Level      = PlayerManager.Instance.CurrentLevel;
        save.Player_Save_State.Xp_Till_Next_Level = PlayerManager.Instance.XpTillNextLevel;
        save.Player_Save_State.Current_Experience = PlayerManager.Instance.CurrentExperience;
        save.Player_Save_State.ResearchPoints     = PlayerManager.Instance.ResearchPoints;

        ResearchTreeSaveSate(save);

        save.Larder_Manager_Save_Sate    = new List <Food_Section_Save_State>();
        save.Meat_Manager_Save_Sate      = new List <Food_Section_Save_State>();
        save.Pastry_Manager_Save_Sate    = new List <Food_Section_Save_State>();
        save.Sauce_Manager_Save_Sate     = new List <Food_Section_Save_State>();
        save.Vegetable_Manager_Save_Sate = new List <Food_Section_Save_State>();
        save.Fish_Manager_Save_Sate      = new List <Food_Section_Save_State>();

        save.Resource_Save_State = new List <Resource_Save_State>();
        save.Item_Save_State     = new List <Item_Save_State>();

        for (int x = 0; x < Inventory.Instance.slots.Count; x++)
        {
            GameObject slot = Inventory.Instance.slots[x].gameObject;

            if (slot.transform.childCount > 0)
            {
                ItemData item = slot.transform.GetChild(0).GetComponent <ItemData>();

                if (item.Item.SlotType == SlotType.Consumable)
                {
                    Resource_Save_State resourceSave = new Resource_Save_State();

                    resourceSave.ID      = item.Item.ID;
                    resourceSave.Count   = item.count;
                    resourceSave.Slot_ID = x;

                    save.Resource_Save_State.Add(resourceSave);
                }
            }
        }

        FishManager.Instance.Research_Points      = save.Fish_Manager_Research_Points;
        LarderManager.Instance.Research_Points    = save.Larder_Manager_Research_Points;
        MeatManager.Instance.Research_Points      = save.Meat_Manager_Research_Points;
        PastryManager.Instance.Research_Points    = save.Pastry_Manager_Research_Points;
        SauceManager.Instance.Research_Points     = save.Sauce_Manager_Research_Points;
        VegetableManager.Instance.Research_Points = save.Vegetable_Manager_Research_Points;

        float afk_difference = Current_Date_Time.Second - Previous_Date_Time.Second;

        ItemSaveState(save.Fish_Manager_Save_Sate, Fish_Item, afk_difference);
        ItemSaveState(save.Larder_Manager_Save_Sate, Larder_Item, afk_difference);
        ItemSaveState(save.Meat_Manager_Save_Sate, Meat_Item, afk_difference);
        ItemSaveState(save.Pastry_Manager_Save_Sate, Pastry_Item, afk_difference);
        ItemSaveState(save.Sauce_Manager_Save_Sate, Sauce_Item, afk_difference);
        ItemSaveState(save.Vegetable_Manager_Save_Sate, Vegetable_Item, afk_difference);

        RecipeSaveState(save.Recipe_Save_State, Recipe_Item);

        format.Serialize(file, save);
        file.Close();

        Debug.Log("saved");
    }