46 lines
721 B
C#
46 lines
721 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class DoorOpenClose : MonoBehaviour
|
|
{
|
|
public bool isRunning;
|
|
|
|
private Animation anim;
|
|
|
|
public AudioClip OpenSound;
|
|
|
|
public AudioClip CloseSound;
|
|
|
|
public GameObject Door;
|
|
|
|
public virtual void Awake()
|
|
{
|
|
anim = GetComponent<Animation>();
|
|
}
|
|
|
|
public virtual void OnMouseDown()
|
|
{
|
|
if (!isRunning)
|
|
{
|
|
GetComponent<AudioSource>().PlayOneShot(OpenSound);
|
|
Door.GetComponent<Animation>().Play("Open");
|
|
}
|
|
else
|
|
{
|
|
GetComponent<AudioSource>().PlayOneShot(CloseSound);
|
|
Door.GetComponent<Animation>().Play("Close");
|
|
}
|
|
isRunning = !isRunning;
|
|
}
|
|
|
|
public virtual void playAnim(string s)
|
|
{
|
|
anim.Blend(s);
|
|
}
|
|
|
|
public virtual void Main()
|
|
{
|
|
}
|
|
}
|