65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using DG.Tweening;
|
|
using HighlightPlus;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// ÆÕͨÃÅ
|
|
/// </summary>
|
|
public class Door : MonoBehaviour
|
|
{
|
|
public bool isOpen;
|
|
public ZhouEnum zhouEnum;
|
|
public float angele;
|
|
public float duration;
|
|
|
|
|
|
Dictionary<bool, Vector3> dic;
|
|
[SerializeField]
|
|
private Vector3 initR;
|
|
[SerializeField]
|
|
private Vector3 nextR;
|
|
|
|
private HighlightEffect highlightEffect;
|
|
|
|
private void Awake()
|
|
{
|
|
GetEndAngle();
|
|
highlightEffect = GetComponent<HighlightEffect>();
|
|
}
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
isOpen = !isOpen;
|
|
transform.DOLocalRotate(dic[isOpen], duration);
|
|
}
|
|
private void OnMouseEnter()
|
|
{
|
|
highlightEffect.SetHighlighted(true);
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
highlightEffect.SetHighlighted(false);
|
|
}
|
|
|
|
private void GetEndAngle()
|
|
{
|
|
initR = transform.localEulerAngles;
|
|
transform.Rotate(new Vector3(zhouEnum == ZhouEnum.X ? 1 : 0, zhouEnum == ZhouEnum.Y ? 1 : 0, zhouEnum == ZhouEnum.Z ? 1 : 0), angele, Space.Self);
|
|
nextR = transform.localEulerAngles;
|
|
transform.localEulerAngles = initR;
|
|
|
|
dic = new Dictionary<bool, Vector3>();
|
|
dic.Add(isOpen, initR);
|
|
dic.Add(!isOpen, nextR);
|
|
}
|
|
}
|
|
public enum ZhouEnum
|
|
{
|
|
X,
|
|
Y,
|
|
Z
|
|
}
|