forked from zxl/LaboratoryProtection
31 lines
726 B
C#
31 lines
726 B
C#
|
using System;
|
|||
|
using Mono.Event;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace UnityTest.ZXL
|
|||
|
{
|
|||
|
public class Door : MonoBehaviour
|
|||
|
{
|
|||
|
private bool isOpen;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
EventManager.Instance.Subscribe(DoorEventArgs.EventId, DoorEvent);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
EventManager.Instance.Unsubscribe(DoorEventArgs.EventId, DoorEvent);
|
|||
|
}
|
|||
|
|
|||
|
private void DoorEvent(object sender, GameEventArgs e)
|
|||
|
{
|
|||
|
var args = e as DoorEventArgs;
|
|||
|
|
|||
|
if (args.isOpen)
|
|||
|
transform.localEulerAngles = new Vector3(0, 90, 0);
|
|||
|
else
|
|||
|
transform.localEulerAngles = Vector3.zero;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|