CreateProblemPart() public static méthode

public static CreateProblemPart ( Senseix newAtom ) : ProblemPart,
newAtom Senseix
Résultat ProblemPart,
        static public bool ParseGetEncouragementsResponse(byte[] responseBytes)
        {
            Encouragement.EncouragementGetResponse getEncouragementResponse =
                Deserialize(responseBytes, typeof(Encouragement.EncouragementGetResponse)) as Encouragement.EncouragementGetResponse;

            Logger.BasicLog("I got an encouragement get response with " + getEncouragementResponse.encouragement_data.Count + " encouragements.");

            foreach (Encouragement.EncouragementData encouragementData in getEncouragementResponse.encouragement_data)
            {
                ProblemPart[] encouragementParts = new ProblemPart[encouragementData.encouragement_atoms.Count];
                for (int i = 0; i < encouragementParts.Length; i++)
                {
                    encouragementParts[i] = ProblemPart.CreateProblemPart(encouragementData.encouragement_atoms[i]);
                }
                ThinksyEvents.InvokeEncouragementReceived(encouragementParts);
            }

            ThinksyPlugin.NewHeartbeatTiming(getEncouragementResponse.frames_per_heartbeat);
            if (getEncouragementResponse.force_pull)
            {
                ProblemKeeper.PullNewProblems();
            }

            return(true);
        }
Exemple #2
0
 /// <summary>
 /// Build an answer from a message received from the Thinksy server.  For internal use within the Thinksy plugin.
 /// </summary>
 public Answer(Senseix.Message.Problem.Answer protoAnswer)
 {
     foreach (Senseix.Message.Atom.Atom atom in protoAnswer.answers)
     {
         answerParts.Add(ProblemPart.CreateProblemPart(atom));
     }
 }
    /// <summary>
    /// Gets distractors.
    /// These are wrong answers which can be presented as options to the player.
    /// </summary>
    /// <returns>The distractors.</returns>
    /// <param name="howManyDistractors">How many random distractors to return.</param>
    public ProblemPart[] GetDistractors(int howManyDistractors)
    {
        int availableDistractors = protobufsProblemData.distractor.distractors.Count;

        if (availableDistractors < howManyDistractors)
        {
            throw new Exception("There aren't enough distractors!  There are only "
                                + availableDistractors + " distractors.");
        }

        ArrayList allDistractors = new ArrayList();

        for (int i = 0; i < availableDistractors; i++)
        {
            Senseix.Message.Atom.Atom distractorAtom = protobufsProblemData.distractor.distractors[i];
            ProblemPart distractor = ProblemPart.CreateProblemPart(distractorAtom);
            allDistractors.Add(distractor);
        }         //find all the distractors

        ProblemPart[] resultDistractors = new ProblemPart[howManyDistractors];
        for (int i = 0; i < howManyDistractors; i++)
        {
            int randomDistractorIndex = UnityEngine.Random.Range(0, allDistractors.Count);
            resultDistractors[i] = (ProblemPart)allDistractors[randomDistractorIndex];
            allDistractors.RemoveAt(randomDistractorIndex);
        }         //take random ones

        return(resultDistractors);
    }
Exemple #4
0
 public System.Collections.IEnumerator GetEnumerator()
 {
     foreach (Senseix.Message.Atom.Atom atom in atomList)
     {
         yield return(ProblemPart.CreateProblemPart(atom));
     }
 }
 public ProblemPart GetLearningActionPartByIndex(int index)
 {
     if (index < 0 || index > GetProto().atoms.Count)
     {
         throw new Exception("That is out of range.  There are " + GetProto().atoms.Count + " problem parts.");
     }
     return(ProblemPart.CreateProblemPart(GetProto().atoms[index]));
 }
Exemple #6
0
 /// <summary>
 /// Questions can be represented as a series of ProblemParts
 /// which contain information to communicate the problem.
 /// This gets the question part at the given index.
 /// You can also iterate through a question using foreach
 /// </summary>
 public ProblemPart GetQuestionPart(int index)
 {
     try
     {
         return(ProblemPart.CreateProblemPart(atomList[index]));
     }
     catch
     {
         throw new Exception("Question part index out of range");
     }
 }
        static public bool ParseListItemsResponse(byte[] responseBytes)
        {
            Player.ListPlayerItemsResponse listItemsResponse =
                Deserialize(responseBytes, typeof(Player.ListPlayerItemsResponse)) as Player.ListPlayerItemsResponse;

            Logger.BasicLog("I got an items list response with " + listItemsResponse.item_atoms.Count + " items");

            //foreach(Message.Atom.Atom atom in listItemsResponse.item_atoms)
            //{
            //UnityEngine.Debug.Log(atom.filename);
            //}

            ProblemPart[] items = new ProblemPart[listItemsResponse.item_atoms.Count];
            for (int i = 0; i < listItemsResponse.item_atoms.Count; i++)
            {
                items[i] = ProblemPart.CreateProblemPart(listItemsResponse.item_atoms[i]);
            }

            ItemsDisplay.SetItemsToDisplay(items);

            return(true);
        }