Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using Tesis;
- using Holoville.HOTween;
- public class VerbalAction : MonoBehaviour
- {
- public AudioSource source;
- Random r;
- public string eventName;
- public AudioClip[] soundsOrientado;
- public AudioClip[] soundsConfuso;
- public AudioClip[] soundsInapropiado;
- public AudioClip[] soundsIncompresible;
- Tweener hablando;
- public virtual void Start()
- {
- NamedEventManager.ListenTo (eventName, DoIt);
- source = GameObject.FindGameObjectWithTag("boca").GetComponent<AudioSource>();
- }
- void Update()
- {
- if (Input.GetKey(KeyCode.A))
- NamedEventManager.Fire(eventName);
- if (!source.isPlaying && hablando != null)
- HOTween.Kill (hablando.id);
- }
- public virtual void DoIt(NameEventArgs args)
- {
- switch (EstadoDelPaciente.Main.Verbal) {
- case 5:
- playSound(soundsOrientado);
- break;
- case 4:
- playSound(soundsConfuso);
- break;
- case 3:
- playSound(soundsInapropiado);
- break;
- case 2:
- playSound(soundsIncompresible);
- break;
- default:
- break;
- }
- }
- void playSound(AudioClip[] sounds){
- int i = Random.Range (0, sounds.Length);
- source.clip = sounds [i];
- source.Play ();
- hablar ();
- }
- void hablar(){
- TweenParms tweenParms = new TweenParms()
- .Prop("rotation", new Vector3(2f, 0, 0), true)
- .Ease(EaseType.Linear)
- .Loops(-1, LoopType.Yoyo);
- hablando = HOTween.To(this.transform, .25f, tweenParms);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement