public void OnRoleplayLoaded(string serializedRoleplayDescription)
    {
        currentRoleplay = JsonUtility.FromJson <RoleplayDescription>(serializedRoleplayDescription);

        isClient = currentRoleplay.UserA.Id == Manager.ClientId;

        Participant other;
        Participant self;

        PrepareBriefingScreens(currentRoleplay);

        if (isClient)
        {
            other = currentRoleplay.UserB;
            self  = currentRoleplay.UserA;
            ScreenController.SwitchScreenToClientBriefing();
        }
        else
        {
            other = currentRoleplay.UserA;
            self  = currentRoleplay.UserB;
            ScreenController.SwitchScreenToProfessionalBriefing();
        }

        RoleplayCall.Initialize(isClient, other, self);
    }
    private void SendEvaluation(InputField[] inputFields)
    {
        ScreenController.SwitchScreenToCompleteEvaluationLoading();

        // creates the case evaluation.
        CaseEvaluation caseEvaluation = new CaseEvaluation()
        {
            Id               = currentRoleplay.Id,
            User             = isClient ? currentRoleplay.UserA : currentRoleplay.UserB,
            EvaluationFields = new string[inputFields.Length]
        };

        for (int i = 0; i < inputFields.Length; i++)
        {
            caseEvaluation.EvaluationFields[i] = inputFields[i].text;
            inputFields[i].text = "";
        }

        // Sends the evaluation to the server.
        string         json = JsonUtility.ToJson(caseEvaluation);
        NetworkMessage evaluationMessage = new NetworkMessage(NetworkMessageType.TransmitEvaluationTest, Manager.ClientId, "", json);

        Manager.SendMessage(evaluationMessage);

        CompleteEvaluationController.RequestCompleteEvaluation(caseEvaluation.Id);
    }
Esempio n. 3
0
    public void PrepareScreen(string serializedCompleteEvaluation)
    {
        CompleteCaseEvaluation caseEvaluation = JsonUtility.FromJson <CompleteCaseEvaluation>(serializedCompleteEvaluation);

        SetNames(caseEvaluation);
        SetElements(caseEvaluation);
        SetEvaluation(caseEvaluation.EvaluationUserA, EvaluationUserAFields);
        SetEvaluation(caseEvaluation.EvaluationUserB, EvaluationUserBFields);
    }
Esempio n. 4
0
    private void OnMatchFound(Participant participantA, Participant participantB, RoleplayModule module)
    {
        RoleplayDescription roleplayDescription = RoleplayDescriptionGenerator.Generate(participantA, participantB, module);
        string json = JsonUtility.ToJson(roleplayDescription);

        string name = string.Format(RoleplayFileName.Value, roleplayDescription.Id);

        SaveLoad.Save(json, name);

        SendRoleplayDescription(json, participantA);
        SendRoleplayDescription(json, participantB);
    }
    public void OnEvaluationAcquired(string serializedEvaluation)
    {
        CaseEvaluation caseEvaluation = JsonUtility.FromJson <CaseEvaluation>(serializedEvaluation);

        string id = caseEvaluation.Id;

        if (acquiredEvaluations.ContainsKey(id))
        {
            GenerateCompleteEvaluation(id, caseEvaluation);
        }
        else
        {
            acquiredEvaluations.Add(id, caseEvaluation);
        }
    }
    private void GenerateCompleteEvaluation(string id, CaseEvaluation caseEvaluation)
    {
        // Removes the case from the dictionary.
        CaseEvaluation other = acquiredEvaluations[id];

        acquiredEvaluations.Remove(id);

        // Converts the stored roleplay to an object.
        string roleplayJson;
        string fileName = string.Format(RoleplaySaveName.Value, id);

        SaveLoad.Load(fileName, out roleplayJson);
        RoleplayDescription roleplayDescription = JsonUtility.FromJson <RoleplayDescription>(roleplayJson);

        // serialized the complete evaluation.
        bool isUserA = id == roleplayDescription.UserA.Id;
        CompleteCaseEvaluation completeCaseEvaluation = new CompleteCaseEvaluation()
        {
            RoleplayDescription = roleplayDescription,
            EvaluationUserA     = isUserA ? caseEvaluation : other,
            EvaluationUserB     = isUserA ? other : caseEvaluation,
            TimeStamp           = DateTime.Now.ToString()
        };

        string completeEvalJson = JsonUtility.ToJson(completeCaseEvaluation);

        SaveLoad.Save(completeEvalJson, string.Format(CompleteEvaluationName.Value, id));

        SendMessageTo(roleplayDescription.UserA, completeEvalJson);
        SendMessageTo(roleplayDescription.UserB, completeEvalJson);

        AddIdToUserLog(roleplayDescription.UserA.Id, id);
        AddIdToUserLog(roleplayDescription.UserB.Id, id);

        SocialManager.AddToRecentLog(roleplayDescription.UserA, roleplayDescription.UserB);
        SocialManager.AddToRecentLog(roleplayDescription.UserB, roleplayDescription.UserA);

        SaveLoad.Remove(fileName);
    }