private IEnumerator DoCuedRecall(int trial_number)
    {
        this_trial_presented_stores.Shuffle(new System.Random());

        textDisplayer.DisplayText("display day cued recall prompt", LanguageSource.GetLanguageString("store cue recall"));
        yield return(SkippableWait(RECALL_MESSAGE_DISPLAY_LENGTH));

        textDisplayer.ClearText();
        highBeep.Play();
        scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
        {
            { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() }
        });
        textDisplayer.DisplayText("display recall text", RECALL_TEXT);
        yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH));

        textDisplayer.ClearText();
        foreach (StoreComponent cueStore in this_trial_presented_stores)
        {
            cueStore.familiarization_object.SetActive(true);
            string output_file_name = trial_number.ToString() + "-" + cueStore.GetStoreName();
            string output_directory = UnityEPL.GetDataPath();
            string wavFilePath      = System.IO.Path.Combine(output_directory, output_file_name) + ".wav";
            string lstFilepath      = System.IO.Path.Combine(output_directory, output_file_name) + ".lst";
            AppendWordToLst(lstFilepath, cueStore.GetLastPoppedItemName());
            Dictionary <string, object> cuedRecordingData = new Dictionary <string, object>();
            cuedRecordingData.Add("trial number", trial_number);
            cuedRecordingData.Add("store", cueStore.GetStoreName());
            cuedRecordingData.Add("item", cueStore.GetLastPoppedItemName());
            cuedRecordingData.Add("store position", cueStore.transform.position.ToString());
            scriptedEventReporter.ReportScriptedEvent("cued recall recording start", cuedRecordingData);
            soundRecorder.StartRecording(wavFilePath);
            yield return(SkippableWait(CUED_RECALL_TIME_PER_STORE));

            cueStore.familiarization_object.SetActive(false);
            scriptedEventReporter.ReportScriptedEvent("cued recall recording stop", cuedRecordingData);
            soundRecorder.StopRecording();


            lowBeep.Play();
            scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
            {
                { "sound name", "low beep" }, { "sound duration", highBeep.clip.length.ToString() }
            });
            textDisplayer.DisplayText("display recall text", RECALL_TEXT);
            yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH));

            textDisplayer.ClearText();
        }
    }
Beispiel #2
0
    private void processList(LanguageSource source, bool isError)
    {
        if (isError)
        {
            loadingText.text = "couldn't connect to the server";
            return;
        }
        this.source = source;

        for (int i = 1; i < source.keys.Count; i++)//the first one is id, which is not necessary
        {
            GameObject g = Instantiate(togglePre) as GameObject;
            g.GetComponent <LanguageBtn>().SetUp(source.keys[i], source.values[i], content);
        }
        loadingText.gameObject.SetActive(false);
        content.gameObject.SetActive(true);
    }
Beispiel #3
0
    void DrawSigns()
    {
        List <UnityEngine.TextMesh> updateUs = new List <UnityEngine.TextMesh>();

        updateUs.AddRange(gameObject.GetComponentsInChildren <UnityEngine.TextMesh> ());
        updateUs.AddRange(familiarization_object.GetComponentsInChildren <UnityEngine.TextMesh> ());
        foreach (UnityEngine.TextMesh textComponent in updateUs)
        {
            string displayString = LanguageSource.GetLanguageString(storeName).ToUpper();
            if (displayString.Equals("GROCERY STORE"))
            {
                displayString = "GROCERY";
            }
            if (displayString.Equals("HARDWARE STORE"))
            {
                displayString = "HARDWARE";
            }
            if (displayString.Equals("CLOTHING STORE"))
            {
                displayString = "CLOTHING";
            }
            if (displayString.Equals("JEWELRY STORE"))
            {
                displayString = "JEWELRY";
            }
            if (LanguageSource.current_language == LanguageSource.LANGUAGE.GERMAN)
            {
                string[] germanWords = displayString.Split(' ');
                if (germanWords.Length == 2)
                {
                    displayString = germanWords[1];
                }
                displayString = displayString[0].ToString().ToUpper() + displayString.Substring(1).ToLower();
            }
            if (displayString.Equals("Kleidungsgeschäft"))
            {
                displayString = "Kleidung";
            }
            if (displayString.Equals("Spielwarenladen"))
            {
                displayString = "Spielwaren";
            }
            textComponent.text = displayString;
        }
    }
Beispiel #4
0
    public void SetLanguageName(string languageName, Action <bool> after)
    {
        if (languageName != GetLanguageName())
        {
            PlayerPrefs.SetString("language", languageName);
            string url = "http://madebyjimchen.com/WarOfCastles/api/getLanguageSource.php?language=" + languageName;

            JimHtml.DownLoadJson <LanguageSource>(Data.inst, url, false, (LanguageSource lang, bool isError) =>
            {
                if (!isError)
                {
                    this.languageSource = lang;
                    SaveLanguageSource();
                }
                after(isError);
            });
        }
        else
        {
            after(true);
        }
    }
Beispiel #5
0
 private void Update()
 {
     if (IsValidParticipantName(participantCodeInput.text))
     {
         UnityEPL.ClearParticipants();
         UnityEPL.AddParticipant(participantCodeInput.text);
         UnityEPL.SetExperimentName("DBOY1");
         beginExperimentButton.SetActive(true);
         greyedOutButton.SetActive(false);
         int nextSessionNumber = NextSessionNumber();
         UnityEPL.SetSessionNumber(NextSessionNumber());
         beginButtonText.text = LanguageSource.GetLanguageString("begin session") + " " + nextSessionNumber.ToString();
     }
     else
     {
         greyedOutButton.SetActive(true);
         beginExperimentButton.SetActive(false);
     }
     if (DeliveryItems.ItemsExhausted())
     {
         beginExperimentButton.SetActive(false);
         finishedButton.SetActive(true);
     }
     else
     {
         finishedButton.SetActive(false);
     }
     if (LanguageMismatch())
     {
         beginExperimentButton.SetActive(false);
         languageMismatchButton.SetActive(true);
     }
     else
     {
         languageMismatchButton.SetActive(false);
     }
 }
    private IEnumerator ExperimentCoroutine()
    {
        if (sessionNumber == -1)
        {
            throw new UnityException("Please call ConfigureExperiment before beginning the experiment.");
        }

        //write versions to logfile
        LogVersions();

        if (useRamulator)
        {
            yield return(ramulatorInterface.BeginNewSession(sessionNumber));
        }

        BlackScreen();
        yield return(DoIntroductionVideo(LanguageSource.GetLanguageString("play movie"), LanguageSource.GetLanguageString("first day")));

        yield return(DoSubjectSessionQuitPrompt(sessionNumber,
                                                LanguageSource.GetLanguageString("running participant")));

        yield return(DoMicrophoneTest(LanguageSource.GetLanguageString("microphone test"),
                                      LanguageSource.GetLanguageString("after the beep"),
                                      LanguageSource.GetLanguageString("recording"),
                                      LanguageSource.GetLanguageString("playing"),
                                      LanguageSource.GetLanguageString("recording confirmation")));

        yield return(DoFamiliarization());

        yield return(messageImageDisplayer.DisplayLanguageMessage(messageImageDisplayer.delivery_restart_messages));



        Environment environment = EnableEnvironment();

        Dictionary <string, object> storeMappings = new Dictionary <string, object>();

        foreach (StoreComponent store in environment.stores)
        {
            storeMappings.Add(store.GetStoreName(), store.gameObject.name);
            storeMappings.Add(store.GetStoreName() + " position X", store.transform.position.x);
            storeMappings.Add(store.GetStoreName() + " position Y", store.transform.position.y);
            storeMappings.Add(store.GetStoreName() + " position Z", store.transform.position.z);
        }
        scriptedEventReporter.ReportScriptedEvent("store mappings", storeMappings);

        int trial_number = 0;

        for (trial_number = 0; trial_number < 12; trial_number++)
        {
            Dictionary <string, object> trialData = new Dictionary <string, object>();
            trialData.Add("trial number", trial_number);
            scriptedEventReporter.ReportScriptedEvent("begin new trial", trialData);
            WorldScreen();
            if (useRamulator)
            {
                ramulatorInterface.BeginNewTrial(trial_number);
            }
            yield return(null);

            yield return(DoDelivery(environment, trial_number));

            BlackScreen();
            yield return(DoRecall(trial_number));

            SetRamulatorState("WAITING", true, new Dictionary <string, object>());
            yield return(null);

            if (!DeliveryItems.ItemsExhausted())
            {
                textDisplayer.DisplayText("proceed to next day prompt", LanguageSource.GetLanguageString("next day"));
                while (!Input.GetButton("q (secret)") && !Input.GetButton("x (continue)"))
                {
                    yield return(null);
                }

                textDisplayer.ClearText();
                if (Input.GetButton("q (secret)"))
                {
                    break;
                }
            }
            else
            {
                yield return(PressAnyKey(LanguageSource.GetLanguageString("final recall")));

                break;
            }
            SetRamulatorState("WAITING", false, new Dictionary <string, object>());
        }

        yield return(messageImageDisplayer.DisplayLanguageMessage(messageImageDisplayer.final_recall_messages));

        yield return(DoFinalRecall(environment));

        //int delivered_objects = trial_number == 12 ? (trial_number) * 12 : (trial_number + 1) * 12;
        textDisplayer.DisplayText("end text", LanguageSource.GetLanguageString("end message") + starSystem.CumulativeRating().ToString("+#.##;-#.##"));
    }
    private IEnumerator DoPointingTask(StoreComponent nextStore)
    {
        pointer.SetActive(true);
        ColorPointer(new Color(0.5f, 0.5f, 1f));
        pointer.transform.eulerAngles = new Vector3(0, Random.Range(0, 360), 0);
        scriptedEventReporter.ReportScriptedEvent("pointing begins", new Dictionary <string, object>()
        {
            { "start direction", pointer.transform.eulerAngles.y }
        });
        pointerMessage.SetActive(true);
        pointerText.text = LanguageSource.GetLanguageString("next package prompt") +
                           LanguageSource.GetLanguageString(nextStore.GetStoreName()) + ". " +
                           LanguageSource.GetLanguageString("please point") +
                           LanguageSource.GetLanguageString(nextStore.GetStoreName()) + "." + "\n\n" +
                           LanguageSource.GetLanguageString("joystick");
        yield return(null);

        while (!Input.GetButtonDown("x (continue)"))
        {
            if (!playerMovement.IsDoubleFrozen())
            {
                pointer.transform.eulerAngles = pointer.transform.eulerAngles + new Vector3(0, Input.GetAxis("Horizontal") * Time.deltaTime * pointerRotationSpeed, 0);
            }
            yield return(null);
        }

        float pointerError = PointerError(nextStore.gameObject);

        if (pointerError < Mathf.PI / 12)
        {
            pointerParticleSystem.Play();
            pointerText.text = LanguageSource.GetLanguageString("correct to within") + Mathf.RoundToInt(pointerError * Mathf.Rad2Deg).ToString() + ". ";
        }
        else
        {
            pointerText.text = LanguageSource.GetLanguageString("wrong by") + Mathf.RoundToInt(pointerError * Mathf.Rad2Deg).ToString() + ". ";
        }

        float wrongness = pointerError / Mathf.PI;

        ColorPointer(new Color(wrongness, 1 - wrongness, .2f));
        bool improvement = starSystem.ReportScore(1 - wrongness);

        if (improvement)
        {
            pointerText.text = pointerText.text + LanguageSource.GetLanguageString("rating improved");
        }


        yield return(null);

        yield return(PointArrowToStore(nextStore.gameObject));

        while (!Input.GetButtonDown("x (continue)"))
        {
            yield return(null);
        }
        scriptedEventReporter.ReportScriptedEvent("pointer message cleared", new Dictionary <string, object>());
        pointerParticleSystem.Stop();
        pointer.SetActive(false);
        pointerMessage.SetActive(false);
    }
    private IEnumerator DoFinalRecall(Environment environment)
    {
        SetRamulatorState("RETRIEVAL", true, new Dictionary <string, object>());

        DisplayTitle(LanguageSource.GetLanguageString("all stores recall"));

        highBeep.Play();
        scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
        {
            { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() }
        });
        textDisplayer.DisplayText("display recall text", RECALL_TEXT);
        yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH));

        textDisplayer.ClearText();

        string output_directory = UnityEPL.GetDataPath();
        string output_file_name = "store recall";
        string wavFilePath      = System.IO.Path.Combine(output_directory, output_file_name) + ".wav";
        string lstFilepath      = System.IO.Path.Combine(output_directory, output_file_name) + ".lst";

        foreach (StoreComponent store in environment.stores)
        {
            AppendWordToLst(lstFilepath, store.GetStoreName());
        }

        scriptedEventReporter.ReportScriptedEvent("final store recall recording start", new Dictionary <string, object>());
        soundRecorder.StartRecording(wavFilePath);
        yield return(SkippableWait(STORE_FINAL_RECALL_LENGTH));

        scriptedEventReporter.ReportScriptedEvent("final store recall recording stop", new Dictionary <string, object>());
        soundRecorder.StopRecording();
        textDisplayer.ClearText();
        lowBeep.Play();
        scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
        {
            { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() }
        });

        ClearTitle();

        yield return(SkippableWait(TIME_BETWEEN_DIFFERENT_RECALL_PHASES));

        DisplayTitle(LanguageSource.GetLanguageString("all objects recall"));

        highBeep.Play();
        scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
        {
            { "sound name", "high beep" }, { "sound duration", highBeep.clip.length.ToString() }
        });
        textDisplayer.DisplayText("display recall text", RECALL_TEXT);
        yield return(SkippableWait(RECALL_TEXT_DISPLAY_LENGTH));

        textDisplayer.ClearText();

        output_file_name = "final recall";
        wavFilePath      = System.IO.Path.Combine(output_directory, output_file_name) + ".wav";
        lstFilepath      = System.IO.Path.Combine(output_directory, output_file_name) + ".lst";
        foreach (string deliveredObject in all_presented_objects)
        {
            AppendWordToLst(lstFilepath, deliveredObject);
        }

        scriptedEventReporter.ReportScriptedEvent("final object recall recording start", new Dictionary <string, object>());
        soundRecorder.StartRecording(wavFilePath);
        yield return(SkippableWait(FINAL_RECALL_LENGTH));

        scriptedEventReporter.ReportScriptedEvent("final object recall recording stop", new Dictionary <string, object>());
        soundRecorder.StopRecording();

        textDisplayer.ClearText();
        lowBeep.Play();
        scriptedEventReporter.ReportScriptedEvent("Sound played", new Dictionary <string, object>()
        {
            { "sound name", "low beep" }, { "sound duration", lowBeep.clip.length.ToString() }
        });

        ClearTitle();
        SetRamulatorState("RETRIEVAL", false, new Dictionary <string, object>());
    }
Beispiel #9
0
        private static void CheckLocalizedTextInPrefab(GameObject obj, string assetName, LanguageSource source)
        {
            var  components = obj.GetComponentsInChildren <LocalizedText>(true);
            bool modifyTag  = false;

            foreach (var component in components)
            {
                string text = GetComponentText(component.gameObject);
                if (text.Length > 0)
                {
                    var tComponent = component.gameObject.GetComponent <Text>();
                    if (!StringUtil.ContainChinese(text))  // 不包含汉字
                    {
                        ModifyLocalizedText(component, "", "");
                        modifyTag = true;
                    }
                    else
                    {
                        uint key = StringUtil.ToUInt32(assetName + text);
                        if (!key.Equals(component.Key) || !assetName.Equals(component.AssetName))
                        {
                            ModifyLocalizedText(component, key.ToString(), assetName);
                            modifyTag = true;
                        }
                        if (!source.ContainEntry(key))
                        {
                            source.AddEntry(new LanguageEntry(key, text));
                        }
                    }

                    if (modifyTag)
                    {
                        PrefabUtility.SavePrefabAsset(obj);
                    }
                }
            }
        }
Beispiel #10
0
 public void processLang(LanguageSource lang)
 {
     this.languageSource = lang;
     SaveLanguageSource();
 }
    public void SetReminderText(string store_name)
    {
        string prompt_string = LanguageSource.GetLanguageString("please find prompt") + LanguageSource.GetLanguageString(store_name);

        please_find_the_blah_reminder_text.text = prompt_string;
    }