diff --git a/MoCha/Assets/Scenes/Goals.unity b/MoCha/Assets/Scenes/Goals.unity index 6820354..2516d16 100644 Binary files a/MoCha/Assets/Scenes/Goals.unity and b/MoCha/Assets/Scenes/Goals.unity differ diff --git a/MoCha/Assets/Scripts/GetGoals.cs b/MoCha/Assets/Scripts/GetGoals.cs index 580c9eb..4b26139 100644 --- a/MoCha/Assets/Scripts/GetGoals.cs +++ b/MoCha/Assets/Scripts/GetGoals.cs @@ -33,8 +33,8 @@ namespace PedometerU.Tests public Text remainingText; // Goal information. - public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); - public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); + private string currentDayStr; + private string goalDayStr; public string prefKey; // Used for time calculation. @@ -43,7 +43,7 @@ namespace PedometerU.Tests private const int secondsperday = 86400; //Progress Bar... - public float barDisplay; //current progress + private float barDisplay; //current progress //private Vector2 barPos; // This gets overwritten later by the background's size values. private Vector2 barSize = new Vector2(5000, 10); @@ -52,7 +52,7 @@ namespace PedometerU.Tests private Pedometer pedometer; int userSteps; int userPoints; - int stepsGoal = 100; + public int stepsGoal; private int savedSteps; private int savedPoints; @@ -78,8 +78,11 @@ namespace PedometerU.Tests void Start () { - // This should later only get called per goal - StartCoroutine(updateRival()); + if(prefKey == "daily") + { + // This should later only get called per goal + StartCoroutine(updateRival()); + } savedSteps = PlayerPrefs.GetInt("currentSteps"); savedPoints = PlayerPrefs.GetInt("totalPoints"); @@ -97,15 +100,18 @@ namespace PedometerU.Tests pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString (); } - if(PlayerPrefs.HasKey("goalDate")) - { - goalDayStr = PlayerPrefs.GetString("goalDate"); - } - else - { - PlayerPrefs.SetString("goalDate", - System.DateTime.Now.AddMinutes(1).ToString("MM/dd/yyyy")); - goalDayStr = PlayerPrefs.GetString("goalDate"); + if(prefKey == "daily") + { + if(PlayerPrefs.HasKey("goalDate")) + { + goalDayStr = PlayerPrefs.GetString("goalDate"); + } + else + { + PlayerPrefs.SetString("goalDate", + System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy")); + goalDayStr = PlayerPrefs.GetString("goalDate"); + } } userSteps = savedSteps; userPoints = savedPoints; @@ -121,7 +127,6 @@ namespace PedometerU.Tests //barPos = new Vector2(pbbg.transform.position.x, 1895 - pbbg.transform.position.y); currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); - goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); } // Was used for testing. @@ -193,27 +198,31 @@ namespace PedometerU.Tests { updateTimeRemaining (); 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?) - //needs the total required points for this goal - currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy"); - - remainingText.text = formatTimeRemaining (); - - //barDisplay = Time.time*0.05f; //put actual progress here (current/total) + userSteps = (int)(Time.time*10.0f); + //barDisplay = Time.time*0.05f; barDisplay = (float)userSteps/(float)stepsGoal; //check if the current date matches the goal date - if(currentDayStr == goalDayStr) + if(prefKey == "daily" && currentDayStr == goalDayStr) { Debug.Log("current: " + currentDayStr); 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", - System.DateTime.Now.AddMinutes(1).ToString("MM/dd/yyyy")); + System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy")); goalDayStr = PlayerPrefs.GetString("goalDate"); Debug.Log("new goal: " + goalDayStr); + + //reset steps... + userSteps = 0; + PlayerPrefs.SetInt("currentSteps", userSteps); } //goal complete if(barDisplay >= 1.0f) @@ -230,18 +239,12 @@ namespace PedometerU.Tests PlayerPrefs.SetInt("totalPoints", savedPoints); pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString (); - //Random item - 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()); - } - - //only applies if "daily" goal - if(prefKey == "daily") - { + //Random item + 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()); } } } - } diff --git a/MoCha/ProjectSettings/ProjectVersion.txt b/MoCha/ProjectSettings/ProjectVersion.txt index 27997c5..ac7d214 100644 --- a/MoCha/ProjectSettings/ProjectVersion.txt +++ b/MoCha/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.3.1f1 +m_EditorVersion: 2017.4.0f1