| | | 1 | | using System; |
| | | 2 | | using System.Collections; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using UnityEngine; |
| | | 5 | | using UnityEngine.Events; |
| | | 6 | | |
| | | 7 | | public class LoopManager : MonoBehaviour |
| | | 8 | | { |
| | | 9 | | public GameObject key; |
| | | 10 | | public GameObject spotlight; |
| | | 11 | | |
| | 2 | 12 | | [SerializeField] private int outsideState = 0; //used to keep track of which piece is put in the outside socket |
| | 2 | 13 | | [SerializeField] private int insideState = 0; //used to keep track of which piece is put in the inside socket |
| | | 14 | | |
| | 2 | 15 | | private bool showShort = false; |
| | 2 | 16 | | private float ifTimer = 0; |
| | | 17 | | |
| | | 18 | | private void Start() |
| | 1 | 19 | | { |
| | 1 | 20 | | key.SetActive(false); |
| | 1 | 21 | | spotlight.SetActive(false); |
| | 1 | 22 | | } |
| | | 23 | | |
| | | 24 | | private void Update() |
| | 2735 | 25 | | { |
| | 2735 | 26 | | if (showShort) |
| | 0 | 27 | | { |
| | 0 | 28 | | ifTimer -= Time.deltaTime; |
| | 0 | 29 | | if(ifTimer < 0) |
| | 0 | 30 | | { |
| | 0 | 31 | | showShort = false; |
| | | 32 | | //turn off key and light |
| | 0 | 33 | | key.SetActive(false); |
| | 0 | 34 | | spotlight.SetActive(false); |
| | 0 | 35 | | } |
| | 0 | 36 | | } |
| | 2735 | 37 | | } |
| | | 38 | | |
| | | 39 | | internal void outsideWhile() |
| | 1 | 40 | | { |
| | 1 | 41 | | outsideState = 1; //state 1 means function will run constantly, eg. key will show permanently |
| | 1 | 42 | | } |
| | | 43 | | |
| | | 44 | | internal void outsideIf() |
| | 1 | 45 | | { |
| | 1 | 46 | | outsideState = 2; //state 2 means function will run 1 time, eg. key will show for short burst of time |
| | 1 | 47 | | } |
| | | 48 | | |
| | | 49 | | internal void outsideRemoved() |
| | 1 | 50 | | { |
| | 1 | 51 | | outsideState = 0; //state 0 means running function will do nothing |
| | 1 | 52 | | } |
| | | 53 | | internal void insideKey() |
| | 1 | 54 | | { |
| | 1 | 55 | | insideState = 1; //state 1 means the key will show depending on outside state |
| | 1 | 56 | | } |
| | | 57 | | |
| | | 58 | | internal void insideLight() |
| | 1 | 59 | | { |
| | 1 | 60 | | insideState = 2; //state 2 means light will be turned on depending on outside state |
| | 1 | 61 | | } |
| | | 62 | | |
| | | 63 | | internal void insideRemoved() |
| | 1 | 64 | | { |
| | 1 | 65 | | insideState = 0; //state 0 does nothing |
| | 1 | 66 | | } |
| | | 67 | | |
| | | 68 | | public void ButtonPressed() |
| | 1 | 69 | | { |
| | 1 | 70 | | key.SetActive(false); |
| | 1 | 71 | | spotlight.SetActive(false); |
| | 1 | 72 | | if(outsideState != 0) |
| | 0 | 73 | | { |
| | 0 | 74 | | if (insideState == 1) |
| | 0 | 75 | | { |
| | 0 | 76 | | key.SetActive(true); |
| | 0 | 77 | | } else if (insideState == 2) |
| | 0 | 78 | | { |
| | 0 | 79 | | spotlight.SetActive(true); |
| | 0 | 80 | | } |
| | | 81 | | |
| | 0 | 82 | | if (outsideState == 2) |
| | 0 | 83 | | { |
| | 0 | 84 | | showShort = true; |
| | 0 | 85 | | ifTimer = 1; |
| | 0 | 86 | | } |
| | 0 | 87 | | } |
| | 1 | 88 | | } |
| | | 89 | | } |