59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class Door : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
GameObject cabinet;
|
|
bool isopen = false;
|
|
TextMeshProUGUI TextMeshProUGUI;
|
|
Image Image;
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (isopen)
|
|
{
|
|
GameManager.Inst.power_open(cabinet);
|
|
TextMeshProUGUI.text = "¹ØÃÅ";
|
|
isopen = !isopen;
|
|
}
|
|
else
|
|
{
|
|
GameManager.Inst.power_close(cabinet);
|
|
TextMeshProUGUI.text = "¿ªÃÅ";
|
|
isopen = !isopen;
|
|
}
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
{
|
|
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
TextMeshProUGUI = transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
|
Image = GetComponent<Image>();
|
|
cabinet = transform.parent.parent.parent.gameObject;
|
|
isopen = (cabinet.transform.GetChild(0).rotation != Quaternion.Euler(Vector3.zero));
|
|
if (isopen)
|
|
{
|
|
TextMeshProUGUI.text = "¿ªÃÅ";
|
|
}
|
|
else
|
|
{
|
|
TextMeshProUGUI.text = "¹ØÃÅ";
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|