Advertisement
NolanSyKinsley

Untitled

May 26th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TriggerSleepStates : MonoBehaviour
  5. {
  6. static DragonStates States = DragonStates.Instance;
  7. public Rigidbody DragonRigidBody;
  8.  
  9. // Create a reference to the animator component
  10. private Animator animator;
  11.  
  12. public float IdleBeforeSleep;
  13. //TODO set up falling asleep after a period of time, possibly rotate the camera in a circle while sleeping.?
  14.  
  15. // Use this for initialization
  16. void Start ()
  17. {
  18. // initialise the reference to the animator component
  19. animator = GetComponent<Animator>();
  20. }
  21.  
  22. void Update()
  23. {
  24. if (Input.GetButtonDown("Nap"))
  25. {
  26.  
  27. if (States.CurrentDragonState == DragonStates.DragonState.Idle)
  28. {
  29. States.SetSleepFallAsleep();
  30. animator.SetBool("FallAsleep", true);
  31. }
  32. else if (States.CurrentDragonState == DragonStates.DragonState.Sleeping)
  33. {
  34. States.SetSleepWakeUp();
  35. animator.SetBool("WakeUp", true);
  36. States.SetIdle();
  37. }
  38.  
  39. }
  40.  
  41. if (States.CurrentDragonState == DragonStates.DragonState.Sleeping)
  42. {
  43. if (!DragonRigidBody.IsSleeping())
  44. {
  45. DragonRigidBody.Sleep();
  46. }
  47. }
  48. else
  49. {
  50. if (DragonRigidBody.IsSleeping())
  51. DragonRigidBody.WakeUp();
  52. }
  53. if (Input.GetButtonUp("Nap") && States.CurrentDragonState == DragonStates.DragonState.Idle)
  54. {
  55. animator.SetBool("WakeUp", false);
  56. }
  57. }
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement