public void PlayNameClip() { if (trackableObjects.Count < 1) { Debug.Log("No Trackables Found!"); return; } if (currentTrackedPlayAudioTarget == null || currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() == null) { Debug.Log("No PlayAudio script attached to this object, or there is no active trackable target atm!"); return; } breakOutOfQuestions = true; if (playAudio != null) { playAudio.PlayAnimalNameClipOnClick(); if (userSettings != null) { userSettings.FadeBGMusicVolume(playAudio.GetAudioSource().clip.length + 0.5f); } } }
void GetCurrentTrackableObjects() { // Get the StateManager StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); noOfActiveTrackables = activeTrackables.Count(); // Iterate through the list of active trackables foreach (TrackableBehaviour tb in activeTrackables) { //Debug.Log("Trackable: " + tb.TrackableName); if (tb.TrackableName != "action-card" && tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { currentTrackedPlayAudioTarget = tb; cardTrackingTimer += Time.deltaTime; if (!playedAnimalNameOnce && cardTrackingTimer >= 1.75f) { if (currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() != null) { playAudio = currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>(); playAudio.PlayAnimalNameClipOnClick(); } playedAnimalNameOnce = true; } } currentTrackedTarget = tb; if (currentTrackedTarget.GetComponentInChildren <TouchControls>()) { currentTrackedTarget.GetComponentInChildren <TouchControls>().objectVisible = true; } if (currentTrackedTarget.TrackableName == "action-card" && noOfActiveTrackables == 1) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(false); } } else { if (!takingScreenshot) { foreach (GameObject objectUI in iconsUI) { objectUI.SetActive(true); } } } foreach (GameObject obj in objects) { GameObject ro = obj.GetComponent <SnappedObject>().refObject; if (ro != null) { if (ro.activeSelf) { ro.SetActive(false); } } } trackableObjects.Add(currentTrackedTarget); currentTrackedTargetName = currentTrackedTarget.TrackableName; if (!source.isPlaying && !breakOutOfQuestions && currentTrackedTargetName != "action-card" && currentTrackedTargetName != "groundcard") { if (!scannedCurrentTrackable && cardTrackingTimer >= timeBeforeQuestionsPlayRightOrWRong) { if (!answeredCorrectly) { if (Time.time > msTimeBeforePlayingCorrectOrWrong) { if (currentTrackedTargetName == names[randomIndex]) { switch (currentChoosenLanguage) { case "English": source.clip = answers[0]; break; case "Chinese": source.clip = answers[2]; break; default: source.clip = answers[0]; break; } if (userSettings != null) { userSettings.FadeBGMusicVolume(source.clip.length + 0.5f); } source.Play(); answeredCorrectly = true; } else { switch (currentChoosenLanguage) { case "English": source.clip = answers[1]; break; case "Chinese": source.clip = answers[3]; break; default: source.clip = answers[1]; break; } if (userSettings != null) { userSettings.FadeBGMusicVolume(source.clip.length + 0.5f); } source.Play(); } scannedCurrentTrackable = true; } } } } } }
void GetCurrentTrackableObjects() { // Get the StateManager StateManager sm = TrackerManager.Instance.GetStateManager(); IEnumerable <TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours(); //noOfActiveTrackables = activeTrackables.Count(); // Iterate through the list of active trackables foreach (TrackableBehaviour tb in activeTrackables) { if (tb.TrackableName != "action-card" && tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { currentTrackedPlayAudioTarget = tb; animalNameTimer += Time.deltaTime; if (currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>() != null) { playAudio = currentTrackedPlayAudioTarget.GetComponentInChildren <PlayAudio>(); } if (!playedAnimalNameOnce && animalNameTimer >= passedTime) { playedAnimalNameOnce = true; playedAnimalVoiceOnce = false; if (playAudio != null) { playAudio.PlayAnimalNameClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } } if (playedAnimalNameOnce && animalNameTimer >= passedTime) { if (playAudio != null) { if (playAudio.indexNumber == 0 && !playedAnimalVoiceOnce) { playedAnimalVoiceOnce = true; playAudio.PlayAnimalSoundClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } else { if (playAudio.indexNumber > playAudio.maxArrayLength - 1) { playedAnimalNameOnce = false; playAudio.indexNumber = 0; } else { playAudio.PlayInfoClipOnClick(); passedTime = passedTime + playAudio.currentClipLength + audioClipsInterval; } } } } } if (tb.TrackableName != "groundcard" && tb.TrackableName != "BigFishMarker") { bigMarkerTrackable = tb; } currentTrackedTarget = tb; trackableObjects.Add(currentTrackedTarget); } }