Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using Tesis;
  4. using Holoville.HOTween;
  5.  
  6. public class VerbalAction : MonoBehaviour
  7. {
  8. public AudioSource source;
  9. Random r;
  10. public string eventName;
  11. public AudioClip[] soundsOrientado;
  12. public AudioClip[] soundsConfuso;
  13. public AudioClip[] soundsInapropiado;
  14. public AudioClip[] soundsIncompresible;
  15. Tweener hablando;
  16.  
  17. public virtual void Start()
  18. {
  19.  
  20. NamedEventManager.ListenTo (eventName, DoIt);
  21. source = GameObject.FindGameObjectWithTag("boca").GetComponent<AudioSource>();
  22.  
  23. }
  24.  
  25. void Update()
  26. {
  27. if (Input.GetKey(KeyCode.A))
  28. NamedEventManager.Fire(eventName);
  29. if (!source.isPlaying && hablando != null)
  30. HOTween.Kill (hablando.id);
  31. }
  32.  
  33. public virtual void DoIt(NameEventArgs args)
  34. {
  35. switch (EstadoDelPaciente.Main.Verbal) {
  36. case 5:
  37. playSound(soundsOrientado);
  38. break;
  39. case 4:
  40. playSound(soundsConfuso);
  41. break;
  42. case 3:
  43. playSound(soundsInapropiado);
  44. break;
  45. case 2:
  46. playSound(soundsIncompresible);
  47. break;
  48. default:
  49. break;
  50. }
  51.  
  52. }
  53.  
  54. void playSound(AudioClip[] sounds){
  55. int i = Random.Range (0, sounds.Length);
  56. source.clip = sounds [i];
  57. source.Play ();
  58. hablar ();
  59. }
  60.  
  61. void hablar(){
  62. TweenParms tweenParms = new TweenParms()
  63. .Prop("rotation", new Vector3(2f, 0, 0), true)
  64. .Ease(EaseType.Linear)
  65. .Loops(-1, LoopType.Yoyo);
  66. hablando = HOTween.To(this.transform, .25f, tweenParms);
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement