| | | 1 | | using System; |
| | | 2 | | using System.Collections; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using UnityEngine; |
| | | 5 | | using UnityEngine.Events; |
| | | 6 | | |
| | | 7 | | public class CheckElements : MonoBehaviour |
| | | 8 | | { |
| | | 9 | | [SerializeField] private int numberOfElements; //3 |
| | 9 | 10 | | private int numberOfElementsInSocket = 0; |
| | | 11 | | |
| | 9 | 12 | | [SerializeField] bool cursorActive = true; |
| | | 13 | | |
| | | 14 | | [Header("Unity Events")] |
| | | 15 | | public UnityEvent unlock; |
| | | 16 | | public UnityEvent hideTaskDescription; |
| | | 17 | | public UnityEvent showNextLevelUI; |
| | | 18 | | |
| | | 19 | | [Header("UI Components")] |
| | | 20 | | [SerializeField] Canvas nextLevelUI; |
| | | 21 | | [SerializeField] Canvas taskDescription; |
| | | 22 | | |
| | | 23 | | |
| | | 24 | | private void Start() |
| | 8 | 25 | | { |
| | 8 | 26 | | if (cursorActive) |
| | 8 | 27 | | { |
| | 8 | 28 | | Cursor.lockState = CursorLockMode.Locked; |
| | 8 | 29 | | Cursor.visible = false; |
| | 8 | 30 | | } |
| | 8 | 31 | | } |
| | | 32 | | |
| | | 33 | | |
| | | 34 | | public void AddElementInSocket() |
| | 12 | 35 | | { |
| | 12 | 36 | | numberOfElementsInSocket++; |
| | 12 | 37 | | CheckNumberOfElements(); |
| | 12 | 38 | | } |
| | | 39 | | |
| | | 40 | | private void CheckNumberOfElements() |
| | 12 | 41 | | { |
| | 12 | 42 | | if (numberOfElementsInSocket == numberOfElements) |
| | 2 | 43 | | { |
| | 2 | 44 | | hideTaskDescription.Invoke(); |
| | 2 | 45 | | showNextLevelUI.Invoke(); |
| | 2 | 46 | | unlock.Invoke(); |
| | 2 | 47 | | } |
| | 12 | 48 | | } |
| | | 49 | | } |