fixed daily goal, added personal progress bar
This commit is contained in:
parent
736e9c3376
commit
83fbdcd8ed
3 changed files with 42 additions and 39 deletions
Binary file not shown.
|
@ -33,8 +33,8 @@ namespace PedometerU.Tests
|
||||||
public Text remainingText;
|
public Text remainingText;
|
||||||
|
|
||||||
// Goal information.
|
// Goal information.
|
||||||
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
private string currentDayStr;
|
||||||
public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
private string goalDayStr;
|
||||||
public string prefKey;
|
public string prefKey;
|
||||||
|
|
||||||
// Used for time calculation.
|
// Used for time calculation.
|
||||||
|
@ -43,7 +43,7 @@ namespace PedometerU.Tests
|
||||||
private const int secondsperday = 86400;
|
private const int secondsperday = 86400;
|
||||||
|
|
||||||
//Progress Bar...
|
//Progress Bar...
|
||||||
public float barDisplay; //current progress
|
private float barDisplay; //current progress
|
||||||
//private Vector2 barPos;
|
//private Vector2 barPos;
|
||||||
// This gets overwritten later by the background's size values.
|
// This gets overwritten later by the background's size values.
|
||||||
private Vector2 barSize = new Vector2(5000, 10);
|
private Vector2 barSize = new Vector2(5000, 10);
|
||||||
|
@ -52,7 +52,7 @@ namespace PedometerU.Tests
|
||||||
private Pedometer pedometer;
|
private Pedometer pedometer;
|
||||||
int userSteps;
|
int userSteps;
|
||||||
int userPoints;
|
int userPoints;
|
||||||
int stepsGoal = 100;
|
public int stepsGoal;
|
||||||
private int savedSteps;
|
private int savedSteps;
|
||||||
private int savedPoints;
|
private int savedPoints;
|
||||||
|
|
||||||
|
@ -78,8 +78,11 @@ namespace PedometerU.Tests
|
||||||
|
|
||||||
void Start ()
|
void Start ()
|
||||||
{
|
{
|
||||||
// This should later only get called per goal
|
if(prefKey == "daily")
|
||||||
StartCoroutine(updateRival());
|
{
|
||||||
|
// This should later only get called per goal
|
||||||
|
StartCoroutine(updateRival());
|
||||||
|
}
|
||||||
|
|
||||||
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
||||||
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
||||||
|
@ -97,15 +100,18 @@ namespace PedometerU.Tests
|
||||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PlayerPrefs.HasKey("goalDate"))
|
if(prefKey == "daily")
|
||||||
{
|
{
|
||||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
if(PlayerPrefs.HasKey("goalDate"))
|
||||||
}
|
{
|
||||||
else
|
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||||
{
|
}
|
||||||
PlayerPrefs.SetString("goalDate",
|
else
|
||||||
System.DateTime.Now.AddMinutes(1).ToString("MM/dd/yyyy"));
|
{
|
||||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
PlayerPrefs.SetString("goalDate",
|
||||||
|
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
||||||
|
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
userSteps = savedSteps;
|
userSteps = savedSteps;
|
||||||
userPoints = savedPoints;
|
userPoints = savedPoints;
|
||||||
|
@ -121,7 +127,6 @@ namespace PedometerU.Tests
|
||||||
//barPos = new Vector2(pbbg.transform.position.x, 1895 - pbbg.transform.position.y);
|
//barPos = new Vector2(pbbg.transform.position.x, 1895 - pbbg.transform.position.y);
|
||||||
|
|
||||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Was used for testing.
|
// Was used for testing.
|
||||||
|
@ -193,27 +198,31 @@ namespace PedometerU.Tests
|
||||||
{
|
{
|
||||||
updateTimeRemaining ();
|
updateTimeRemaining ();
|
||||||
updateProgressBar ();
|
updateProgressBar ();
|
||||||
updateMonsterProgressBar ();
|
if(prefKey == "daily")
|
||||||
|
{
|
||||||
|
updateMonsterProgressBar ();
|
||||||
|
remainingText.text = formatTimeRemaining ();
|
||||||
|
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
|
}
|
||||||
|
|
||||||
//needs current points counting toward this goal (daily?)
|
userSteps = (int)(Time.time*10.0f);
|
||||||
//needs the total required points for this goal
|
//barDisplay = Time.time*0.05f;
|
||||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
|
||||||
|
|
||||||
remainingText.text = formatTimeRemaining ();
|
|
||||||
|
|
||||||
//barDisplay = Time.time*0.05f; //put actual progress here (current/total)
|
|
||||||
barDisplay = (float)userSteps/(float)stepsGoal;
|
barDisplay = (float)userSteps/(float)stepsGoal;
|
||||||
|
|
||||||
//check if the current date matches the goal date
|
//check if the current date matches the goal date
|
||||||
if(currentDayStr == goalDayStr)
|
if(prefKey == "daily" && currentDayStr == goalDayStr)
|
||||||
{
|
{
|
||||||
Debug.Log("current: " + currentDayStr);
|
Debug.Log("current: " + currentDayStr);
|
||||||
Debug.Log("goal: " + goalDayStr);
|
Debug.Log("goal: " + goalDayStr);
|
||||||
Debug.Log("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.AddMinutes(1).ToString("MM/dd/yyyy"));
|
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
||||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||||
Debug.Log("new goal: " + goalDayStr);
|
Debug.Log("new goal: " + goalDayStr);
|
||||||
|
|
||||||
|
//reset steps...
|
||||||
|
userSteps = 0;
|
||||||
|
PlayerPrefs.SetInt("currentSteps", userSteps);
|
||||||
}
|
}
|
||||||
//goal complete
|
//goal complete
|
||||||
if(barDisplay >= 1.0f)
|
if(barDisplay >= 1.0f)
|
||||||
|
@ -230,18 +239,12 @@ namespace PedometerU.Tests
|
||||||
PlayerPrefs.SetInt("totalPoints", savedPoints);
|
PlayerPrefs.SetInt("totalPoints", savedPoints);
|
||||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||||
|
|
||||||
//Random item
|
//Random item
|
||||||
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());
|
||||||
}
|
|
||||||
|
|
||||||
//only applies if "daily" goal
|
|
||||||
if(prefKey == "daily")
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
m_EditorVersion: 2017.3.1f1
|
m_EditorVersion: 2017.4.0f1
|
||||||
|
|
Reference in a new issue