- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Gate : MonoBehaviour
- {
- [SerializeField]
- private GameObject gate;
- private Vector3 openPos;
- private Vector3 originPos;
- private ConditionCkecker cc;
- private float timer = 1;
- int a = 0;
-
- public bool isOpening = false;
- private bool ready;
- private bool andConditions;
-
- void Start()
- {
-
- openPos = new Vector3(gate.transform.position.x,gate.transform.position.y + 5, gate.transform.position.z);
- originPos = gate.transform.position;
- cc = GetComponent<ConditionCkecker>();
-
- }
-
- private void Update()
- {
- if (timer > 0) timer -= Time.deltaTime;
- else { ready = cc.CheckConditions(); andConditions = cc.AND(); timer = 1; }
- if (!andConditions) isOpening = false;
- if (ready)
- {
-
- if (gate.transform.position == originPos) { isOpening = true; }
- }
- if (isOpening)
- {
-
- gate.transform.position = Vector3.MoveTowards(gate.transform.position, openPos, Time.deltaTime);
- }
- else gate.transform.position = Vector3.MoveTowards(gate.transform.position, originPos, Time.deltaTime);
- }
- }