From 499a0aedfdbf2a99722e7b2fb11746e112a3f6d4 Mon Sep 17 00:00:00 2001 From: asleal2 Date: Mon, 30 Apr 2018 21:30:05 -0500 Subject: [PATCH] added new progress bar, should all work... --- MoCha/Assets/Scenes/Goals.unity | Bin 48672 -> 50248 bytes MoCha/Assets/Scripts/GetGoals.cs | 56 +++++++++++++++++++------------ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/MoCha/Assets/Scenes/Goals.unity b/MoCha/Assets/Scenes/Goals.unity index 2516d160cd8acf20f7b56ea633e9c690d73a78da..4f0e9c5c65b92ab0c7f2e15342b8a1c571dbcf01 100644 GIT binary patch delta 2048 zcmYk7YfO_@7{{Nt6s_D=C`fS*%8<)8HcKqXMFizy0|PP0f|4bGV@SfKN=X2fRY(*_Uq<9ok>;G|0I??z4t-pra=1cm9B+q%m&r8{re1} zrFL1V5{0i44u-j$L9mh22k3fD=T5#+su@iY92#G|@o@oH6+=*o{%N`$RGS-e>lm95Zy zBJUJbMzm5i{_zI9`cw3I^=@9Rl!;dCQ_gEs_JmZr@}^Yo4Jj)^%1Tz^4dzSog|9x| z)ahz(@1&kiF;U;1dSu}E@s3`1qr1b^U)wQ6?ml;0cSB!SubYSJSLJ^G!3)Bak(L$cM-${!X$0*gF_MhxWZ>IToU3jFCE8kjx9_!gvGPZOI;qwh>Ed zLt{x-&R{kVb{dg)w@Bs`*Woak6!u1-BspW+Ow@=m0&SM8 z6@wLwqtM=a=*UE%a-n!Er8km^K9)1%a;6mrFe^kTJ~}6vD}{)witFRh(=#t4(4;s3 z2kRE1uQ6ip7CEy7rm3$z{`VDD6JBxvfp0M@*`W9c4*spWdQQ&Ff=xonuAb^?I|4ah zAR0ns2d`v7@fREh@pjsYN9Bw^O?U07Nh`-9ng!DwdL^@qJzh&`(55@MJ<;X77u0XcYaIG zOoC|+9g*h&=Zm!-A?2{p+!S? za=;T_96+wM+kIiKY{eV}!L+}CFC}Zp(+$6pY!xh58s3o1xXpE#%Cn6 z?hN}C^TuNm&I0DhoA@PLD%1^s8Sfs39HoY*H>y`g{RUC)GpSj=kqu&H&Vqqa{OH># z&R;O8ch06p1H>5l;l;|uL?b_#cye*8^0$Z|%NEOile+6tt|kXY7g}&HH!(Y%!>0%tsXu=f6R8-~2Xm?-Rwhlw>y5Oev#C}T zd@8Qux}kl2ZQV9k=!5aVeu~YcX9Aa zf|)n*mhpEzd|})mE3C-#*@XS9N&WEinMlPVPT$H9u~WpxlW zM-$z55m5s6u3pENqQuWfo_wgS9)zG42`MoVb!Sz!Zf}R zbmrKcL;+BID)mdG9IOidM68Fx2En$%hYj ztg7b}=1C;-!$*jw3ajNj&6zWb$VSjg+O@kz}Y z%tZqZ3sD>*?Go`%C-T6zV{QK3vH*r^!Rla@LYc5JupaoT(iUOeGt9F$zW-T>5DkLW zz^b!7!iq3m)Qul6+$%7^OPZWHS_)AYQk875@QN3Pl4qIaHDO&~M)@XTMcf31K$_Xa z{i#Cu|hVn9Q&+ZHYOV z5n&y{rDoygx4){CU@aS3b1=1KJWFDF6Tf diff --git a/MoCha/Assets/Scripts/GetGoals.cs b/MoCha/Assets/Scripts/GetGoals.cs index cb5c15e..0958508 100644 --- a/MoCha/Assets/Scripts/GetGoals.cs +++ b/MoCha/Assets/Scripts/GetGoals.cs @@ -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")) { @@ -217,7 +228,7 @@ namespace PedometerU.Tests updateTimeRemaining (); updateProgressBar (); - updateMyGoalProgressBar (); + //updateMyGoalProgressBar (); if(prefKey == "daily") { @@ -226,9 +237,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,23 +255,25 @@ namespace PedometerU.Tests //reset steps... userSteps = 0; - PlayerPrefs.SetInt("currentSteps", userSteps); + PlayerPrefs.SetInt(currentStepsKey, userSteps); } //goal complete 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 (); + if(!PlayerPrefs.HasKey("inventory")) + PlayerPrefs.SetString("inventory", ""); //Random item StringBuilder invList = new StringBuilder (); invList.Append(PlayerPrefs.GetString ("inventory"));