Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- public class SecDoor : MonoBehaviour
- {
- public string defName;
- public bool scanning;
- public bool open = false;
- public string macAdress;
- public Light lightIndicator;
- private float originalY;
- public TextMeshPro statusDisplay;
- private int percentage = 0;
- public TextMeshProUGUI taskText;
- public GameObject player;
- public GameObject bioScanArea;
- [SerializeField] private GameObject lowerDoor;
- void Start()
- {
- originalY = transform.position.y;
- defName = transform.name;
- bioScanArea.SetActive(false);
- }
- void Update()
- {
- if(scanning == true)
- {
- lightIndicator.color = Color.yellow;
- transform.tag = "ACTIVE_DOOR";
- transform.name = macAdress;
- }
- else
- {
- transform.tag = "INACTIVE_DOOR";
- transform.name = defName;
- }
- if(open)
- {
- taskText.text = "";
- statusDisplay.text = "Bioscan complete";
- lightIndicator.color = Color.green;
- scanning = false;
- if(transform.position.y < originalY + 5f)
- {
- transform.Translate(Vector3.up * Time.deltaTime, Space.World);
- lowerDoor.transform.Translate(Vector3.down * Time.deltaTime, Space.World);
- }
- }
- }
- public void StartScan()
- {
- StartCoroutine(BIOSCAN());
- }
- public IEnumerator BIOSCAN()
- {
- bioScanArea.SetActive(true);
- while(percentage < 35)
- {
- statusDisplay.text = "Bioscan in progress" + " \n <color=white> [" + percentage + "%] <color=white>";
- yield return new WaitForSeconds(0.2f);
- if(Vector3.Distance(bioScanArea.transform.position, player.transform.position) < 3f)
- {
- percentage++;
- }
- }
- bioScanArea.SetActive(false);
- statusDisplay.text = "Bioscan " + "ERROR <color=red>";
- taskText.text = "Access door from terminal and OVERRIDE it";
- scanning = true;
- yield return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement