Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class AnimFranGoingNextDoor : MonoBehaviour {
- public GameObject GlobalDialogueManager;
- public GameObject SceneManager;
- public Transform Fran;
- public Animator FranAnimator;
- public GameObject Player;
- public GameObject[] FranToShow;
- public GameObject[] NextDialogue;
- public GameObject[] GODestroy;
- public void LauchAnimGoingDoor()
- {
- if (gameObject.GetComponent<Transform>().transform.localScale.x < 0)
- {
- Fran.transform.localScale = new Vector2(4,4);
- }
- AnimationEvent StopGoingDoor;
- StopGoingDoor = new AnimationEvent();
- StopGoingDoor.time = 1.5f;
- StopGoingDoor.functionName = "StopAnimation";
- Animation anim = GetComponent<Animation>();
- AnimationCurve curve;
- // create a new AnimationClip
- AnimationClip clip = new AnimationClip();
- clip.legacy = true;
- clip.name = "FranGoingNextDoor";
- // create a curve to move the GameObject and assign to the clip
- curve = AnimationCurve.Linear(0f, gameObject.GetComponent<Transform>().transform.localPosition.x, 1.5f, -1.072f);
- clip.SetCurve("", typeof(Transform), "localPosition.x", curve);
- curve = AnimationCurve.Linear(0f, gameObject.GetComponent<Transform>().transform.localPosition.y, 1.5f, -0.6809406f);
- clip.SetCurve("", typeof(Transform), "localPosition.y", curve);
- // now animate the GameObject
- anim.AddClip(clip, "FranGoingNextDoor");
- clip.AddEvent(StopGoingDoor);
- anim.Play("FranGoingNextDoor");
- }
- public void StopAnimation()
- {
- FranAnimator.SetBool("GoingDoor", false);
- Animation anim = GetComponent<Animation>();
- anim.RemoveClip("FranGoingNextDoor");
- Player.SetActive(false);
- GlobalDialogueManager.GetComponent<DialogueManager>().EndDialogue();
- if (SceneManager.GetComponent<DialogueBooleanVerificator>().isFirstPatientCinematic == true) {
- FranToShow[0].SetActive(true);
- NextDialogue[0].GetComponent<DialogueTrigger>().TriggerDialogue();
- Destroy(GODestroy[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement