extra fixes to pedometer/fitbit behavior

This commit is contained in:
asleal2 2018-05-04 02:59:27 -05:00
parent 030c4b922d
commit dff6f9036b
3 changed files with 37 additions and 18 deletions

Binary file not shown.

Binary file not shown.

View file

@ -85,6 +85,7 @@ namespace PedometerU.Tests
void Start ()
{
//PlayerPrefs.SetInt("currentGoals", 0);
//PlayerPrefs.DeleteAll(); //danger!!
if(prefKey == "daily")
{
@ -106,6 +107,12 @@ namespace PedometerU.Tests
// Reset UI
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
if(!PlayerPrefs.HasKey("goalComplete"))
{
PlayerPrefs.SetInt("goalComplete", 0);
}
if(PlayerPrefs.HasKey(totalPointsKey))
{
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
@ -223,6 +230,12 @@ namespace PedometerU.Tests
rivalText.text = "You are being chased by " + mp.players [0].username;
}
public void refreshSteps()
{
int fitbitSteps = PlayerPrefs.GetInt("fitbitSteps");
PlayerPrefs.SetInt(currentStepsKey, fitbitSteps);
}
void Update()
{
updateTimeRemaining ();
@ -236,9 +249,10 @@ namespace PedometerU.Tests
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
}
//userSteps = (int)(Time.time*10.0f);
//barDisplay = Time.time*0.05f;
userSteps = PlayerPrefs.GetInt(currentStepsKey);
barDisplay = (float)userSteps/(float)stepsGoal;
if(barDisplay > 1.0f)
barDisplay = 1.0f;
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
//check if the current date matches the goal date
@ -249,6 +263,7 @@ namespace PedometerU.Tests
Debug.Log(prefKey + "...DAY HAS PASSED!! SETTING GOAL TO NEXT DAY!!");
PlayerPrefs.SetString("goalDate",
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
PlayerPrefs.SetInt("goalComplete", 0);
goalDayStr = PlayerPrefs.GetString("goalDate");
Debug.Log("new goal: " + goalDayStr);
@ -258,6 +273,8 @@ namespace PedometerU.Tests
}
//goal complete
else if(barDisplay >= 1.0f)
{
if(PlayerPrefs.GetInt("goalComplete") == 0)
{
Debug.Log(prefKey + "... Goal complete! +100pts!");
userSteps = 0;
@ -277,6 +294,8 @@ namespace PedometerU.Tests
invList.Append(PlayerPrefs.GetString ("inventory"));
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
PlayerPrefs.SetString ("inventory", invList.ToString());
PlayerPrefs.SetInt("goalComplete", 1);
}
}
}
}