What is Wrong With The Logic in My Variable?

I am working on creating my In-Game Currency. I have two variables… one to represent what “gem count” is for the current game session and also what is displayed when you get to the “Game Over” scene; the other is for the overall Bank of gems that I am putting in my store. What is wrong with my logic in my “GameOverManager” script that explains why my overall Bank of gems is not increasing after every game session?

Snippet of my GameOverManager script below:

All of my StoreManager script so far below:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class StoreManager : MonoBehaviour 
{
	public Text gemCountText;

	private int storeGemCount;

	void Start () 
	{
		storeGemCount = PlayerPrefs.GetInt("PLAYERPREFS_GemScore_GameOver");	//storeGemCount is equal to this Playerprefs that I set in GameOverManager
	}

	void Update () 
	{
		gemCountText.text = "Gem Count:" + " " + storeGemCount;	//This displays the value of storeGemCount
	}
}

If you need more information or something else please let me know

I am just going by what I currently see Right off the bat I can sort of see a problem. For proper design I would suggest using a different approach:

class PlayerPrefs
{
    //Static so you don't need to instance a playerPrefs class to refrence the one int
    static int GemScore_GameOver = 0; 
    //Logic to populate GemScore
}

public class StoreManager : MonoBehaviour
{
    private int storeGemCount;
    void StoreManager()
    {
        //You don't have to do this if you only reference it once. **Also this only sets the store GemCount at START so you will not be able to update it at runtime. Meaning soreGemCount ONLY grabs the playerPref on the Start of this class, once.** 
        storeGemCount = PlayerPrefs.GemScore_GameOver;
    }

     void Update () 
     {
        //You don't need to assign storeGemCount if you are just refrencing it once. This will grab gemscore from the static var on playerPrefs and update properly
         gemCountText.text = "Gem Count:" + " " + PlayerPrefs.GemScore_GameOver;
     }
}

Let me know if this makes sense to you, this is a important design practice.

In AfterCollisionWithItems you do this

void Start ()
{
    count = 0;
}

void Update ()
{
    PlayerPrefs.SetInt ("PLAYERPREF_GemCount", count);
}

and then in GameOverManager you do this

void Start ()
{
    gemScore = PlayerPrefs.GetInt ("PLAYERPREF_GemCount");
    gemBankForStore += gemScore;
}

gemScore will be zero by the time you do this

gemScore = PlayerPrefs.GetInt ("PLAYERPREF_GemCount");

Personally I do not no the reason why you feel the need to have three classes to handle these values. But This should remedy your problem

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
 
public class AfterCollisionWithItems : MonoBehaviour
{
    public Text countText;
 
    public int count;
 
    private static AfterCollisionWithItems instance;
 
    void Awake ()
    {
        instance = this;
    }
 
    public static AfterCollisionWithItems Instance
    {
        get
        {
            return instance;
        }
    }
   
    public int count;
    void Start ()
    {
        count = 0;
        SetCountText (PlayerPrefs.GetInt ("PLAYERPREF_GemCount", 0)); // defaults to 0 if key does not exist
    }

    void OnTriggerEnter (Collider item)
    {
        if (item.gameObject.tag == "Sapphire")
        {
            item.gameObject.SetActive (false);
            SetCountText(1, false); // change false to true if you want to update PLAYERPREF_GemCount
        }
        else if (item.gameObject.tag == "Ruby")
        {
            item.gameObject.SetActive(false);
            SetCountText(2, false); // change false to true if you want to update PLAYERPREF_GemCount
        }
 
        else if (item.gameObject.tag == "Diamond")
        {
            item.gameObject.SetActive (false);
            SetCountText(3, false); // change false to true if you want to update PLAYERPREF_GemCount
        }
    }
 
    void SetCountText (int value, bool updatePlayerPrefs)
    {
        count += value;
        countText.text = "" + count.ToString ();
        if (updatePlayerPrefs)
        {
            PlayerPrefs.SetInt ("PLAYERPREF_GemCount", count);
        }
    }
}