Ok ive been looking at my code for so long that i cant see whats wrong with it so could i have some help sorting the time atm it dosent sort it properly
edit: what i am doing is timing the player to complete a level the time is taken and sorted then the player can start again it resets time and start counting again and so on
using UnityEngine;
using System.Collections;
using System.IO;
using System;
public class Score : MonoBehaviour {
public int Time;
public int BestTime;
public int SecondBestTime;
public int ThirdBestTime;
void Start ()
{
Time = PlayerPrefs.GetInt("Time");
BestTime = PlayerPrefs.GetInt("Best Time");
SecondBestTime = PlayerPrefs.GetInt ("Second Best Time");
ThirdBestTime = PlayerPrefs.GetInt ("Third Best Time");
InvokeRepeating("Points", 2, 0.3F);
}
// Update is called once per frame
void Points ()
{
Time += 1;
PlayerPrefs.SetInt("Time",Time);
if (Time >= BestTime || Time < BestTime)
{
// Set the highscore to our current score
BestTime = Time;
// savign highscore
PlayerPrefs.SetInt("Best Time", BestTime);
}
else
{
if(Time >= SecondBestTime && Time > BestTime && Time > ThirdBestTime)
{
SecondBestTime = Time;
PlayerPrefs.SetInt("Second Best Time", SecondBestTime);
}
}
if (Time >= ThirdBestTime && Time < SecondBestTime && Time < BestTime )
{
// Set the highscore to our current score
ThirdBestTime = Time;
// savign highscore
PlayerPrefs.SetInt("Third Best Time", ThirdBestTime);
}
}
void OnGUI()
{
Time = PlayerPrefs.GetInt("Time");
GUI.Box(new Rect(200,10,100,30),"Time:"+Time.ToString());
}
}