extra fixes to pedometer/fitbit behavior
This commit is contained in:
parent
030c4b922d
commit
dff6f9036b
3 changed files with 37 additions and 18 deletions
Binary file not shown.
Binary file not shown.
|
@ -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);
|
||||
|
||||
|
@ -259,24 +274,28 @@ namespace PedometerU.Tests
|
|||
//goal complete
|
||||
else if(barDisplay >= 1.0f)
|
||||
{
|
||||
Debug.Log(prefKey + "... Goal complete! +100pts!");
|
||||
userSteps = 0;
|
||||
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
||||
savedSteps = 0;
|
||||
//OnStep(0,0);
|
||||
if(PlayerPrefs.GetInt("goalComplete") == 0)
|
||||
{
|
||||
Debug.Log(prefKey + "... Goal complete! +100pts!");
|
||||
userSteps = 0;
|
||||
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
||||
savedSteps = 0;
|
||||
//OnStep(0,0);
|
||||
|
||||
//destroy the goal and set a new one?
|
||||
savedPoints += stepsGoal*10;
|
||||
PlayerPrefs.SetInt(totalPointsKey, savedPoints);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
||||
//destroy the goal and set a new one?
|
||||
savedPoints += stepsGoal*10;
|
||||
PlayerPrefs.SetInt(totalPointsKey, savedPoints);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
||||
|
||||
//Random item
|
||||
if(!PlayerPrefs.HasKey("inventory"))
|
||||
PlayerPrefs.SetString("inventory", "");
|
||||
StringBuilder invList = new StringBuilder ();
|
||||
invList.Append(PlayerPrefs.GetString ("inventory"));
|
||||
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
|
||||
PlayerPrefs.SetString ("inventory", invList.ToString());
|
||||
//Random item
|
||||
if(!PlayerPrefs.HasKey("inventory"))
|
||||
PlayerPrefs.SetString("inventory", "");
|
||||
StringBuilder invList = new StringBuilder ();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue