Hey guys i have a timer running and as simple as it may seem i cant seem to add to it with breaking the structure. i want to add to once certain score markers are hit
here is the code:
public float Seconds = 30;
public float Minutes = 0;
public AudioClip mark;
public AudioClip TimeB;
// Use this for initialization
void Start () {
GameObject.Find("Timer").guiText.material.color = Color.white;
}
void OnGUI()
{
if (Seconds <= 10)
{
GameObject.Find("Timer").guiText.material.color = Color.red;
audio.PlayOneShot(mark);
}
}
// Update is called once per frame
void Update ()
{
if ( Seconds <= 0)
{
Seconds = 30;
if(Minutes >= 1)
{
Minutes --;
}
else
{
Minutes = 0;
Seconds = 0;
//This makes the guitext show the time as X:XX ToString ("f0") formats it so there is no decimal
GameObject.Find("Timer").guiText.text = Minutes.ToString("f0") + ":0" + Seconds.ToString("f0");
}
}
else
{
Seconds -= Time.deltaTime;
}
//these lines will make sure the time is shown as x:xx and not x:xxx.xxxxx
if(Mathf.Round(Seconds) <= 9)
{
GameObject.Find("Timer").guiText.text = Minutes.ToString("f0") + ":0" + Seconds.ToString("f0");
}
else
{
GameObject.Find("Timer").guiText.text = Minutes.ToString("f0") + ":" + Seconds.ToString("f0");
}
if(Seconds <= 0)
{
if(Scoring.Score >= PlayerPrefs.GetInt("NewHighScore"))
{
PlayerPrefs.SetInt("NewHighScore", Scoring.Score);
}
Application.LoadLevel("Complete");
}
sample of what im trying to do
if(scoring.score == 2500)
{
timer += 15;
}
when i try this is break structure(meaning all of a sudden decimals are showing and it starts counting upward)