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 WorkDoor : MonoBehaviour
- {
- bool IsDoorGame;
- public bool isTimerPlay;
- [SerializeField] Animation animation;
- Light lightColor;
- public AudioSource audioGame;
- public int id = 0;
- private void Start()
- {
- IsDoorGame = true;
- lightColor = transform.GetChild(0).GetComponent<Light>();
- isTimerPlay = true;
- audioGame = animation.GetComponent<AudioSource>();
- }
- public void Door()
- {
- if (IsDoorGame)
- {
- lightColor.color = Color.green;
- animation[animation.clip.name].speed = 1;
- IsDoorGame = false;
- }
- else
- {
- lightColor.color = Color.red;
- animation[animation.clip.name].speed = -1;
- animation[animation.clip.name].time = animation[animation.clip.name].length;
- IsDoorGame = true;
- }
- if (isTimerPlay)
- {
- audioGame.Play();
- animation.Play();
- isTimerPlay = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement