So In My Temple Run Game I Have Accomplished a lot (Though Making It For Pc) I Am Stucked on Diamonds Or COins .
My Question is that My DIamonds Get Saved Using PlayerPrefs But evry time one plays it removes the other diamonds which were saved previously But i want them to be added and not removed
If You Didn’t understand what i am trying to say
You May Have Played Temple Run Or SubWay Surfers
When U Play It For The First Time Suppose You Get 100 coins in first But When You Play Again suppose you get 50 coins in The Game They Get Added And You Get Your coins to be 150
But In My Game 100 gets replaced by 50 Please Help
#pragma strict
static var Diamond :int = 0 ;
var Text = "Diamonds : " + 0 ;
var NumDiamonds : int = 1;
static var Total :int;
function Awake(){
}
function Start () {
}
function Update () {
if(P_C.DiamondMultiplier){
if(Shop.Boost1){
NumDiamonds = 2;
}
if(Shop.Boost2){
NumDiamonds = 3;
}
if(Shop.Boost3){
NumDiamonds = 4;
}
}
PlayerPrefs.SetInt("Diamonds",Diamonds.Diamond);
if(PlayerPrefs.HasKey("Diamonds")){
PlayerPrefs.SetInt("Diamonds" , PlayerPrefs.GetInt("Diamonds")+Diamond);
}
}
function OnTriggerEnter(other:Collider){
if (other.tag == "Diamonds") {
Debug.Log("Other object is a Coins");
Diamond += NumDiamonds; // They Are A Variable Used For Multiplying Boosts
Text = "Diamonds : " + Diamond;
Debug.Log("Score is now " + Diamond);
Destroy(other.gameObject);
}
if(P_C.DiamondMultiplier){
}
}
function OnGUI(){
GUI.Box (Rect (900, 570, 130, 25), Text);
}
I Hope You Can Help Me