Inheritance: UnityEngine.MonoBehaviour
Ejemplo n.º 1
0
        public void ResetCode()
        {
            string verificationCode = GetRandomSixDigitHexNumber();

            codeText.text = verificationCode;
            StartCoroutine(SenseixSession.VerifyGame(verificationCode));
        }
Ejemplo n.º 2
0
        static public string PlayerSeedPath()
        {
            string PlayerName     = SenseixSession.GetCurrentPlayerID();
            string playerSeedPath = System.IO.Path.Combine(Application.persistentDataPath, PlayerName + SEED_FILE_EXTENSION);

            return(playerSeedPath);
        }
Ejemplo n.º 3
0
 private static SenseixSession GetSingletonInstance()
 {
     if (singletonInstance == null)
     {
         singletonInstance = FindObjectOfType <SenseixSession>();
     }
     return(singletonInstance);
 }
Ejemplo n.º 4
0
 private static void LogText(string logString)
 {
     File.AppendAllText(GetLogPath(), logString);
     if (new System.IO.FileInfo(GetLogPath()).Length > deleteThreshhold)
     {
         File.Delete(GetLogPath());
     }
     SenseixSession.DoFileFlagging(GetLogPath());
 }
Ejemplo n.º 5
0
 static private void CheckProblemPull()
 {
     //Debug.Log ("get new problem count: " + GetNewProblemCount ());
     if (GetNewProblemCount() < 3)
     {
         if (SenseixSession.GetSessionState())
         {
             PullNewProblems();
         }
         //Debug.Log ("pulling more Problems");
     }
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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";
            }
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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());
        }
Ejemplo n.º 14
0
 static public bool ShouldCacheProblemPosts()
 {
     return(!SenseixSession.GetSessionState());
 }
Ejemplo n.º 15
0
 public static void GetProblems(uint numberOfProblems)
 {
     Message.Request.GetSingletonInstance().StartCoroutine(
         Message.Request.GetProblems(SenseixSession.GetCurrentPlayerID(), numberOfProblems));
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 static public void PullNewProblems()
 {
     SenseixSession.GetProblems(PROBLEMS_PER_PULL);
 }
Ejemplo n.º 18
0
 public void PullAvailablePlayers()
 {
     availablePlayers = SenseixSession.GetCurrentPlayerList();
 }