public void ResetCode() { string verificationCode = GetRandomSixDigitHexNumber(); codeText.text = verificationCode; StartCoroutine(SenseixSession.VerifyGame(verificationCode)); }
static public string PlayerSeedPath() { string PlayerName = SenseixSession.GetCurrentPlayerID(); string playerSeedPath = System.IO.Path.Combine(Application.persistentDataPath, PlayerName + SEED_FILE_EXTENSION); return(playerSeedPath); }
private static SenseixSession GetSingletonInstance() { if (singletonInstance == null) { singletonInstance = FindObjectOfType <SenseixSession>(); } return(singletonInstance); }
private static void LogText(string logString) { File.AppendAllText(GetLogPath(), logString); if (new System.IO.FileInfo(GetLogPath()).Length > deleteThreshhold) { File.Delete(GetLogPath()); } SenseixSession.DoFileFlagging(GetLogPath()); }
static private void CheckProblemPull() { //Debug.Log ("get new problem count: " + GetNewProblemCount ()); if (GetNewProblemCount() < 3) { if (SenseixSession.GetSessionState()) { PullNewProblems(); } //Debug.Log ("pulling more Problems"); } }
private static SenseixSession GetSingletonInstance() { if (singletonInstance == null) { singletonInstance = FindObjectOfType <SenseixSession>(); } if (singletonInstance == null) { throw new Exception("There is no SenseixSession.cs in scene. Please ensure" + " the Thinksy prefab is enabled."); } return(singletonInstance); }
public static IEnumerator InitializeSenseix(string newAccessToken) { //Debug.Log ("initializing"); if (isInitializing) { Logger.BasicLog("already initializing"); yield break; } isInitializing = true; yield return(GetSingletonInstance().StartCoroutine(WaitForWebGLInitializing())); SetSessionState(true); accessToken = newAccessToken; if (CheckAccessToken() == -1) { throw new Exception("The Thinksy Token you have provided is not of a valid length, please" + " register at https://developer.thinksylearn.com/ to create a valid key. Then, fill " + "in the Game Access Token field of the ThinksyPlugin script on the Thinksy Prefab." + " You can also test offline by checking the testing mode boolean on the Thinksy Prefab."); } //Creates a temporary account based on device id //returns an auth token. This is Syncronous. //Debug.Log("registering device"); yield return(GetSingletonInstance().StartCoroutine(RegisterDevice())); //Debug.Log ("listing players"); yield return(GetSingletonInstance().StartCoroutine(ListPlayers())); //Debug.Log("register all players"); yield return(GetSingletonInstance().StartCoroutine(RegisterAllPlayers())); //Debug.Log("submit cache"); SenseixSession.CheckProblemPostCacheSubmission(); //SenseixPlugin.ShowEmergencyWindow ("testing"); //yield return GetSingletonInstance().StartCoroutine(Message.Request.UpdatePlayerScore (GetCurrentPlayerID(), 0)); //yield return GetSingletonInstance().StartCoroutine(Message.Request.GetPlayerRank (GetCurrentPlayerID ())); yield return(Message.Request.GetSingletonInstance().StartCoroutine( Message.Request.GetProblems(SenseixSession.GetCurrentPlayerID(), ProblemKeeper.PROBLEMS_PER_PULL))); ThinksyPlugin.GetMostRecentProblem(); isInitializing = false; }
public void Refresh() { SenseixSession.PullLeaderboard(currentPage, (uint)PlayersPerPage); IList <Message.Leaderboard.PlayerData> leaders = SenseixSession.GetCurrentLeaderboard(); Text thisText = gameObject.GetComponent <Text> (); thisText.text = ""; for (int i = 0; i < leaders.Count; i++) { thisText.text += (i + 1).ToString() + ". "; thisText.text += leaders[i].name + " Sensei - "; thisText.text += leaders[i].score.ToString() + " points"; thisText.text += "\n"; } }
public void SetStudent(int studentIndex) { if (availablePlayers.Count <= 0) { return; } currentPlayerIndex = studentIndex % availablePlayers.Count; if (currentPlayerIndex < 0) { currentPlayerIndex = availablePlayers.Count + currentPlayerIndex; } SenseixSession.SelectPlayer(GetCurrentPlayer()); SetName(); SetFace(); ThinksyPlugin.NextProblem(); }
public static IEnumerator InitializeSenseix(string newAccessToken) { //Debug.Log ("initializing"); yield return(GetSingletonInstance().StartCoroutine(LimitedInitializeSenseix(newAccessToken))); //Debug.Log("submit cache"); SenseixSession.CheckProblemPostCacheSubmission(); //SenseixPlugin.ShowEmergencyWindow ("testing"); //yield return GetSingletonInstance().StartCoroutine(Message.Request.UpdatePlayerScore (GetCurrentPlayerID(), 0)); //yield return GetSingletonInstance().StartCoroutine(Message.Request.GetPlayerRank (GetCurrentPlayerID ())); yield return(Message.Request.GetSingletonInstance().StartCoroutine( Message.Request.GetProblems(SenseixSession.GetCurrentPlayerID(), ProblemKeeper.PROBLEMS_PER_PULL))); ThinksyPlugin.GetMostRecentProblem(); EndInitialize(); }
static public bool SubmitAnswer(Message.Problem.ProblemData answeredProblemData, Answer answer, bool correct) { Message.Problem.ProblemPost problem = new Message.Problem.ProblemPost(); problem.correct = correct; //set Problem's answers to given ones string[] answerIDStrings = answer.GetAnswerIDs(); Senseix.Message.Problem.AnswerIdentifier givenAnswerIDs = new Senseix.Message.Problem.AnswerIdentifier(); foreach (string answerID in answerIDStrings) { givenAnswerIDs.uuid.Add(answerID); } problem.problem_id = answeredProblemData.uuid; problem.answer_ids = givenAnswerIDs; problem.player_id = SenseixSession.GetCurrentPlayerID(); problem.answered_at_unix_time = UnixTimeNow(); AddAnsweredProblem(problem, answer); return(correct); }
static public void CopyFailsafeOver() { string failsafeFileName = "failsafe"; string failsafeDestination = System.IO.Path.Combine(Application.persistentDataPath, failsafeFileName + SEED_FILE_EXTENSION); TextAsset failsafeAsset = Resources.Load <TextAsset>(failsafeFileName); byte[] failsafeContents = failsafeAsset.bytes; try { FileStream newFile = System.IO.File.Create(failsafeDestination); SenseixSession.DoFileFlagging(failsafeDestination); newFile.Close(); System.IO.File.WriteAllBytes(failsafeDestination, failsafeContents); } catch { ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a failsafe seed file in " + failsafeDestination); } }
static private void ReplaceSeed(Message.Problem.ProblemGetResponse reply) { Logger.BasicLog("Replacing seed file."); MemoryStream stream = new MemoryStream(); ThinksyProtosSerializer customSerializer = new ThinksyProtosSerializer(); customSerializer.Serialize(stream, reply); byte[] replacementBytes = stream.ToArray(); try { FileStream newFile = System.IO.File.Create(PlayerSeedPath()); SenseixSession.DoFileFlagging(PlayerSeedPath()); newFile.Close(); } catch { ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a seedfile in " + PlayerSeedPath()); } stream.Close(); System.IO.File.WriteAllBytes(SeedFilePath(), replacementBytes); SenseixSession.DoFileFlagging(SeedFilePath()); }
static public bool ShouldCacheProblemPosts() { return(!SenseixSession.GetSessionState()); }
public static void GetProblems(uint numberOfProblems) { Message.Request.GetSingletonInstance().StartCoroutine( Message.Request.GetProblems(SenseixSession.GetCurrentPlayerID(), numberOfProblems)); }
private static SenseixSession GetSingletonInstance() { if (singletonInstance == null) { singletonInstance = FindObjectOfType<SenseixSession>(); } if (singletonInstance == null) { throw new Exception("There is no SenseixSession.cs in scene. Please ensure" + " the Thinksy prefab is enabled."); } return singletonInstance; }
static public void PullNewProblems() { SenseixSession.GetProblems(PROBLEMS_PER_PULL); }
public void PullAvailablePlayers() { availablePlayers = SenseixSession.GetCurrentPlayerList(); }