//Displays an emotion (eye sprites) transiently for 2 seconds, then go back to neutral private IEnumerator transientEmotion(EyeType emote) { Opie.instance().head().set_eye_type(emote, Opie.Head.instant_action()); yield return(new WaitForSeconds(2)); Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); }
//public static WifiAndroidManager wifimanager; static OpieTorso() { //Opie.add_game (new PhonemeGame.PhonemeGameInterface ()); // Opie.add_game(new LookAroundYou.LookAroundYouGameInterface()); //Opie.add_game(new Assets.Games.DreamtimeGame.Scripts.OpieGameInterface()); //Opie.add_game(new AnimalGameControl.OpieGameInterface()); //Opie.add_game(new Assets.Games.TommyGame.Scripts.OpieGameInterface()); //This code defines which game to launch once the Opie ROS interface is initialized. This will switch to the profile scene when initialized Opie.add_game(new Assets.Games.MemoryGame.Scripts.OpieGameInterface()); #if UNITY_ANDROID && !UNITY_EDITOR // do not add TTS unless platform is Android Debug.Log("Starting TTS"); Opie.add_driver(OpieTTSDriver.instance()); #endif Opie.add_driver(new OpieAudio.OpieAudioInterface()); //Add Opie idle motion behaviour Opie.add_behaviour(new Opie.Behaviour("idle_motion")); //Setting node name (for ROS) and topic name Opie.instance().set_node_name("opie_2_torso_amy"); Opie.instance().set_topic_root("/opie"); }
// Use this for initialization void Start() { //Disable the "go" button while the animation is playing goButton = GameObject.Find("GoButton").GetComponent <Button>(); goButton.interactable = false; goButton.gameObject.SetActive(false); gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); int originnum = Math.Max(gameData.Iteration - 1, 0); int destinationnum = Math.Max(gameData.Iteration, 1); string originname = "level" + originnum.ToString(); string destinationname = "level" + destinationnum.ToString(); //Defining the origin and destination of the avatar origin = GameObject.Find(originname); destination = GameObject.Find(destinationname); transform.position = origin.transform.position + new Vector3(0, 0, -1); #if UNITY_ANDROID && !UNITY_EDITOR //Get Opie to look at the animation (by looking at its tummy) Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0f, Opie.Head.transition_action()); #endif //Using iTween script functions to move the object from origin to destination (the last argument calls //the function activateGoButton() upon completion of the animation) iTween.MoveTo(transform.gameObject, iTween.Hash("position", destination.transform.position + new Vector3(0, 0, -1), "speed", 1, "delay", 2, "easetype", iTween.EaseType.linear, "oncomplete", "ActivateGoButton")); }
void Start() { //Opie looks up with NEUTRAL emotion #if UNITY_ANDROID Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif // there should only be these levels if (gameInfo.Level == 1) //2 words, 4 tiles { gameData.arrange_grid(2); } else if (gameInfo.Level == 2) //3 words, 6 tiles { gameData.arrange_grid(3); } else if (gameInfo.Level == 3) //4 words, 8 tiles { gameData.arrange_grid(4); } else if (gameInfo.Level == 4) //6 words, 12 tiles { gameData.arrange_grid(6); } StateMachineInit(); CardsSetup(); }
// Update is called once per frame void Update() { if (!Opie.instance().update()) { Debug.Log("ERROR: Opie failed to update\n"); } }
public void QuitApp() { // the only way for quitPressed to be true here is when the game has started progressing to // next stage, so should not quit. this is an extra safeguard in case the disabling the button // doesnt happen fast enough. Unity doesnt always update the UI immediately if (quitPressed) { return; } quitPressed = true; quitButton.interactable = false; #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif Microphone.End(Microphone.devices[0]); if (RecordingText.text == "recording...") { RecordingText.text = "Stop recording"; } gameData.Reset(); logInfo.Reset(); extRes.Reset(); StartCoroutine(QuitAppCo()); }
void Start() { //Find all the necessary the Game Objects gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); extRes = GameObject.Find("LoadExternalResources").GetComponent <LoadExternalResources>(); mrps = GameObject.Find("MemRepeatPlaySound").GetComponent <MemRepeatPlaySound>(); quitButton = GameObject.Find("QuitButton").GetComponent <Button>(); //Retrieve ordering of the images, all the resources should have already been loaded //ordering = gameData.Ordering; // the iteration has increased at the end of the recalled scene, so -1 to bring it back to the actual level //questionNo = gameData.Iteration - 1; // an ID randomly chosen from the last seen set of questions int chosen = gameData.MemRepeatID; // start counting from 0 MemoryCard.sprite = extRes.MemoryImages[chosen]; targetSound = extRes.MemorySounds[chosen]; targetText = extRes.MemoryWords[chosen]; TranscriptionText.text = targetText; RecordingText.text = ""; StartCoroutine(PlayTargetSound()); #if UNITY_ANDROID && !UNITY_EDITOR // Opie looks down at the belly Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.0f, Opie.Head.transition_action()); #endif }
//This function is called at the end of the animation moving the avatar. public void ActivateGoButton() { // if quit button is not interactable, that means the quit button has be pressed and is playing // the thank you audio, if the go button is activated now the go sound will interrupt the quit sound Button quitButton = GameObject.Find("QuitButton").GetComponent <Button>(); if (!quitButton.IsInteractable()) { return; } #if UNITY_ANDROID && !UNITY_EDITOR //Opie looks back up Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif //Playing the audio instructions "press go" ProgressPlaySound pps = GameObject.Find("ProgressPlaySound").GetComponent <ProgressPlaySound>(); pps.PlayGoLongSound(); #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_eye_type(EyeType.ATTENTIVE, Opie.Head.instant_action()); #endif //Make the "Go!" button interactable goButton.gameObject.SetActive(true); //goButton.interactable = true; }
void Update() { #if UNITY_ANDROID //Define what happens when the user touches foreach (Vector2 pos in getTouchOrMouseInteractions()) { // Get the origin of the tap Vector2 origin = Camera.main.ScreenToWorldPoint(pos); float Xeye = 0.5f + origin.x / (22.5f - 2f * origin.y); //Get Opie to look at the position where the touch occurred Opie.instance().head().set_linked_pose_and_eye_position(Xeye, 0.0f, Opie.Head.transition_action()); } #endif //For debugging only (keyboard) if (Input.GetKey("escape")) { StopAllCoroutines(); Application.Quit(); } //Update the state machine state_machine.update(); }
// Use this for initialization void Start() { //Find the object containing profile information logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); mainLog = GameObject.Find("MainLogging").GetComponent <MainLogging>(); #if UNITY_ANDROID && !UNITY_EDITOR //Stop idle motion Opie.instance().behaviours("idle_motion").stop(Opie.Behaviour.instant_action()); #endif extRes = GameObject.Find("LoadExternalResources").GetComponent <LoadExternalResources>(); //If the resources folder for the selected language does not contain pictures/words subfolder, //then deactivate the Memory Game and Repetition Game // if ((Resources.LoadAll(language+"/pictures")).Length == 0){ if (!extRes.CheckIfPicturesExist()) { TextMemory.enabled = false; ButtonMemory.SetActive(false); TextRepetition.enabled = false; ButtonRepetition.SetActive(false); } //If the resource folder does not contain a Story subfolder, deactivate the story activity //if((Resources.LoadAll(language+"/story")).Length == 0){ if (!extRes.CheckIfStoryExist()) { TextStory.enabled = false; ButtonStory.SetActive(false); } }
void Start() { logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); Opie.instance().head().set_eye_type(EyeType.ATTENTIVE, Opie.Head.instant_action()); #endif }
public void Reset() { //Resets the logging information Filename = GetLatestFilename(); #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); Opie.instance().head().set_eye_type(EyeType.ATTENTIVE, Opie.Head.instant_action()); #endif }
private void LoadAndPlayBack(AudioClip ac) { StartCoroutine(LoadOneSound(ac)); #if UNITY_ANDROID && !UNITY_EDITOR //Opie is HAPPY to listern to the playback StartCoroutine(TransientEmotion(EyeType.ATTENTIVE)); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif }
// Update is called once per frame void Update() { #if UNITY_ANDROID && !UNITY_EDITOR if (!Opie.instance().update()) { Debug.Log("ERROR: Opie failed to update\n"); } #endif }
void Start() { //Create the file that logs the information Filename = GetLatestFilename(); #if UNITY_ANDROID && !UNITY_EDITOR //When the file is created, set the eyes to look straight up and set their emotion to ATTENTIVE Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); Opie.instance().head().set_eye_type(EyeType.ATTENTIVE, Opie.Head.instant_action()); #endif }
// Use this for initialization void Start() { //When entering this scene, stop the idle motion so that Opie stops //scanning the environment with its eyes #if UNITY_ANDROID Opie.instance().behaviours("idle_motion").stop(Opie.Behaviour.instant_action()); #endif game_info = GameObject.Find("GameInfo").GetComponent <GameInfo>(); currentLevel.text = game_info.CurrentLevelToString(); }
// Use this for initialization void Start() { //When entering this scene, stop the idle motion so that Opie stops //scanning the environment with its eyes #if UNITY_ANDROID Opie.instance().behaviours("idle_motion").stop(Opie.Behaviour.instant_action()); #endif //Find the object containing profile information game_info = GameObject.Find("GameInfo").GetComponent <GameInfo>(); }
private IEnumerator TransientEmotion(EyeType emote) { #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_eye_type(emote, Opie.Head.instant_action()); #endif yield return(new WaitForSeconds(2)); //2 #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); #endif }
//If quitting the game at that stge, go back to login screen public void QuitApp() { quitButton.interactable = false; quitPressed = true; #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif logInfo.Reset(); extRes.Reset(); StartCoroutine(QuitAppCo()); }
// Use this for initialization void Start() { //When entering this scene, stop the idle motion so that Opie stops scanning the environment with its eyes #if UNITY_ANDROID && !UNITY_EDITOR Opie.instance().behaviours("idle_motion").stop(Opie.Behaviour.instant_action()); #endif //Find the object containing profile information logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); //Write the username on screen (for verification purpose) UsernameText.text = logInfo.PlayerName; }
// Use this for initialization void Start() { //Find the objects containing the game data and the profile information gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); extRes = GameObject.Find("LoadExternalResources").GetComponent <LoadExternalResources>(); quitButton = GameObject.Find("QuitButton").GetComponent <Button>(); //goButton = GameObject.Find("GoButton").GetComponent<Button>(); restartBtn = GameObject.Find("RestartButton").GetComponent <Button>(); // move the loading resources to here to hide loading time // only load if not loaded if (!extRes.IsLoaded()) { resourcesLoaded = false; startTime = Time.realtimeSinceStartup; extRes.LoadMemoryGameResources(); restartBtn.interactable = false; goButton.interactable = false; } else { goButton.interactable = true; restartBtn.interactable = true; } //Quit the application if the player has reached the last level if (gameData.Iteration > gameData.TotalLevel) { QuitApp(); } if (gameData.Iteration == 1) { restartBtn.gameObject.SetActive(false); } else { restartBtn.gameObject.SetActive(true); } //Display the name of the user TextWritten.text = logInfo.PlayerName; #if UNITY_ANDROID && !UNITY_EDITOR //Get Opie to look down at its tummy to observe progress Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.0f, Opie.Head.transition_action()); #endif }
void Update() { #if UNITY_ANDROID && !UNITY_EDITOR foreach (Vector2 pos in GetTouchOrMouseInteractions()) { // Get the origin of the tap Vector2 origin = Camera.main.ScreenToWorldPoint(pos); float Xeye = 0.5f + origin.x / (22.5f - 2f * origin.y); Opie.instance().head().set_linked_pose_and_eye_position(Xeye, 0.0f, Opie.Head.transition_action()); } #endif }
void Start() { //Find all the necessary the Game Objects gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); logInfo = GameObject.Find("ProfileInfo").GetComponent <LogInfo>(); originalCard = GameObject.Find("Memory Card").GetComponent <MemoryCardRecall>(); originalStar = GameObject.Find("Star").GetComponent <Star>(); extRes = GameObject.Find("LoadExternalResources").GetComponent <LoadExternalResources>(); rps = GameObject.Find("RecallPlaySound").GetComponent <RecallPlaySound>(); quitButton = GameObject.Find("QuitButton").GetComponent <Button>(); mainLog = GameObject.Find("MainLogging").GetComponent <MainLogging>(); #if UNITY_ANDROID && !UNITY_EDITOR //Opie looks up with NEUTRAL emotion Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif //Retrieve ordering of the images, all the resources should have already been loaded ordering = gameData.Ordering; images = extRes.MemoryImages; sounds = extRes.MemorySounds; words = extRes.MemoryWords; noOfCard = gameData.NRows * gameData.NCols / 2; //Shuffle the order of the cards to be Question questions = Enumerable.Range(0, noOfCard).ToArray(); Shuffle(questions); answers = new int[noOfCard]; for (int i = 0; i < noOfCard; i++) { answers[i] = ordering[questions[i]]; } CardsSetup(); //Initializing the vectors of correct and incorrect answers correct = new List <string>(); incorrect = new List <string>(); oneShotCorrect = new List <string>(); //mcbn.GetComponent<Button>().interactable = false; DeactivateAllCards(); //Present the first word (sound + transcription) NextQuestion(); }
// Use this for initialization void Start() { #if UNITY_ANDROID Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif //When entering this scene, stop the idle motion so that Opie stops scanning //the environment with its eyes //#if UNITY_ANDROID // Opie.instance().behaviours ("idle_motion").stop (Opie.Behaviour.instant_action ()); //#endif //Find the object containing profile information gameInfo = GameObject.Find("GameInfo").GetComponent <GameInfo>(); gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); }
void Update() { //React to user touches foreach (Vector2 pos in getTouchOrMouseInteractions()) { // Get the origin of the tap Vector2 origin = Camera.main.ScreenToWorldPoint(pos); float Xeye = 0.5f + origin.x / (22.5f - 2f * origin.y); //Get Opie to look where the touch happened #if UNITY_ANDROID Opie.instance().head().set_linked_pose_and_eye_position(Xeye, 0.0f, Opie.Head.transition_action()); #endif } }
//Check if the cards match private IEnumerator CheckMatch() { //If the cards match if (_firstRevealed.id == _secondRevealed.id) { #if UNITY_ANDROID StartCoroutine(transientEmotion(EyeType.ATTENTIVE)); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif current_score++; // prevent overlapping of sound, so far the only condition is if it is playing the quit sound if (!mps.SoundSource.isPlaying) { mps.PlayCardMatchSound(); } //Debug.Log ("Scored in state " + state_machine.state.name); Scored(); //If the score reaches the maximum, then go to next if (current_score == winning_score) { go_to_next(); //StartCoroutine(go_to_next()); } } else { //If the cards don't match, Opie looks sad #if UNITY_ANDROID StartCoroutine(transientEmotion(EyeType.SAD)); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif mps.PlayCardMismatchSound(); yield return(new WaitForSeconds(.5f)); Finish(); //If the cards don't match, unreveal them _firstRevealed.Unreveal(); _secondRevealed.Unreveal(); } //Reinitialize the variables containing the values of the selected cards _firstRevealed = null; _secondRevealed = null; }
public void NextQuestion() { NextBtn.interactable = false; ImageDisplay.sprite = extRes.MemoryImages[questions[questionNo]]; targetSound = extRes.MemorySounds[questions[questionNo]]; targetText = extRes.MemoryWords[questions[questionNo]]; TranscriptionText.text = targetText; RecordText.text = ""; #if UNITY_ANDROID && !UNITY_EDITOR // Opie looks down at the belly //Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.0f, Opie.Head.transition_action()); Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); #endif if (!quitPressed) { StartCoroutine(PlayTargetSound()); } }
void Start() { #if UNITY_ANDROID Opie.instance().head().set_eye_type(EyeType.NEUTRAL, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.5f, Opie.Head.transition_action()); #endif //Find all the necessary the Game Objects gameData = GameObject.Find("GameData").GetComponent <GameDataScript>(); gameInfo = GameObject.Find("GameInfo").GetComponent <GameInfo>(); recallResults = GameObject.Find("RecallResults").GetComponent <RecallResults>(); recallResults.Reset(); originalCard = GameObject.Find("Memory Card").GetComponent <MemoryCardRecall>(); //originalStar = GameObject.Find("Star").GetComponent<Star>(); rps = GameObject.Find("RecallPlaySound").GetComponent <RecallPlaySound>(); quitButton = GameObject.Find("QuitButton").GetComponent <Button>(); //Retrieve ordering of the images, all the resources should have already been loaded ordering = gameData.Ordering; images = gameInfo.Images; sounds = gameInfo.Sounds; words = gameInfo.Words; no_of_card = gameData.N_rows * gameData.N_cols / 2; //Shuffle the order of the cards to be Question questions = Enumerable.Range(0, no_of_card).ToArray(); Shuffle(questions); answers = new int[no_of_card]; for (int i = 0; i < no_of_card; i++) { answers[i] = ordering[questions[i]]; } CardsSetup(); DeactivateAllCards(); //Present the first word (sound + transcription) NextQuestion(); }
// Update is called once per frame void Update() { #if UNITY_ANDROID && !UNITY_EDITOR //React to user touches foreach (Vector2 pos in GetTouchOrMouseInteractions()) { // Get the origin of the tap Vector2 origin = Camera.main.ScreenToWorldPoint(pos); float Xeye = 0.5f + origin.x / (22.5f - 2f * origin.y); // log every tap?? what is the point of logging the position /* * StreamWriter w; * w = new StreamWriter(Application.persistentDataPath + "/" + logInfo.PlayerName + '/' + logInfo.Filename, true); + w.WriteLine(DateTime.Now.ToString() + "\t" + origin.x.ToString() + "\t" + origin.y.ToString() + "\n"); + w.Close(); */ //using auto closes streamwrite //prevents problems if w.close() is not executed using (StreamWriter w = logInfo.LogFileInfo.AppendText()) { w.WriteLine(DateTime.Now.ToString() + "\t" + origin.x.ToString() + "\t" + origin.y.ToString()); } //Get opie to look where the touch occured Opie.instance().head().set_linked_pose_and_eye_position(Xeye, 0.0f, Opie.Head.transition_action()); } #endif // if we are waiting for some resources to be loaded if (resourceLoading) { if (extRes.AreStoryResourcesReady()) { resourceLoading = false; LoadingText.text = ""; Debug.Log("Load next page time" + (Time.realtimeSinceStartup - startTime).ToString()); } } }
//Called when a story sequence is finished (target found) private IEnumerator FinishedSequence() { #if UNITY_ANDROID && !UNITY_EDITOR //Opie looks up Opie.instance().head().set_eye_type(EyeType.ATTENTIVE, Opie.Head.instant_action()); Opie.instance().head().set_linked_pose_and_eye_position(0.5f, 0.0f, Opie.Head.transition_action()); #endif // no more clicking mask.gameObject.SetActive(false); //Target has been found, so the text of the sequence is read sps.PlayStorySound(currentSound); //Wait for sound to be finished yield return(new WaitWhile(() => sps.SoundSource.isPlaying)); if (quitPressed) { yield break; // stop the coroutine entirely } //Move to next level (or quit if last level is reached) level++; if (level > totalLevels) { QuitApp(); yield break; } // in case the next page is still loading for some reason if (resourceLoading) { LoadingText.text = "loading next page"; } // wait for the loading to finish yield return(new WaitWhile(() => resourceLoading)); // if not quited not finished, move to next page SetupNextPage(); }