Merge branch 'andrew' into darrel
This commit is contained in:
commit
b5c291ac44
2 changed files with 38 additions and 26 deletions
Binary file not shown.
|
@ -60,14 +60,17 @@ namespace PedometerU.Tests
|
|||
private int savedSteps;
|
||||
private int savedPoints;
|
||||
|
||||
public string currentStepsKey;
|
||||
public string totalPointsKey;
|
||||
|
||||
void OnStep (int steps, double distance) {
|
||||
//userDistance = (distance * 3.28084);
|
||||
userSteps = steps + savedSteps;
|
||||
PlayerPrefs.SetInt("currentSteps",userSteps);
|
||||
PlayerPrefs.SetInt(currentStepsKey,userSteps);
|
||||
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
|
||||
userPoints = steps*5 + savedPoints;
|
||||
PlayerPrefs.SetInt("totalPoints",userPoints);
|
||||
PlayerPrefs.SetInt(totalPointsKey,userPoints);
|
||||
pointsText.text = "Points: " + userPoints.ToString ();
|
||||
}
|
||||
|
||||
|
@ -82,30 +85,38 @@ namespace PedometerU.Tests
|
|||
|
||||
void Start ()
|
||||
{
|
||||
//PlayerPrefs.DeleteAll(); //danger!!
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
// This should later only get called per goal
|
||||
StartCoroutine(updateRival());
|
||||
currentStepsKey = "currentSteps";
|
||||
totalPointsKey = "totalPoints";
|
||||
}
|
||||
else
|
||||
{
|
||||
currentStepsKey = "currentSteps_p";
|
||||
totalPointsKey = "totalPoints_p";
|
||||
}
|
||||
|
||||
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
||||
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
||||
savedSteps = PlayerPrefs.GetInt(currentStepsKey);
|
||||
savedPoints = PlayerPrefs.GetInt(totalPointsKey);
|
||||
// Create a new pedometer
|
||||
pedometer = new Pedometer(OnStep);
|
||||
// Reset UI
|
||||
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
|
||||
if(prefKey == "daily")
|
||||
if(PlayerPrefs.HasKey("totalPoints"))
|
||||
{
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetInt("totalPoints", 0);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
}
|
||||
if(PlayerPrefs.HasKey(totalPointsKey))
|
||||
{
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetInt(totalPointsKey, 0);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt(totalPointsKey).ToString ();
|
||||
}
|
||||
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
if(PlayerPrefs.HasKey("goalDate"))
|
||||
{
|
||||
|
@ -123,9 +134,9 @@ namespace PedometerU.Tests
|
|||
userPoints = savedPoints;
|
||||
|
||||
//OnStep(savedSteps, 0); //necessary?
|
||||
Debug.Log(savedSteps);
|
||||
//Debug.Log(savedSteps);
|
||||
|
||||
Debug.Log(pbbg.rectTransform.anchoredPosition.x.ToString() + " " + pbbg.rectTransform.anchoredPosition.y.ToString());
|
||||
//Debug.Log(pbbg.rectTransform.anchoredPosition.x.ToString() + " " + pbbg.rectTransform.anchoredPosition.y.ToString());
|
||||
|
||||
//barPos = new Vector2(pbbg.transform.position.x, 1895 - pbbg.transform.position.y);
|
||||
|
||||
|
@ -216,8 +227,7 @@ namespace PedometerU.Tests
|
|||
{
|
||||
updateTimeRemaining ();
|
||||
updateProgressBar ();
|
||||
|
||||
updateMyGoalProgressBar ();
|
||||
//updateMyGoalProgressBar ();
|
||||
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
|
@ -226,9 +236,10 @@ namespace PedometerU.Tests
|
|||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
}
|
||||
|
||||
//userSteps = (int)(Time.time);
|
||||
//userSteps = (int)(Time.time*10.0f);
|
||||
//barDisplay = Time.time*0.05f;
|
||||
barDisplay = (float)userSteps/(float)stepsGoal;
|
||||
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
|
||||
//check if the current date matches the goal date
|
||||
if(prefKey == "daily" && currentDayStr == goalDayStr)
|
||||
|
@ -243,24 +254,25 @@ namespace PedometerU.Tests
|
|||
|
||||
//reset steps...
|
||||
userSteps = 0;
|
||||
PlayerPrefs.SetInt("currentSteps", userSteps);
|
||||
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
||||
}
|
||||
//goal complete
|
||||
if(barDisplay >= 1.0f)
|
||||
else if(barDisplay >= 1.0f)
|
||||
{
|
||||
Debug.Log("Goal complete! +100pts!");
|
||||
Debug.Log(prefKey + "... Goal complete! +100pts!");
|
||||
userSteps = 0;
|
||||
PlayerPrefs.SetInt("currentSteps", userSteps);
|
||||
PlayerPrefs.SetInt(currentStepsKey, userSteps);
|
||||
savedSteps = 0;
|
||||
//OnStep(0,0);
|
||||
stepText.text = userSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
|
||||
//destroy the goal and set a new one?
|
||||
savedPoints += stepsGoal*10;
|
||||
PlayerPrefs.SetInt("totalPoints", savedPoints);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
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(" ");
|
||||
|
|
Reference in a new issue