Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class AnimFranGoingNextDoor : MonoBehaviour {
  6.  
  7. public GameObject GlobalDialogueManager;
  8. public GameObject SceneManager;
  9.  
  10. public Transform Fran;
  11. public Animator FranAnimator;
  12.  
  13. public GameObject Player;
  14. public GameObject[] FranToShow;
  15.  
  16. public GameObject[] NextDialogue;
  17. public GameObject[] GODestroy;
  18.  
  19. public void LauchAnimGoingDoor()
  20. {
  21.  
  22. if (gameObject.GetComponent<Transform>().transform.localScale.x < 0)
  23. {
  24. Fran.transform.localScale = new Vector2(4,4);
  25.  
  26. }
  27.  
  28.  
  29. AnimationEvent StopGoingDoor;
  30. StopGoingDoor = new AnimationEvent();
  31. StopGoingDoor.time = 1.5f;
  32. StopGoingDoor.functionName = "StopAnimation";
  33.  
  34. Animation anim = GetComponent<Animation>();
  35. AnimationCurve curve;
  36.  
  37.  
  38.  
  39.  
  40. // create a new AnimationClip
  41. AnimationClip clip = new AnimationClip();
  42. clip.legacy = true;
  43. clip.name = "FranGoingNextDoor";
  44.  
  45.  
  46. // create a curve to move the GameObject and assign to the clip
  47. curve = AnimationCurve.Linear(0f, gameObject.GetComponent<Transform>().transform.localPosition.x, 1.5f, -1.072f);
  48. clip.SetCurve("", typeof(Transform), "localPosition.x", curve);
  49.  
  50.  
  51. curve = AnimationCurve.Linear(0f, gameObject.GetComponent<Transform>().transform.localPosition.y, 1.5f, -0.6809406f);
  52. clip.SetCurve("", typeof(Transform), "localPosition.y", curve);
  53.  
  54.  
  55.  
  56.  
  57. // now animate the GameObject
  58. anim.AddClip(clip, "FranGoingNextDoor");
  59. clip.AddEvent(StopGoingDoor);
  60. anim.Play("FranGoingNextDoor");
  61. }
  62.  
  63. public void StopAnimation()
  64. {
  65. FranAnimator.SetBool("GoingDoor", false);
  66. Animation anim = GetComponent<Animation>();
  67. anim.RemoveClip("FranGoingNextDoor");
  68. Player.SetActive(false);
  69. GlobalDialogueManager.GetComponent<DialogueManager>().EndDialogue();
  70. if (SceneManager.GetComponent<DialogueBooleanVerificator>().isFirstPatientCinematic == true) {
  71. FranToShow[0].SetActive(true);
  72. NextDialogue[0].GetComponent<DialogueTrigger>().TriggerDialogue();
  73. Destroy(GODestroy[0]);
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement