playerpref steps

This commit is contained in:
asleal2 2018-04-26 01:18:08 -05:00
parent f3c4d0b610
commit c2ed30d441

View file

@ -11,18 +11,15 @@ namespace PedometerU.Tests {
public class GetGoals : MonoBehaviour { public class GetGoals : MonoBehaviour {
public Text goalText; public Text goalText;
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
public string prefKey; public string prefKey;
public float goalValue; public float goalValue;
//Progress Bar... //Progress Bar...
public float barDisplay; //current progress public float barDisplay; //current progress
private Vector2 barPos; private Vector2 barPos;
Vector2 barSize = new Vector2(227,20); private Vector2 barSize = new Vector2(227,20);
//Pedometer //Pedometer
private Pedometer pedometer; private Pedometer pedometer;
@ -35,6 +32,7 @@ public class GetGoals : MonoBehaviour {
userSteps = steps; userSteps = steps;
stepText.text = steps.ToString (); stepText.text = steps.ToString ();
userDistance = (distance * 3.28084); userDistance = (distance * 3.28084);
PlayerPrefs.setInt("currentSteps",userSteps);
} }
private void OnDisable () { private void OnDisable () {
@ -47,7 +45,7 @@ public class GetGoals : MonoBehaviour {
// Create a new pedometer // Create a new pedometer
pedometer = new Pedometer(OnStep); pedometer = new Pedometer(OnStep);
// Reset UI // Reset UI
OnStep(0, 0); OnStep(PlayerPrefs.getInt("currentSteps"), 0);
//goalText.text = prefKey; //goalText.text = prefKey;
goalText.color = new Color(0f, 0f, 0f); goalText.color = new Color(0f, 0f, 0f);
@ -104,6 +102,7 @@ public class GetGoals : MonoBehaviour {
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
//barDisplay = Time.time*0.05f; //put actual progress here (current/total) //barDisplay = Time.time*0.05f; //put actual progress here (current/total)
barDisplay = (float)userSteps/(float)totalSteps; barDisplay = (float)userSteps/(float)totalSteps;
//failed to complete goal //failed to complete goal
if(currentDayStr != goalDayStr) if(currentDayStr != goalDayStr)
{ {
@ -137,4 +136,5 @@ public class GetGoals : MonoBehaviour {
} }
} }
} }
} }