So until now in my game i got a little content already, the problem is the playerprefs.If the player reenters the game the cost of the buttons is equal to the basecost but if you click, it returns to the original state.
this is my itemmanager code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class itemmanager : MonoBehaviour {
public UnityEngine.UI.Text iteminfo;
public click click;
public float cost;
public int tickvalue;
public int count;
public string itemname;
private float basecost;
public Color standart;
public Color affordable;
private Slider _slider;
void Start (){
basecost = cost;
_slider = GetComponentInChildren();
count = PlayerPrefs.GetInt(“count”, 0);
}
void Update (){
iteminfo.text = itemname + “\n cost:” + currencyconverter.Instance.getcurrencyintostring (cost,false,false) + “\n Euro:” + tickvalue + “/s”;
/if (click.Euro >= cost) {
GetComponent ().color = affordable;
} else {
GetComponent().color = standart;
}/
_slider.value = click.Euro / cost * 100;
if (_slider.value >= 100) {
GetComponent ().color = affordable;
} else {
GetComponent ().color = standart;
}
}
public void purchaseditem(){
if (click.Euro >= cost) {
click.Euro -= cost;
count += 1;
cost = Mathf.Round( basecost * Mathf.Pow (1.15f, count));
}
}
void OnDestroy(){
PlayerPrefs.SetInt (“count”, count);
PlayerPrefs.Save();
}
}