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 ()
|
void Start ()
|
||||||
{
|
{
|
||||||
|
//PlayerPrefs.SetInt("currentGoals", 0);
|
||||||
//PlayerPrefs.DeleteAll(); //danger!!
|
//PlayerPrefs.DeleteAll(); //danger!!
|
||||||
if(prefKey == "daily")
|
if(prefKey == "daily")
|
||||||
{
|
{
|
||||||
|
@ -106,6 +107,12 @@ namespace PedometerU.Tests
|
||||||
// Reset UI
|
// Reset UI
|
||||||
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
|
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
|
||||||
|
|
||||||
|
if(!PlayerPrefs.HasKey("goalComplete"))
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetInt("goalComplete", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(PlayerPrefs.HasKey(totalPointsKey))
|
if(PlayerPrefs.HasKey(totalPointsKey))
|
||||||
{
|
{
|
||||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
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;
|
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()
|
void Update()
|
||||||
{
|
{
|
||||||
updateTimeRemaining ();
|
updateTimeRemaining ();
|
||||||
|
@ -236,9 +249,10 @@ namespace PedometerU.Tests
|
||||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
}
|
}
|
||||||
|
|
||||||
//userSteps = (int)(Time.time*10.0f);
|
userSteps = PlayerPrefs.GetInt(currentStepsKey);
|
||||||
//barDisplay = Time.time*0.05f;
|
|
||||||
barDisplay = (float)userSteps/(float)stepsGoal;
|
barDisplay = (float)userSteps/(float)stepsGoal;
|
||||||
|
if(barDisplay > 1.0f)
|
||||||
|
barDisplay = 1.0f;
|
||||||
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
|
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
|
||||||
|
|
||||||
//check if the current date matches the goal date
|
//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!!");
|
Debug.Log(prefKey + "...DAY HAS PASSED!! SETTING GOAL TO NEXT DAY!!");
|
||||||
PlayerPrefs.SetString("goalDate",
|
PlayerPrefs.SetString("goalDate",
|
||||||
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
||||||
|
PlayerPrefs.SetInt("goalComplete", 0);
|
||||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||||
Debug.Log("new goal: " + goalDayStr);
|
Debug.Log("new goal: " + goalDayStr);
|
||||||
|
|
||||||
|
@ -259,24 +274,28 @@ namespace PedometerU.Tests
|
||||||
//goal complete
|
//goal complete
|
||||||
else if(barDisplay >= 1.0f)
|
else if(barDisplay >= 1.0f)
|
||||||
{
|
{
|
||||||
Debug.Log(prefKey + "... Goal complete! +100pts!");
|
if(PlayerPrefs.GetInt("goalComplete") == 0)
|
||||||
userSteps = 0;
|
{
|
||||||
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
Debug.Log(prefKey + "... Goal complete! +100pts!");
|
||||||
savedSteps = 0;
|
userSteps = 0;
|
||||||
//OnStep(0,0);
|
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
||||||
|
savedSteps = 0;
|
||||||
|
//OnStep(0,0);
|
||||||
|
|
||||||
//destroy the goal and set a new one?
|
//destroy the goal and set a new one?
|
||||||
savedPoints += stepsGoal*10;
|
savedPoints += stepsGoal*10;
|
||||||
PlayerPrefs.SetInt(totalPointsKey, savedPoints);
|
PlayerPrefs.SetInt(totalPointsKey, savedPoints);
|
||||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
||||||
|
|
||||||
//Random item
|
//Random item
|
||||||
if(!PlayerPrefs.HasKey("inventory"))
|
if(!PlayerPrefs.HasKey("inventory"))
|
||||||
PlayerPrefs.SetString("inventory", "");
|
PlayerPrefs.SetString("inventory", "");
|
||||||
StringBuilder invList = new StringBuilder ();
|
StringBuilder invList = new StringBuilder ();
|
||||||
invList.Append(PlayerPrefs.GetString ("inventory"));
|
invList.Append(PlayerPrefs.GetString ("inventory"));
|
||||||
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
|
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
|
||||||
PlayerPrefs.SetString ("inventory", invList.ToString());
|
PlayerPrefs.SetString ("inventory", invList.ToString());
|
||||||
|
PlayerPrefs.SetInt("goalComplete", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue