Added progress bars, working on integrating the actual fitbit data and goal system

This commit is contained in:
asleal2 2018-04-25 13:47:56 -05:00
parent 843ca90028
commit 5cf0257e18
6 changed files with 97 additions and 19 deletions

Binary file not shown.

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 76a3a676c97c14505abe10fa7fa30134
timeCreated: 1524600874
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,84 @@
using System;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//Pretty much a copy of GetData...
public class GetGoals : MonoBehaviour {
public Text objectText;
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy/mm");
public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy/mm");
public string prefKey;
void Start () {
objectText = GetComponent<Text> ();
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
}
//Progress Bar...
public float barDisplay; //current progress
public Vector2 barPos = new Vector2(20,190);
public Vector2 barSize = new Vector2(60,20);
public Texture2D emptyTex;
public Texture2D fullTex;
//on a button press? begin a goal?
void startGoal()
{
}
void savePersistantGoalDate(string key)
{
PlayerPrefs.SetString(key, goalDayStr);
}
bool checkNewDay(string key)
{
string checkDay = PlayerPrefs.GetString(key);
if(checkDay == currentDayStr)
return false;
return true;
}
void OnGUI() {
//draw the background:
GUI.BeginGroup(new Rect(barPos.x, barPos.y, barSize.x, barSize.y));
GUI.Box(new Rect(0,0, barSize.x, barSize.y), emptyTex);
//draw the filled-in part:
GUI.BeginGroup(new Rect(0,0, barSize.x * barDisplay, barSize.y));
GUI.Box(new Rect(0,0, barSize.x, barSize.y), fullTex);
GUI.EndGroup();
GUI.EndGroup();
}
void Update() {
//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)
if(currentDayStr != goalDayStr)
{
//check if goal is complete or not, the day is over
barDisplay = 1.0f;
Debug.Log("DAY HAS PASSED!!");
}
if(checkNewDay("daily"))
{
Debug.Log("You failed your goal"); //not true if progress is actually complete!
goalDayStr = currentDayStr;
savePersistantGoalDate("daily");
}
}
}

View file

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 5f138b644c262457385474b2256308a7
timeCreated: 1524165858
guid: 040f99a891f1b4fed92f5a44e33fc47f
timeCreated: 1524166714
licenseType: Free
MonoImporter:
externalObjects: {}

View file

@ -1,16 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goals : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View file

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