Esempio n. 1
0
    public void PrepareScreen(string serializedCompleteEvaluation)
    {
        CompleteCaseEvaluation caseEvaluation = JsonUtility.FromJson <CompleteCaseEvaluation>(serializedCompleteEvaluation);

        SetNames(caseEvaluation);
        SetElements(caseEvaluation);
        SetEvaluation(caseEvaluation.EvaluationUserA, EvaluationUserAFields);
        SetEvaluation(caseEvaluation.EvaluationUserB, EvaluationUserBFields);
    }
    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);
    }