Piped pedometer steps into goals

This commit is contained in:
Darrel Marek 2018-04-26 00:18:01 -05:00
parent 00e3956098
commit 1d11f0c3dd
3 changed files with 30 additions and 16 deletions

Binary file not shown.

View file

@ -6,7 +6,8 @@ using UnityEngine;
using UnityEngine.UI;
//Pretty much a copy of GetData...
namespace PedometerU.Tests {
public class GetGoals : MonoBehaviour {
public Text goalText;
@ -20,24 +21,36 @@ public class GetGoals : MonoBehaviour {
//Progress Bar...
public float barDisplay; //current progress
public Vector2 barPos;
private Vector2 barPos;
Vector2 barSize = new Vector2(227,20);
//Pedometer
private Pedometer pedometer;
int userSteps;
double userDistance;
int totalSteps = 30;
void OnStep (int steps, double distance) {
userSteps = steps;
userDistance = (distance * 3.28084);
}
private void OnDisable () {
// Release the pedometer
pedometer.Dispose();
pedometer = null;
}
void Start () {
// Create a new pedometer
pedometer = new Pedometer(OnStep);
// Reset UI
OnStep(0, 0);
//goalText.text = prefKey;
goalText.color = new Color(0f, 0f, 0f);
goalText.transform.position = new Vector2(barPos.x + 45.0f,barPos.y + 55.0f);
//barPos.x = goalText.transform.position.x;
//barPos.y = goalText.transform.position.y + 10.0f;
//Debug.Log(barPos.x + " " + barPos.y);
//barPos.x = 0;
//barPos.y = 0;
barPos = new Vector2(goalText.transform.position.x - 105, goalText.transform.position.y - 30);
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
@ -87,8 +100,8 @@ public class GetGoals : MonoBehaviour {
//needs current points counting toward this goal (daily?)
//needs the total required points for this goal
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 = userSteps/totalSteps;
//failed to complete goal
if(currentDayStr != goalDayStr)
{
@ -122,3 +135,4 @@ public class GetGoals : MonoBehaviour {
}
}
}
}

View file

@ -1 +1 @@
m_EditorVersion: 2017.4.0f1
m_EditorVersion: 2017.3.1f1