blob: cb0776239d447c292f6f1d5f65ecce9785e017c8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using Random = UnityEngine.Random;
public class OneWayDoorBehaviour : MonoBehaviour
{
[Header("绑定")]
public Transform door;
public GameObject messageHint;
public bool lockId;
[HideInInspector] public int doorAngleStoreId;
public float Angle => Mathf.Round(door.localRotation.eulerAngles.y);
public float AnglePercent => Mathf.Clamp01(Angle / 90);
public bool IsOpened => Angle > 25;
private void Reset()
{
doorAngleStoreId = Random.Range(0, 65535);
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
private void FixedUpdate()
{
// 如果门打开,就关闭消息提示
messageHint.SetActive(! IsOpened);
}
private void Awake()
{
var angle = HermesOnDisk.HermesOnDisk.Float[(uint)doorAngleStoreId];
door.localRotation = Quaternion.Euler(0, angle, 0);
}
private void OnDisable()
{
HermesOnDisk.HermesOnDisk.Float[(uint)doorAngleStoreId] = Angle;
}
}
|