diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAchievements.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAchievements.cs
index ace5cba..91dea24 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAchievements.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAchievements.cs
@@ -1,7 +1,7 @@
-using System;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using UnityEngine;
namespace Fizzyo
@@ -12,7 +12,6 @@ namespace Fizzyo
public class AllHighscoreData
{
public HighscoreData[] highscores;
-
}
// Serializable which holds individual high score data
@@ -31,7 +30,6 @@ public class AllAchievementData
{
public AchievementData[] achievements;
public AchievementData[] unlockedAchievements;
-
}
// Serializable that is used to pull and hold the data of each Achievement in the Achievements.json file
@@ -63,7 +61,6 @@ public class CalibrationData
///
/// Used to unlock Fizzyo achievements and post high scores in the Fizzyo rest API
///
-
public class FizzyoAchievements
{
///
@@ -80,10 +77,8 @@ public class FizzyoAchievements
///
public HighscoreData[] highscores;
-
-
///
- /// Loads all game achievements and the users unlocked achievements and achievement progres.
+ /// Loads all game achievements and the users unlocked achievements and achievement progress.
///
///
/// A JSON formatted string containing the list of achievements
@@ -121,7 +116,6 @@ public FizzyoRequestReturnType LoadAchievements()
return FizzyoRequestReturnType.SUCCESS;
-
}
internal void Load()
@@ -129,9 +123,8 @@ internal void Load()
LoadAchievements();
}
-
///
- /// Loads in the top 20 highscores for the current game.
+ /// Loads in the top 20 high-scores for the current game.
///
///
/// A JSON formatted string containing tag and score for the top 20 scores of the game
@@ -157,9 +150,6 @@ public FizzyoRequestReturnType GetHighscores()
return FizzyoRequestReturnType.SUCCESS;
}
-
-
-
///
/// Uploads a players Score
///
@@ -200,7 +190,6 @@ public FizzyoRequestReturnType PostScore(int score)
/// FizzyoRequestReturnType.SUCCESS is upload is successful.
/// FizzyoRequestReturnType.FAILED_TO_CONNECT if connection failed.
///
- ///
public FizzyoRequestReturnType UnlockAchievement(string achievementId)
{
string unlockAchievement = "https://api.fizzyo-ucl.co.uk/api/v1/games/" + FizzyoFramework.Instance.gameID + "/achievements/" + achievementId + "/unlock" ;
@@ -221,8 +210,8 @@ public FizzyoRequestReturnType UnlockAchievement(string achievementId)
if (sendPostUnlock.error != null)
{
return FizzyoRequestReturnType.FAILED_TO_CONNECT;
- //TODO add upload que here
}
+
return FizzyoRequestReturnType.SUCCESS;
}
@@ -239,15 +228,12 @@ private FizzyoRequestReturnType PostAchievements()
if (achievementsToUpload != "")
{
-
string[] achievementsToUploadArray = achievementsToUpload.Split(',');
for (int i = 0; i < achievementsToUploadArray.Length; i++)
{
-
if (achievementsToUploadArray[i] != "")
{
-
string postUnlock;
postUnlock = "https://api.fizzyo-ucl.co.uk/api/v1/game/" + FizzyoFramework.Instance.gameID + "/achievements/" + achievementsToUploadArray[i] + "/unlock";
@@ -270,11 +256,8 @@ private FizzyoRequestReturnType PostAchievements()
{
return FizzyoRequestReturnType.FAILED_TO_CONNECT;
}
-
}
-
}
-
}
string achievementsToProgress = PlayerPrefs.GetString("achievementsToProgress");
@@ -287,18 +270,14 @@ private FizzyoRequestReturnType PostAchievements()
// Add achievement progress to player preferences
for (int i = 0; i < achievementsToProgressArray.Length; i++)
{
-
if (achievementsToProgressArray[i] != "")
{
-
for (int j = 0; j < allUserProgress.achievements.Length; j++)
{
-
if (allUserProgress.achievements[j].id == achievementsToProgressArray[i])
{
for (int k = 0; k < allAchievements.achievements.Length; k++)
{
-
if (allUserProgress.achievements[j].id == allAchievements.achievements[k].id)
{
allUserProgress.achievements[j].unlockProgress = allAchievements.achievements[k].unlockProgress;
@@ -306,21 +285,14 @@ private FizzyoRequestReturnType PostAchievements()
PlayerPrefs.SetString(FizzyoFramework.Instance.User.UserID + "AchievementProgress", newAllData);
break;
}
-
}
break;
}
-
}
-
}
-
}
return FizzyoRequestReturnType.SUCCESS;
}
-
}
-
-}
-
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAnalytics.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAnalytics.cs
index ce1ff03..dc772e3 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAnalytics.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoAnalytics.cs
@@ -1,7 +1,8 @@
-using System;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using UnityEngine;
namespace Fizzyo
@@ -20,7 +21,6 @@ namespace Fizzyo
///
public class FizzyoAnalytics
{
-
// Various session parameters
public int breathCount;
public int goodBreathCount;
@@ -32,18 +32,22 @@ public class FizzyoAnalytics
///
/// Add this to your game to update the score to send in the session.
///
- public int Score {
- get { return _score; }
- set {
- if(value >= _score ){
- _score = value;
- }
- }
+ public int Score
+ {
+ get { return _score; }
+ set
+ {
+ if (value >= _score)
+ {
+ _score = value;
+ }
+ }
}
private int _setCount;
+
///
- /// Add this to your game to update the breathing setcount to send in the session.
+ /// Add this to your game to update the breathing set-count to send in the session.
///
public int SetCount { get { return _setCount; } set { _setCount = value; } }
@@ -56,29 +60,29 @@ public int Score {
///
/// Integer holding the amount of breaths that are to be completed in each set
///
-
private void Start()
{
- //Set start time
- ///
- System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
- startTime = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
+ //Set start time
+ ///
+ System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
+ startTime = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
}
+
private void OnApplicationFocus(bool focus)
{
if (focus)
{
-
+
}
else
{
-
+
}
}
-
- ///
- ///Add this to the logic which manages quitting the application to Create and Post sessions.
- ///
+
+ ///
+ ///Add this to the logic which manages quitting the application to Create and Post sessions.
+ ///
public void PostOnQuit()
{
Debug.Log("[FizzyoAnalytics] About to quit: creating session to upload.");
@@ -90,8 +94,7 @@ public void PostOnQuit()
///
///Sets all the fields of the session before upload.
- ///
-
+ ///
void CreateSession()
{
//All of the stats comes from the Breath Recognizer
@@ -100,27 +103,25 @@ void CreateSession()
badBreathCount = FizzyoFramework.Instance.Recogniser.BadBreaths;
endTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
Debug.Log("Good breath count = " + goodBreathCount);
- Debug.Log("Bearth count = " + breathCount);
+ Debug.Log("Breath count = " + breathCount);
Debug.Log("Bad breath count = " + badBreathCount);
Debug.Log("Highest score = " + _score);
Debug.Log("Time in Unix epoch: " + endTime);
-
}
- ///
- ///Once the game shuts down, information from the session is sent to the server.
- ///
- ///It will send:
- /// 1. Amount of sets in this session
- /// 2. Amounts of breaths in this session
- /// 3. Amount of good breaths in this session
- /// 4. Amount of bad breaths in this session
- /// 5. User-s highest score for this session
- /// 6. Start time of the session
- /// 7. End time of the session.
- /// Note: Time represented as Unix Epoch time.
- ///
-
+ ///
+ ///Once the game shuts down, information from the session is sent to the server.
+ ///
+ ///It will send:
+ /// 1. Amount of sets in this session
+ /// 2. Amounts of breaths in this session
+ /// 3. Amount of good breaths in this session
+ /// 4. Amount of bad breaths in this session
+ /// 5. User-s highest score for this session
+ /// 6. Start time of the session
+ /// 7. End time of the session.
+ /// Note: Time represented as Unix Epoch time.
+ ///
public FizzyoRequestReturnType PostAnalytics()
{
///https://api.fizzyo-ucl.co.uk/api/v1/games//sessions
@@ -140,27 +141,19 @@ public FizzyoRequestReturnType PostAnalytics()
headers["Authorization"] = "Bearer " + FizzyoFramework.Instance.User.AccessToken;
byte[] rawData = form.data;
-
+
WWW sendPostAnalytics = new WWW(postAnalytics, rawData, headers);
-
+
while (!sendPostAnalytics.isDone) { };
if (sendPostAnalytics.error != null)
{
Debug.Log("[FizzyoAnalytics] Posting analytics failed. ");
return FizzyoRequestReturnType.FAILED_TO_CONNECT;
-
+
}
Debug.Log("[FizzyoAnalytics] Posting analytics successful.");
return FizzyoRequestReturnType.SUCCESS;
}
-
-
-
-
- }
-
-
-
}
-
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoBreathRecognizer.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoBreathRecognizer.cs
index 325a938..ab5340f 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoBreathRecognizer.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoBreathRecognizer.cs
@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System;
namespace Fizzyo
{
-
///
/// Provides data about the current breath to the receiver when the ExhalationComplete event fires
///
@@ -17,8 +15,6 @@ public class ExhalationCompleteEventArgs : EventArgs
private bool isBreathFull = false;
private float breathPercentage = 0;
private int breathQuality = 0;
-
-
public ExhalationCompleteEventArgs(float breathLength, int breathCount, float exhaledVolume, bool isBreathFull, float breathPercentage, int breathQuality)
{
@@ -28,7 +24,6 @@ public ExhalationCompleteEventArgs(float breathLength, int breathCount, float ex
this.isBreathFull = isBreathFull;
this.breathPercentage = breathPercentage;
this.breathQuality = breathQuality;
-
}
///
@@ -139,20 +134,15 @@ public class BreathRecogniser
private const float kTollerance = 0.80f;
private float minBreathThreshold = .05f;
private float breathPercentage = 0;
-
public event ExhalationCompleteEventHandler BreathComplete;
public event ExhalationStartedEventHandler BreathStarted;
-
-
public BreathRecogniser()
{
}
-
-
/// The length of the current exhaled breath in seconds
public float BreathLength
{
@@ -367,7 +357,6 @@ protected virtual void OnExhalationComplete(object sender, ExhalationCompleteEve
}
}
-
///
/// Invoke the event - called whenever exhalation starts
///
@@ -378,7 +367,5 @@ protected virtual void OnExhalationStarted(object sender)
BreathStarted(this);
}
}
-
-
}
}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoCalibration.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoCalibration.cs
index 4d9e449..775d809 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoCalibration.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoCalibration.cs
@@ -1,11 +1,12 @@
-using System;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using UnityEngine;
+
namespace Fizzyo
{
-
///
/// An Instance of this class can be created to calibrate the game based on the users device input
///
@@ -14,24 +15,24 @@ public class Calibration : MonoBehaviour
// Time that current breath has been held for
private float breathLength;
- ///
- /// How many calibration steps have been completed
- ///
+ ///
+ /// How many calibration steps have been completed
+ ///
public int calibrationStep = 1;
- ///
- /// How many calibration steps are required
- ///
+ ///
+ /// How many calibration steps are required
+ ///
public int requiredSteps = 3;
- ///
- /// Status of calibration
- ///
+ ///
+ /// Status of calibration
+ ///
public string calibrationStatus;
- ///
- /// A color reflecting the status of calibration
- ///
+ ///
+ /// A color reflecting the status of calibration
+ ///
public Color calibrationColor;
// List that holds pressure readings from calibration
@@ -43,32 +44,24 @@ public class Calibration : MonoBehaviour
// List that holds pressure readings from calibration
private List avgLengths = new List();
- // Holds average pressure reading
- private float avgPressureReading;
-
- // Average time of each calibration step
- private float avgLength;
-
// Breath has to be above this to register
private float minPressureThreshold = 0.1f;
- ///
- /// Pressure used for calibration from device
- ///
+ ///
+ /// Pressure used for calibration from device
+ ///
public float pressure;
-
- ///
- /// If true calibration script is running
- ///
+ ///
+ /// If true calibration script is running
+ ///
public bool calibrating = false;
- ///
- /// If true calibration is finished
- ///
+ ///
+ /// If true calibration is finished
+ ///
public bool calibrationFinished = false;
-
///
/// Used to get input from the device to get a pressure and time value that can be used in the breath framework, according to the breathing capacity of the user.
///
@@ -80,7 +73,6 @@ public class Calibration : MonoBehaviour
///
public void Calibrate()
{
-
// Pressure comes from device
pressure = FizzyoFramework.Instance.Device.Pressure();
@@ -91,31 +83,23 @@ public void Calibrate()
pressureReadings.Add(pressure);
breathLength += Time.deltaTime;
- calibrationStatus = "Status: Calibraion Step " + calibrationStep.ToString() + " In Progress";
+ calibrationStatus = "Status: Calibration Step " + calibrationStep.ToString() + " In Progress";
calibrationColor = Color.yellow;
}
// If the pressure is not being maintained
else
{
-
if (breathLength > 1.0)
{
-
// Average and maximum values are taken from the calibration pressure readings
avgPressureReadings.Add(pressureReadings.Sum() / pressureReadings.Count);
avgLengths.Add(breathLength);
-
if (calibrationStep == requiredSteps)
{
-
- avgPressureReading = avgPressureReadings.Sum() / avgPressureReadings.Count;
- avgLength = avgLengths.Sum() / avgLengths.Count;
-
calibrationStatus = "Status: Uploading...";
calibrationColor = Color.green;
- // calibrationStatus = "Status: " + Data.Upload.Calibration(avgPressureReading, avgLength);
if (calibrationStatus == "Status: Upload Failed")
{
calibrationColor = Color.red;
@@ -127,28 +111,23 @@ public void Calibrate()
calibrating = false;
calibrationFinished = true;
-
}
else
{
-
pressureReadings.Clear();
breathLength = 0;
calibrating = false;
- calibrationStatus = "Status: Calibraion Step " + calibrationStep.ToString() + " Complete";
+ calibrationStatus = "Status: Calibration Step " + calibrationStep.ToString() + " Complete";
calibrationColor = Color.green;
calibrationStep += 1;
-
}
-
}
// If length of breath was less than 1
else
{
-
calibrating = false;
pressureReadings.Clear();
@@ -158,9 +137,7 @@ public void Calibrate()
calibrationStatus = "Status: Please Try Again";
calibrationColor = Color.red;
}
-
}
-
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoDevice.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoDevice.cs
index 975fd64..8dee069 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoDevice.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoDevice.cs
@@ -1,10 +1,11 @@
-
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
#if UNITY_EDITOR
using System.IO;
using System.Timers;
#endif
-// using System.Timers;
using UnityEngine;
namespace Fizzyo
@@ -39,13 +40,16 @@ public class FizzyoDevice
///
public float maxBreathCalibrated = 1.0f;
-
//protected
// protected StreamReader fileReader = null;
protected string text = " "; // assigned to allow first line to be read below
// System.Timers.Timer pollTimer = new System.Timers.Timer();
float pressure = 0;
+#if WINDOWS_UWP
+ private FizzyoHID fizzyoHID;
+#endif
+
#if UNITY_EDITOR
private StreamReader fileReader = null;
private Timer pollTimer;
@@ -58,7 +62,9 @@ public class FizzyoDevice
public FizzyoDevice()
{
-
+#if WINDOWS_UWP
+ fizzyoHID = FizzyoHID.Instance();
+#endif
}
//Cleanup
@@ -74,7 +80,6 @@ void OnApplicationQuit()
#endif
}
-
///
/// If useRecordedData is set to false pressure data is streamed from the device or streamed from a log file if set to true.
///
@@ -93,7 +98,11 @@ public float Pressure()
}
else
{
+#if WINDOWS_UWP
+ return (float)fizzyoHID.CurrentPressureValue / maxPressureCalibrated;
+#else
return Input.GetAxisRaw("Horizontal") / maxPressureCalibrated;
+#endif
}
}
}
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoFramework.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoFramework.cs
index 12e1b5d..b21c8d9 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoFramework.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoFramework.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -34,7 +32,7 @@ public class FizzyoFramework : MonoBehaviour
///
public bool showSetGamerTagAutomatically = false;
- [Tooltip("Automatically show calibration screen if never calibratd by user.")]
+ [Tooltip("Automatically show calibration screen if never calibrated by user.")]
///
///Set to true, shows calibration screen if there has never been a calibration
///
@@ -80,13 +78,11 @@ public enum TestHarnessData { p1_acapella, p1_pep, p2_acapella };
public FizzyoDevice Device { get; set; }
public FizzyoAchievements Achievements { get; set; }
public BreathRecogniser Recogniser { get; set; }
- public FizzyoAnalytics Analytics {get; set;}
+ public FizzyoAnalytics Analytics { get; set; }
- private static object _lock = new object();
private static bool applicationIsQuitting = false;
public string CallbackScenePath { get; private set; }
-
//Singleton instance
public static FizzyoFramework Instance
{
@@ -98,58 +94,50 @@ public static FizzyoFramework Instance
Debug.LogWarning("[Singleton] Instance '" + typeof(FizzyoFramework) +
"' already destroyed on application quit." +
" Won't create again - returning null.");
- // return null;
}
- // lock (_lock)
+ if (_instance == null)
{
- if (_instance == null)
+ _instance = (FizzyoFramework)FindObjectOfType(typeof(FizzyoFramework));
+
+ if (FindObjectsOfType(typeof(FizzyoFramework)).Length > 1)
{
- _instance = (FizzyoFramework)FindObjectOfType(typeof(FizzyoFramework));
-
- if (FindObjectsOfType(typeof(FizzyoFramework)).Length > 1)
- {
- Debug.LogError("[Singleton] Something went really wrong " +
- " - there should never be more than 1 singleton!" +
- " Reopening the scene might fix it.");
- return _instance;
- }
-
- if (_instance == null)
- {
- GameObject singleton = new GameObject();
- _instance = singleton.AddComponent();
- singleton.name = "(singleton) " + typeof(FizzyoFramework).ToString();
-
- DontDestroyOnLoad(singleton);
-
- Debug.Log("[Singleton] An instance of " + typeof(FizzyoFramework) +
- " is needed in the scene, so '" + singleton +
- "' was created with DontDestroyOnLoad.");
- }
- else
- {
- Debug.Log("[Singleton] Using instance already created: " +
- _instance.gameObject.name);
- }
+ Debug.LogError("[Singleton] Something went really wrong " +
+ " - there should never be more than 1 singleton!" +
+ " Reopening the scene might fix it.");
+ return _instance;
}
- return _instance;
+ if (_instance == null)
+ {
+ GameObject singleton = new GameObject();
+ _instance = singleton.AddComponent();
+ singleton.name = "(singleton) " + typeof(FizzyoFramework).ToString();
+
+ DontDestroyOnLoad(singleton);
+
+ Debug.Log("[Singleton] An instance of " + typeof(FizzyoFramework) +
+ " is needed in the scene, so '" + singleton +
+ "' was created with DontDestroyOnLoad.");
+ }
+ else
+ {
+ Debug.Log("[Singleton] Using instance already created: " +
+ _instance.gameObject.name);
+ }
}
- }
+ return _instance;
+ }
}
-
private FizzyoFramework()
{
-
if (_instance != null)
return;
Debug.Log("[FizzyoFramework] Instantiate.");
-
User = new FizzyoUser();
Device = new FizzyoDevice();
Recogniser = new BreathRecogniser();
@@ -157,8 +145,6 @@ private FizzyoFramework()
Analytics = new FizzyoAnalytics();
}
-
-
void Start()
{
Debug.Log("[FizzyoFramework] Start.");
@@ -170,7 +156,6 @@ void Start()
Load();
-
if (useTestHarnessData)
{
#if UNITY_EDITOR
@@ -178,29 +163,23 @@ void Start()
#endif
}
-
if (showCalibrateAutomatically && !Device.Calibrated)
{
Scene scene = SceneManager.GetActiveScene();
CallbackScenePath = scene.path;
SceneManager.LoadScene("Fizzyo/Scenes/Calibration");
}
-
-
-
}
void OnApplicationQuit()
{
- if(Analytics != null)
+ if (Analytics != null)
{
Analytics.PostOnQuit();
}
Debug.Log("[FizzyoFramework] Analytics is Null.");
}
-
-
private void Update()
{
//update the breath recoginiser
@@ -208,9 +187,6 @@ private void Update()
{
Recogniser.AddSample(Time.deltaTime, Device.Pressure());
}
-
-
-
}
@@ -230,7 +206,7 @@ private void Update()
///
/// Current players userID + "AchievementProgress" - String - Holds data on the achievement progress that the user has made in this game
///
- /// "accessToken" - String - Holds the access token that is aquired for the current user
+ /// "accessToken" - String - Holds the access token that is acquired for the current user
///
/// "tagDone" - Integer - 0 or 1 - Tells the developer if the user has completed setting a tag
///
@@ -240,7 +216,7 @@ private void Update()
///
/// "calTime" - Integer - Holds the breath length that the user has set in their calibration
///
- /// "userId" - String - Holds the user Id that is aquired for the current user
+ /// "userId" - String - Holds the user Id that is acquired for the current user
///
/// "gameId" - String - Holds the game Id for this specific game
///
@@ -265,12 +241,10 @@ private void Update()
public bool Load()
{
//Login to server
-
if (showLoginAutomatically)
{
LoginReturnType loginResult = User.Login();
-
if (loginResult != LoginReturnType.SUCCESS)
{
PlayOffline();
@@ -286,30 +260,19 @@ public bool Load()
User.Load();
Achievements.Load();
-
-
-
return true;
}
-
-
-
-
///
/// Sets up the player preferences to allow the user to play offline
///
private static void PlayOffline()
{
- // ResetPlayerPrefs();
}
///
/// Resets all of the player preferences
///
-
-
-
public void OnDestroy()
{
applicationIsQuitting = true;
@@ -320,9 +283,5 @@ private void OnEnable()
applicationIsQuitting = false;
}
-
-
}
-
-
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs
new file mode 100644
index 0000000..ea7b021
--- /dev/null
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs
@@ -0,0 +1,95 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+#if WINDOWS_UWP
+using System;
+using System.Collections.Generic;
+using Windows.Devices.Enumeration;
+using Windows.Devices.HumanInterfaceDevice;
+using Windows.Storage;
+#endif
+
+public class FizzyoHID
+{
+ //Singleton
+ private static FizzyoHID _instance;
+
+ public static FizzyoHID Instance()
+ {
+ if (_instance == null)
+ {
+ _instance = new FizzyoHID();
+ }
+ return _instance;
+ }
+
+ private double _currentPressureValue = 0;
+
+ public double CurrentPressureValue
+ {
+ get
+ {
+ return _currentPressureValue;
+ }
+ }
+
+#if WINDOWS_UWP
+
+ private DeviceWatcher watcher = null;
+
+ readonly Dictionary _gamepads = new Dictionary();
+
+ public IReadOnlyDictionary Gamepads => _gamepads;
+
+ public FizzyoHID()
+ {
+ var deviceSelector = HidDevice.GetDeviceSelector(0x01, 0x04);
+
+ watcher = DeviceInformation.CreateWatcher(deviceSelector);
+ watcher.Added += HandleAdded;
+ watcher.Removed += HandleRemoved;
+ watcher.Start();
+ }
+
+ private async void HandleAdded(DeviceWatcher sender, DeviceInformation args)
+ {
+ try
+ {
+ HidDevice hidDevice = await HidDevice.FromIdAsync(args.Id, FileAccessMode.Read);
+ hidDevice.InputReportReceived += HandleInputReportRecieved;
+ _gamepads.Add(args.Id, hidDevice);
+ }
+ catch
+ {
+ return;
+ }
+ }
+
+ private void HandleRemoved(DeviceWatcher sender, DeviceInformationUpdate args)
+ {
+ foreach (KeyValuePair pair in Gamepads)
+ {
+ if (pair.Key.Equals(args.Id))
+ {
+ _gamepads.Remove(pair.Key);
+ return;
+ }
+ }
+ }
+
+ void HandleInputReportRecieved(HidDevice sender, HidInputReportReceivedEventArgs args)
+ {
+ try
+ {
+ var pressureVal = args.Report.GetNumericControl(0x01, 0x30).Value;
+ pressureVal -= 127;
+ _currentPressureValue = pressureVal;
+ }
+ catch
+ {
+ return;
+ }
+ }
+
+#endif
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs.meta b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs.meta
new file mode 100644
index 0000000..2bbb6aa
--- /dev/null
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoHID.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7050d278b6142904cb57dd31838eca5f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoUser.cs b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoUser.cs
index 78cd6e6..92bd97d 100644
--- a/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoUser.cs
+++ b/Assets/Fizzyo/Scripts/FizzyoFramework/FizzyoUser.cs
@@ -1,9 +1,11 @@
- using System;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using UnityEngine;
using System.Text.RegularExpressions;
+using UnityEngine;
//https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
#if UNITY_UWP
@@ -11,12 +13,10 @@
using Windows.Data.Json;
using System.Net.Http;
using System.Threading.Tasks;
-
#endif
namespace Fizzyo
{
-
// Serializable that holds user data, access token and expiry
[System.Serializable]
public class AllUserData
@@ -42,19 +42,15 @@ public class UserTag
public string gamerTag;
}
-
-
-
public enum LoginReturnType { SUCCESS, INCORRECT, FAILED_TO_CONNECT }
public enum UserTagReturnType { SUCCESS, NOT_SET, FAILED_TO_CONNECT, BANNED_TAG }
- public enum CalibrationReturnType { SUCCESS, NOT_SET, FAILED_TO_CONNECT}
+ public enum CalibrationReturnType { SUCCESS, NOT_SET, FAILED_TO_CONNECT }
- ///
- /// Class that handles correct identification of each user, thanks to the use of Windows Live authentication
- ///
- public class FizzyoUser
+ ///
+ /// Class that handles correct identification of each user, thanks to the use of Windows Live authentication
+ ///
+ public class FizzyoUser
{
-
//Client ID refers to the Fizzyo app ID, which is used to get the Windows Live auth code
const string clientID = "65973b85-c34f-41a8-a4ad-00529d1fc23c"; //ce680d1e-27dc-4ffa-bc74-200d79a9e702
const string scopes = "wl.offline_access wl.signin wl.phone_numbers wl.emails";
@@ -66,40 +62,69 @@ public class FizzyoUser
private string patientRecordId;
private string token;
- ///
- /// Indicates whether someone is logged in or not
- ///
+ ///
+ /// Indicates whether someone is logged in or not
+ ///
public bool loggedIn = false;
- ///
- /// String holding the username of the account logging in
- ///
+ ///
+ /// String holding the username of the account logging in
+ ///
public string username;
- ///
- /// Testing variables, by default, username should be : test-patient
- ///
+ ///
+ /// Testing variables, by default, username should be : test-patient
+ ///
public string testUsername = "test-patient";
- ///
- /// Testing variables, by default, password should be : FizzyoTesting2017
- ///
+ ///
+ /// Testing variables, by default, password should be : FizzyoTesting2017
+ ///
public string testPassword = "FizzyoTesting2017";
public string UserID { get; internal set; }
public string AccessToken { get; internal set; }
+ private bool userTagSet = false;
+
+ public bool UserTagSet
+ {
+ get
+ {
+ return userTagSet;
+ }
+ set
+ {
+ userTagSet = value;
+ }
+ }
+
+ private bool calibrationSet = false;
+
+ public bool CalibrationSet
+ {
+ get
+ {
+ return calibrationSet;
+ }
+
+ set
+ {
+ calibrationSet = value;
+ }
+ }
+
+#if !UNITY_EDITOR
private bool loginInProgress = false;
private LoginReturnType loginResult = LoginReturnType.FAILED_TO_CONNECT;
- private bool userTagSet;
- private bool calibrationSet;
+#endif
- ///
+ ///
/// Method that begins the login process.
///
public LoginReturnType Login()
{
-
#if UNITY_UWP
loginInProgress = true;
+
UnityEngine.WSA.Application.InvokeOnUIThread(
async () =>
{
@@ -108,18 +133,16 @@ public LoginReturnType Login()
while(loginInProgress){}
return loginResult;
-
#elif UNITY_EDITOR
return PostAuthentication(testUsername, testPassword);
#else
- return loginResult;
+ return loginResult;
#endif
-
}
- ///
+ ///
/// Logs out the user. TO BE IMPLEMENTED
///
public void Logout()
@@ -127,18 +150,14 @@ public void Logout()
}
-
-
///
/// Uses a username and password to access the Fizzyo API and load in the users access token and user Id
/// This is currently incomplete as it does not use Windows live authorization
///
private LoginReturnType PostAuthentication(string username, string password)
{
-
string postAuth = "https://api.fizzyo-ucl.co.uk/api/v1/auth/test-token";
-
WWWForm form = new WWWForm();
form.AddField("username", username);
form.AddField("password", password);
@@ -150,30 +169,18 @@ private LoginReturnType PostAuthentication(string username, string password)
{
return LoginReturnType.INCORRECT;
}
-
AllUserData allData = JsonUtility.FromJson(sendPostAuth.text);
UserID = allData.user.id;
AccessToken = allData.accessToken;
-
return LoginReturnType.SUCCESS;
-
-
-
}
-
-
-
#if UNITY_UWP
-
-
-
public async Task LoginAsync()
{
-
string authorizationRequest = String.Format("{0}?client_id={1}&scope={2}&response_type=code&redirect_uri={3}",
authorizationEndpoint,
clientID,
@@ -184,10 +191,6 @@ public async Task LoginAsync()
Uri StartUri = new Uri(authorizationRequest);
Uri EndUri = new Uri(redirectURI);
-
-
-
-
WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, StartUri, EndUri);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
@@ -202,9 +205,6 @@ public async Task LoginAsync()
String code = queryStringParams["code"];
// Authorization Code is now ready to use!
-
-
-
bool tokenExhanged = await RequestAccessToken(code);
if (tokenExhanged == true)
@@ -224,10 +224,8 @@ public async Task LoginAsync()
loginResult = LoginReturnType.FAILED_TO_CONNECT;
loginInProgress = false;
return;
-
}
-
-
+
//TODO: look at adding Password vault : https://docs.microsoft.com/en-us/windows/uwp/security/credential-locker
//https://www.wintellect.com/single-sign-on-with-oauth-in-windows-store-apps/
@@ -277,48 +275,41 @@ public async Task RequestAccessToken(string code)
//accessToken = tokens.GetNamedString("accessToken");
loggedIn = true;
return true;
-
}
-
}
#endif
-
- ///
+ ///
/// Function that runs the methods responsible for loading user tags and calibration data.
///
public void Load()
{
-
switch (LoadUserTag())
{
case UserTagReturnType.NOT_SET | UserTagReturnType.FAILED_TO_CONNECT:
- userTagSet = false;
+ UserTagSet = false;
break;
case UserTagReturnType.SUCCESS:
- userTagSet = true;
+ UserTagSet = true;
break;
}
-
switch (LoadCalibrationData())
{
case CalibrationReturnType.NOT_SET | CalibrationReturnType.FAILED_TO_CONNECT:
- calibrationSet = false;
+ CalibrationSet = false;
break;
case CalibrationReturnType.SUCCESS:
- calibrationSet = true;
+ CalibrationSet = true;
break;
}
-
-
}
+
///
/// Loads in the users tag
///
public UserTagReturnType LoadUserTag()
{
-
//https://api.fizzyo-ucl.co.uk/api/v1/users/:id
string getTag = "https://api.fizzyo-ucl.co.uk/api/v1/users/" + FizzyoFramework.Instance.User.UserID;
@@ -346,11 +337,8 @@ public UserTagReturnType LoadUserTag()
{
return UserTagReturnType.NOT_SET;
}
-
-
}
-
///
/// Uploads a player tag to the Fizzyo API
///
@@ -361,7 +349,6 @@ public UserTagReturnType LoadUserTag()
///
public UserTagReturnType PostUserTag(string tag)
{
-
if (PlayerPrefs.GetInt("online") == 0)
{
return UserTagReturnType.FAILED_TO_CONNECT;
@@ -395,12 +382,9 @@ public UserTagReturnType PostUserTag(string tag)
PlayerPrefs.SetInt("tagDone", 1);
PlayerPrefs.SetString("userTag", tag);
- return UserTagReturnType.SUCCESS;
-
-
+ return UserTagReturnType.SUCCESS;
}
-
///
/// Loads in the users calibration data
///
@@ -441,12 +425,9 @@ private CalibrationReturnType LoadCalibrationData()
PlayerPrefs.SetFloat("calTime", allData.time);
return CalibrationReturnType.SUCCESS;
-
}
-
}
-
///
/// Uploads a players calibration data and also sets the values in player prefs
///
@@ -456,7 +437,6 @@ private CalibrationReturnType LoadCalibrationData()
///
public CalibrationReturnType Calibration(float pressure, float time)
{
-
PlayerPrefs.SetFloat("calPressure", pressure);
PlayerPrefs.SetFloat("calTime", time);
PlayerPrefs.SetInt("calDone", 1);
@@ -490,11 +470,9 @@ public CalibrationReturnType Calibration(float pressure, float time)
return CalibrationReturnType.FAILED_TO_CONNECT;
}
- return CalibrationReturnType.SUCCESS;
-
+ return CalibrationReturnType.SUCCESS;
}
-
///
/// Uploads a players session data and achievements
///
@@ -527,7 +505,6 @@ public CalibrationReturnType Calibration(float pressure, float time)
///
public static string Session(int goodBreathCount, int badBreathCount, int score, int startTime, int setCount, int breathCount)
{
-
if (PlayerPrefs.GetInt("online") == 0)
{
return "Session Upload Failed";
@@ -568,11 +545,7 @@ public static string Session(int goodBreathCount, int badBreathCount, int score,
status = "Session Upload Failed";
}
-
return status;
-
}
-
-
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/AchievementButton.cs b/Assets/Fizzyo/Scripts/SceneScripts/AchievementButton.cs
index 17361f3..c0246ac 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/AchievementButton.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/AchievementButton.cs
@@ -1,8 +1,11 @@
-using UnityEngine;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using UnityEngine;
using UnityEngine.UI;
///
-/// Class for catagory button data
+/// Class for category button data
///
public class AchievementButton : MonoBehaviour
{
@@ -36,4 +39,4 @@ public void Click()
achList.SetActive(false);
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/AchievementManager.cs b/Assets/Fizzyo/Scripts/SceneScripts/AchievementManager.cs
index 0d2962b..3c5f0e9 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/AchievementManager.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/AchievementManager.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using Fizzyo;
@@ -33,9 +36,6 @@ public class AchievementManager : MonoBehaviour
// Holds the name of each category
List catagories = new List();
- // Used to acurately display the progress of dependency achievements
- Dictionary dependencyProgress = new Dictionary();
-
// category Button Prefab
public GameObject catPre;
@@ -84,11 +84,11 @@ void Start()
active.Click();
}
- total.text = "Total Achievment Points: " + totalPoints;
+ total.text = "Total Achievement Points: " + totalPoints;
}
///
- /// Instatiates a game object for an achievement and assigns it the correct values
+ /// Instantiates a game object for an achievement and assigns it the correct values
///
/// ///
/// String that contains the category for that achievement
@@ -119,7 +119,7 @@ public void CreateAch(string parentCat, string title, string desc, int points, i
}
///
- /// Sets the parent, scale and all relevent information to be shown in an achievement
+ /// Sets the parent, scale and all relevant information to be shown in an achievement
///
/// ///
/// String that contains the category for that achievement
@@ -143,7 +143,7 @@ public void CreateAch(string parentCat, string title, string desc, int points, i
/// Integer that contains the achievements unlock requirement
///
///
- /// GameObject that contains the instatiated prefab for this achievement
+ /// GameObject that contains the instantiated prefab for this achievement
///
public void SetInfoAch(string parentCat, GameObject ach, string title, string desc, int points, int unlock, int unlockProgress, int unlockRequirement)
{
@@ -204,7 +204,7 @@ public void Changecategory(GameObject button)
{
AchievementButton achButton = button.GetComponent();
- // Changes scroll content on the main mask. Allows for scrolling of all catagories
+ // Changes scroll content on the main mask. Allows for scrolling of all categories
scroll.content = achButton.achList.GetComponent();
// Sets the active to false and the new button to true
@@ -212,6 +212,4 @@ public void Changecategory(GameObject button)
active.Click();
active = achButton;
}
-
-}
-
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/BackToMenu.cs b/Assets/Fizzyo/Scripts/SceneScripts/BackToMenu.cs
index 30d644e..a334240 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/BackToMenu.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/BackToMenu.cs
@@ -1,10 +1,12 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine.SceneManagement;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using UnityEngine;
+using UnityEngine.SceneManagement;
using UnityEngine.UI;
-public class BackToMenu : MonoBehaviour {
+public class BackToMenu : MonoBehaviour
+{
public Button back;
@@ -19,4 +21,4 @@ void BackClick()
{
SceneManager.LoadScene("Menu");
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/CalibrateScene.cs b/Assets/Fizzyo/Scripts/SceneScripts/CalibrateScene.cs
index 6a70777..efbc5a0 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/CalibrateScene.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/CalibrateScene.cs
@@ -1,4 +1,7 @@
-using Fizzyo;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using Fizzyo;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -70,7 +73,6 @@ void Calibrate()
{
float maxPressure = 0;
float minPressure = 0;
- float averagePressure = 0;
float totalPressure = 0;
for(int i = 0; i < pressureVals.Count; i++)
{
@@ -81,7 +83,6 @@ void Calibrate()
minPressure = Mathf.Min(v, minPressure);
}
- averagePressure = totalPressure / pressureVals.Count;
float maxBreath = 0;
for (int i = 0; i < breathLengthVals.Count; i++)
@@ -97,6 +98,8 @@ void Calibrate()
void NextScene()
{
+ FizzyoFramework.Instance.Recogniser.BreathStarted -= OnBreathStarted;
+ FizzyoFramework.Instance.Recogniser.BreathComplete -= OnBreathEnded;
SceneManager.LoadScene(FizzyoFramework.Instance.CallbackScenePath);
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/FizzyoOverlay.cs b/Assets/Fizzyo/Scripts/SceneScripts/FizzyoOverlay.cs
index f826ba1..c881097 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/FizzyoOverlay.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/FizzyoOverlay.cs
@@ -1,11 +1,13 @@
-using System.Collections;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using Fizzyo;
public class FizzyoOverlay : MonoBehaviour
{
-
// Session Data Saved popup that appears on-screen
public GameObject sessionPrefab;
@@ -32,7 +34,6 @@ public void ShowLoading()
uploadingPopup.transform.SetParent(GameObject.Find("LeadUnlock").transform);
uploadingPopup.transform.localScale = new Vector3(1, 1, 1);
StartCoroutine(FadePopup(uploadingPopup, false));
-
}
///
@@ -61,16 +62,15 @@ public void ShowSession(string status)
sessionPopup.transform.localScale = new Vector3(1, 1, 1);
sessionPopup.transform.GetChild(0).GetComponent().text = status;
StartCoroutine(FadePopup(sessionPopup, false));
-
}
///
/// Unlocks / adds progress to an achievement. Data is saved in player preferences and uploaded when a session is uploaded.
- /// When an achievment is unlocked it shows onscreen
+ /// When an achievement is unlocked it shows on screen
///
///
/// Using this achievement system:
- /// Use requires that the FizzyoOverlay Object be placed in a scene and the popup prefab be added in the inspector
+ /// Use requires that the FizzyoOverlay Object be placed in a scene and the pop-up prefab be added in the inspector
/// Then, within the game code the following can be used to unlock / add progress to an achievement:
/// private FizzyoOverlay FizzyoOverlay; - Used as a variable in the class
/// FizzyoOverlay = GameObject.Find("FizzyoOverlay").GetComponent(); - Used in the Start()/Awake() functions in a class
@@ -111,11 +111,9 @@ public void UnlockAchievement(string title, int progress)
if (allData.achievements[i].unlock == 0)
{
- // Set that an achievement variables has been changed and that this achievment will have to be uploaded on session end
+ // Set that an achievement variables has been changed and that this achievement will have to be uploaded on session end
allData.achievements[i].unlockProgress += progress;
-
-
bool chaining = true;
bool dependencyFound;
@@ -128,13 +126,12 @@ public void UnlockAchievement(string title, int progress)
if (allData.achievements[currentAchievement].unlockProgress >= allData.achievements[currentAchievement].unlockRequirement)
{
-
+
ShowAchievement("AchUnlock", allData.achievements[currentAchievement].title, allData.achievements[currentAchievement].description, allData.achievements[currentAchievement].points, allData.achievements[currentAchievement].unlock);
allData.achievements[currentAchievement].unlock = 1;
string achievementsToUpload = PlayerPrefs.GetString("achievementsToUpload");
- string achievementsToProgress = PlayerPrefs.GetString("achievementsToProgress");
// Add achievement into set that need to be uploaded at the end of a session
if (!achievementsToUpload.Contains(allData.achievements[i].id))
@@ -163,7 +160,6 @@ public void UnlockAchievement(string title, int progress)
chaining = false;
}
break;
-
}
}
@@ -171,7 +167,6 @@ public void UnlockAchievement(string title, int progress)
{
break;
}
-
}
else
{
@@ -217,7 +212,6 @@ public void UnlockAchievement(string title, int progress)
{
break;
}
-
}
}
@@ -225,7 +219,7 @@ public void UnlockAchievement(string title, int progress)
/// Used to show in the scene that a achievement has been unlocked
///
///
- /// String holding the achievements catagory
+ /// String holding the achievements category
///
///
/// String holding the achievements title
@@ -255,7 +249,7 @@ public void ShowAchievement(string parentCat, string title, string desc, int poi
///
///
/// Using this achievement system:
- /// Use requires that the FizzyoOverlay Object be placed in a scene and the popup prefab be added in the inspector
+ /// Use requires that the FizzyoOverlay Object be placed in a scene and the pop-up prefab be added in the inspector
/// Then, within the game code the following can be used to attempt to upload a score:
/// private FizzyoOverlay FizzyoOverlay; - Used as a variable in the class
/// FizzyoOverlay = GameObject.Find("FizzyoOverlay").GetComponent(); - Used in the Start()/Awake() functions in a class
@@ -283,34 +277,35 @@ public object LeaderBoard(int score)
scorePopup.transform.localScale = new Vector3(1, 1, 1);
scorePopup.transform.GetChild(0).GetComponent().text = status;
StartCoroutine(FadePopup(scorePopup, false));
-
+
return complete;
}
return complete;
-
}
///
- /// Moves the achievement, score and session messages offscreen and destroys them
+ /// Moves the achievement, score and session messages off screen and destroys them
///
///
- /// Game Object that is to be moved offscreen
+ /// Game Object that is to be moved off screen
///
///
/// Boolean which if false will move the message to the left and it true will move the message to the right
///
private IEnumerator FadePopup(GameObject popup, bool direction)
{
-
yield return new WaitForSeconds(5);
Vector3 startPos = popup.transform.position;
Vector3 endPos;
- if (!direction) {
+ if (!direction)
+ {
endPos = popup.transform.position - new Vector3(600, 0, 0);
- } else {
+ }
+ else
+ {
endPos = popup.transform.position + new Vector3(600, 0, 0);
}
float counter = 0;
@@ -324,7 +319,5 @@ private IEnumerator FadePopup(GameObject popup, bool direction)
}
Destroy(popup);
-
}
-
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/FollowCameraController.cs b/Assets/Fizzyo/Scripts/SceneScripts/FollowCameraController.cs
index 7386a77..f3e44d9 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/FollowCameraController.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/FollowCameraController.cs
@@ -1,12 +1,13 @@
-using UnityEngine;
-using System.Collections;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using UnityEngine;
public class FollowCameraController : MonoBehaviour
{
public GameObject player; //Public variable to store a reference to the player game object
-
private Vector3 offset; //Private variable to store the offset distance between the player and camera
// Use this for initialization
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/GraphBar.cs b/Assets/Fizzyo/Scripts/SceneScripts/GraphBar.cs
index 385facb..5e2a1a1 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/GraphBar.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/GraphBar.cs
@@ -1,5 +1,6 @@
-using System.Collections;
-using System.Collections.Generic;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using UnityEngine;
public class GraphBar : MonoBehaviour {
@@ -24,4 +25,4 @@ public void TweenToScale(float _y)
{
destScaleY = _y;
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/InitialDataLoad.cs b/Assets/Fizzyo/Scripts/SceneScripts/InitialDataLoad.cs
index 75366eb..5d58905 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/InitialDataLoad.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/InitialDataLoad.cs
@@ -1,15 +1,13 @@
-using System.Collections;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class InitialDataLoad : MonoBehaviour
{
-
- // gameId and gameSecret are used to load data via the Fizzyo API, these values must be assigned by the game developer
- string gameId = "40eaf651-5721-4092-81fc-5f631b8b1a97";
- string gameSecret = "70cb56007a46e26d47edae1679d2e9a0";
-
// Game Objects used withing the scene - assigned through unity script component
public GameObject loadingData;
public GameObject tagChange;
@@ -29,11 +27,9 @@ public class InitialDataLoad : MonoBehaviour
///
void Start()
{
-
SceneSetup();
StartCoroutine("LoadUserData");
-
}
///
@@ -41,7 +37,6 @@ void Start()
///
private void SceneSetup()
{
-
Screen.SetResolution(1280, 800, false);
loadingData.SetActive(true);
@@ -68,7 +63,6 @@ private void SceneSetup()
tagChange.SetActive(false);
offline.SetActive(false);
-
}
///
@@ -79,23 +73,22 @@ private void SceneSetup()
///
private IEnumerator LoadUserData()
{
-
-
loadingDataText.text = "Loading User Data...";
offline.SetActive(false);
yield return new WaitForSeconds(0.5f);
- bool dataLoaded = false;// Load.LoadUserData(gameId, gameSecret);
-
+ bool dataLoaded = false;
+
if (!dataLoaded)
{
loadingDataText.text = "Log In Failed / Playing Offline (Achievements, High Scores, Calibration Data and Session Data Will Not Be Uploaded)";
offline.SetActive(true);
- } else
+ }
+ else
{
loadingDataText.text = "User Data Loaded";
@@ -112,7 +105,6 @@ private IEnumerator LoadUserData()
StartCoroutine("EndLoad");
}
}
-
}
///
@@ -126,11 +118,12 @@ private IEnumerator EndLoad()
if (PlayerPrefs.GetInt("calDone") == 1)
{
SceneManager.LoadScene("Menu");
- } else
+ }
+ else
{
SceneManager.LoadScene("Calibration");
}
-
+
}
// Tag methods used to change the tag on screen with arrow buttons
@@ -203,9 +196,6 @@ void Tag3DownClick()
///
void ContinueClick()
{
-
- string fullTag = tag1.text + tag2.text + tag3.text;
-
string tagUpload = "";// Upload.UserTag(fullTag);
if (tagUpload != "Tag Upload Complete")
@@ -221,7 +211,6 @@ void ContinueClick()
StartCoroutine("EndLoad");
}
-
}
///
@@ -256,10 +245,7 @@ void OfflineClick()
///
void RetryClick()
{
-
offline.SetActive(false);
StartCoroutine("LoadUserData");
-
}
-
-}
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/LeaderboardManager.cs b/Assets/Fizzyo/Scripts/SceneScripts/LeaderboardManager.cs
index bb8d298..82d2406 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/LeaderboardManager.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/LeaderboardManager.cs
@@ -1,6 +1,8 @@
-using UnityEngine;
-using UnityEngine.UI;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+using UnityEngine;
+using UnityEngine.UI;
public class LeaderboardManager : MonoBehaviour
{
@@ -23,7 +25,7 @@ public class LeaderboardManager : MonoBehaviour
string pathUsers;
///
- /// Loads the highscores using the Fizzyo API and dispays them. If playing offline a message is displayed and the highscores are not
+ /// Loads the high scores using the Fizzyo API and displays them. If playing offline a message is displayed and the highscores are not
///
void Start()
{
@@ -65,7 +67,7 @@ void Start()
}
///
- /// Instatiates a game object for a high score and assigns it the correct values
+ /// Instantiates a game object for a high score and assigns it the correct values
///
/// ///
/// String that contains the position for that highscore
@@ -84,7 +86,7 @@ public void CreateLead(string position, string name, int score)
}
///
- /// Sets all relevent information to be shown in a highscore
+ /// Sets all relevant information to be shown in a highscore
///
/// ///
/// String that contains the position for that highscore
@@ -96,7 +98,7 @@ public void CreateLead(string position, string name, int score)
/// Integer that contains the score associated with that highscore
///
/// ///
- /// GameObject that contains the instatiated prefab for that highscore
+ /// GameObject that contains the instantiated prefab for that highscore
///
public void SetInfoLead(GameObject lead, string position, string name, int score)
{
@@ -110,8 +112,6 @@ public void SetInfoLead(GameObject lead, string position, string name, int score
} else
{
lead.transform.GetChild(2).GetComponent().text = score.ToString();
- }
-
+ }
}
-}
-
+}
\ No newline at end of file
diff --git a/Assets/Fizzyo/Scripts/SceneScripts/MenuButtons.cs b/Assets/Fizzyo/Scripts/SceneScripts/MenuButtons.cs
index 43fd111..8959a92 100644
--- a/Assets/Fizzyo/Scripts/SceneScripts/MenuButtons.cs
+++ b/Assets/Fizzyo/Scripts/SceneScripts/MenuButtons.cs
@@ -1,7 +1,8 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine.SceneManagement;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
using UnityEngine;
+using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MenuButtons : MonoBehaviour {
@@ -28,7 +29,6 @@ void Start()
Button exitBtn = exit.GetComponent