I'm new in unity someone can help me?
for example my health bar value is 100 if you want to upgrade it will cost about 10 coins and if I upgrade my health bar the value becomes 105 and the price of the health bar also increases. How can I do that? I searched a lot, but i didn't see that kind of upgrade. This is my health bar
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HealthManager : MonoBehaviour {
public int maxPlayerHealth;
public static int playerHealth;
//Text text;
public Slider healthBar;
public bool isDead;
public GameObject carExplosionEfect;
// Use this for initialization
void Start () {
//text = GetComponent<Text> ();
healthBar = GetComponent<Slider>();
playerHealth = maxPlayerHealth;
isDead = false;
}
// Update is called once per frame
void Update () {
if (playerHealth <= 0 && !isDead)
{
playerHealth = 0;
isDead = true;
Instantiate (carExplosionEfect, transform.position, transform.rotation);
}
if (playerHealth > maxPlayerHealth) {
playerHealth = maxPlayerHealth;
}
healthBar.value = playerHealth;
}
public static void HurtPlayerOnContact(int damageToGive)
{
playerHealth -= damageToGive;
}
public void FullHealth()
{
playerHealth = maxPlayerHealth;
}
}