This repository has been archived on 2024-06-19. You can view files and clone it, but cannot push or open issues or pull requests.
evermillion/Assets/Brick Project Studio/Apartment Kit/Common/Scripts & Animation/Windows/opencloseWindowApt.cs
2024-06-05 11:10:54 +08:00

72 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SojaExiles
{
public class opencloseWindowApt : MonoBehaviour
{
public Animator openandclosewindow;
public bool open;
public Transform Player;
void Start()
{
open = false;
}
void OnMouseOver()
{
{
if (Player)
{
float dist = Vector3.Distance(Player.position, transform.position);
if (dist < 15)
{
if (open == false)
{
if (Input.GetMouseButtonDown(0))
{
StartCoroutine(opening());
}
}
else
{
if (open == true)
{
if (Input.GetMouseButtonDown(0))
{
StartCoroutine(closing());
}
}
}
}
}
}
}
IEnumerator opening()
{
print("you are opening the Window");
openandclosewindow.Play("Openingwindow");
open = true;
yield return new WaitForSeconds(.5f);
}
IEnumerator closing()
{
print("you are closing the Window");
openandclosewindow.Play("Closingwindow");
open = false;
yield return new WaitForSeconds(.5f);
}
}
}