private IEnumerator animateObject(Vector3 newAngle, Vector3 newPosition, AudioProfile audioProfile) { Quaternion originalRotation = interactable.MySpawnReference.transform.localRotation; Vector3 originalPosition = interactable.MySpawnReference.transform.localPosition; //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): original position: " + originalPosition + "; rotation: " + originalRotation); AudioSource audioSource = interactable.MySpawnReference.GetComponent <AudioSource>(); if (audioSource != null && audioProfile != null && audioProfile.MyAudioClip != null) { audioSource.PlayOneShot(audioProfile.MyAudioClip); } while (interactable.MySpawnReference.transform.localEulerAngles != newAngle || interactable.MySpawnReference.transform.localPosition != newPosition) { //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): localEulerAngles: " + interactable.MySpawnReference.transform.localEulerAngles + "; position: " + interactable.MySpawnReference.transform.localPosition); //Quaternion newRotation = Quaternion.Lerp(originalRotation, Quaternion.Euler(newAngle), 0.01f); Quaternion newRotation = Quaternion.RotateTowards(interactable.MySpawnReference.transform.localRotation, Quaternion.Euler(newAngle), rotationSpeed); Vector3 newLocation = Vector3.MoveTowards(interactable.MySpawnReference.transform.localPosition, newPosition, movementSpeed); interactable.MySpawnReference.transform.localPosition = newLocation; interactable.MySpawnReference.transform.localRotation = newRotation; yield return(null); } objectOpen = !objectOpen; //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): localEulerAngles: " + interactable.MySpawnReference.transform.localEulerAngles + "; position: " + interactable.MySpawnReference.transform.localPosition + "; COMPLETE ANIMATION"); coroutine = null; }
public override void SetupScriptableObjects() { base.SetupScriptableObjects(); if (flightAudioProfileNames != null) { foreach (string audioProfileName in flightAudioProfileNames) { AudioProfile audioProfile = SystemAudioProfileManager.MyInstance.GetResource(audioProfileName); if (audioProfile != null) { flightAudioProfiles.Add(audioProfile); } else { Debug.LogError("BaseAbility.SetupScriptableObjects(): Could not find audio profile: " + audioProfileName + " while inititalizing " + DisplayName + ". CHECK INSPECTOR"); } } } }
public void ShowDescription(AudioProfile musicProfile) { //Debug.Log("SkillTrainerUI.ShowDescription(" + skillName + ")"); ClearDescription(); if (musicProfile == null) { return; } currentAudioProfile = musicProfile; UpdateButtons(musicProfile); musicDescription.text = string.Format("<size=30><b><color=yellow>{0}</color></b></size>\n\n<size=18>{1}</size>", musicProfile.DisplayName, musicProfile.Description); if (musicProfile.ArtistName != null && musicProfile.ArtistName != string.Empty) { musicDescription.text += string.Format("\n\n<size=20><b>Author:</b></size> {0}\n\n", musicProfile.ArtistName); } }
private IEnumerator animateObject(Vector3 newAngle, Vector3 newPosition, AudioProfile audioProfile) { newAngle = new Vector3(newAngle.x < 0 ? newAngle.x + 360 : newAngle.x, newAngle.y < 0 ? newAngle.y + 360 : newAngle.y, newAngle.z < 0 ? newAngle.z + 360 : newAngle.z); Quaternion originalRotation = interactable.MySpawnReference.transform.localRotation; Vector3 originalPosition = interactable.MySpawnReference.transform.localPosition; //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): original position: " + originalPosition + "; rotation: " + originalRotation); AudioSource audioSource = interactable.MySpawnReference.GetComponent <AudioSource>(); if (audioSource != null && audioProfile != null && audioProfile.AudioClip != null) { //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(): playing audioclip: " + audioProfile.AudioClip); audioSource.PlayOneShot(audioProfile.AudioClip); } // testing doing this first to allow an object to reverse before it's animation has completed objectOpen = !objectOpen; while (interactable.MySpawnReference.transform.localEulerAngles != newAngle || interactable.MySpawnReference.transform.localPosition != newPosition) { //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): localEulerAngles: " + interactable.MySpawnReference.transform.localEulerAngles + "; position: " + interactable.MySpawnReference.transform.localPosition); //Quaternion newRotation = Quaternion.Lerp(originalRotation, Quaternion.Euler(newAngle), 0.01f); //Quaternion newRotation = Quaternion.RotateTowards(interactable.MySpawnReference.transform.localRotation, Quaternion.Euler(newAngle), rotationSpeed); // get a separate quaternion rotation to avoid issues with negative start angles //Quaternion tmpRotation = interactable.MySpawnReference.transform.localRotation * Quaternion.Euler(newAngle); //Vector3 realNewAngle = tmpRotation.eulerAngles; Quaternion newRotation = Quaternion.RotateTowards(Quaternion.Euler(interactable.MySpawnReference.transform.localEulerAngles), Quaternion.Euler(newAngle), rotationSpeed); //Quaternion newRotation = Quaternion.RotateTowards(interactable.MySpawnReference.transform.localRotation, Quaternion.Euler(realNewAngle), rotationSpeed); //Quaternion newRotation = Quaternion.RotateTowards(interactable.MySpawnReference.transform.localRotation, tmpRotation, rotationSpeed); Vector3 newLocation = Vector3.MoveTowards(interactable.MySpawnReference.transform.localPosition, newPosition, movementSpeed); interactable.MySpawnReference.transform.localPosition = newLocation; interactable.MySpawnReference.transform.localRotation = newRotation; yield return(null); } //objectOpen = !objectOpen; //Debug.Log(gameObject.name + ".AnimatedObject.animateObject(" + newAngle + ", " + newPosition + "): localEulerAngles: " + interactable.MySpawnReference.transform.localEulerAngles + "; position: " + interactable.MySpawnReference.transform.localPosition + "; COMPLETE ANIMATION"); coroutine = null; }
/* * public void UpdateSelected() { * //Debug.Log("SkillTrainerUI.UpdateSelected()"); * if (SelectedMusicPlayerHighlightButton != null) { * ShowDescription(SelectedMusicPlayerHighlightButton.MyMusicProfile); * } * } */ private void UpdateButtons(AudioProfile musicProfile) { //Debug.Log("MusicPlayerUI.UpdateButtons(" + musicProfile + ")"); playButton.Button.interactable = true; if (audioType == AudioType.Music) { if (audioManager.MusicAudioSource.isPlaying == true) { stopButton.Button.interactable = true; pauseButton.Button.interactable = true; } else { stopButton.Button.interactable = false; pauseButton.Button.interactable = false; } } else if (audioType == AudioType.Ambient) { if (audioManager.AmbientAudioSource.isPlaying == true) { stopButton.Button.interactable = true; pauseButton.Button.interactable = true; } else { stopButton.Button.interactable = false; pauseButton.Button.interactable = false; } } else if (audioType == AudioType.Effect) { stopButton.Button.interactable = true; pauseButton.Button.interactable = false; } uINavigationControllers[1].UpdateNavigationList(); uINavigationControllers[1].FocusCurrentButton(); }