Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class WorkDoor : MonoBehaviour
  6. {
  7.  
  8.  
  9. bool IsDoorGame;
  10. public bool isTimerPlay;
  11.  
  12. [SerializeField] Animation animation;
  13.  
  14. Light lightColor;
  15. public AudioSource audioGame;
  16.  
  17. public int id = 0;
  18.  
  19. private void Start()
  20. {
  21.  
  22. IsDoorGame = true;
  23.  
  24. lightColor = transform.GetChild(0).GetComponent<Light>();
  25. isTimerPlay = true;
  26. audioGame = animation.GetComponent<AudioSource>();
  27.  
  28. }
  29.  
  30.  
  31.  
  32. public void Door()
  33. {
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. if (IsDoorGame)
  41. {
  42.  
  43.  
  44.  
  45. lightColor.color = Color.green;
  46.  
  47. animation[animation.clip.name].speed = 1;
  48. IsDoorGame = false;
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. else
  59. {
  60.  
  61.  
  62. lightColor.color = Color.red;
  63.  
  64. animation[animation.clip.name].speed = -1;
  65. animation[animation.clip.name].time = animation[animation.clip.name].length;
  66. IsDoorGame = true;
  67.  
  68.  
  69. }
  70.  
  71. if (isTimerPlay)
  72. {
  73.  
  74.  
  75. audioGame.Play();
  76.  
  77. animation.Play();
  78.  
  79. isTimerPlay = false;
  80.  
  81.  
  82.  
  83.  
  84. }
  85.  
  86.  
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement