62 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| using DG.Tweening;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| 
 | |
| /// <summary>
 | |
| /// 柜门
 | |
| /// </summary>
 | |
| public class Device_CabinetDoor : Device_Base
 | |
| {
 | |
|     /// <summary>
 | |
|     /// 验电位置
 | |
|     /// </summary>
 | |
|     public Transform testPosAndRot;
 | |
|     /// <summary>
 | |
|     /// 是否打开
 | |
|     /// </summary>
 | |
|     public bool isOpen;
 | |
|     /// <summary>
 | |
|     /// 是否带点
 | |
|     /// </summary>
 | |
|     public bool hasElectricity;
 | |
|     public void Open()
 | |
|     {
 | |
|         Debug.Log("开门");
 | |
|         //开锁
 | |
|         transform.Find("计量柜锁2/计量柜锁3").DOLocalRotate(new Vector3(-45f, 0, 0), 1).OnComplete(() => 
 | |
|         {
 | |
|             //开门
 | |
|             transform.DOLocalRotate(new Vector3(0, 0, 180), 3).OnComplete(() =>
 | |
|             {
 | |
|                 isOpen = true;
 | |
|             });
 | |
|         });
 | |
|     }  
 | |
|     public void Close()
 | |
|     {
 | |
|         Debug.Log("关门");
 | |
|         //关门
 | |
|         transform.DOLocalRotate(new Vector3(0,0,0), 3).OnComplete(() =>
 | |
|         {
 | |
|             //关锁
 | |
|             transform.Find("计量柜锁2/计量柜锁3").DOLocalRotate(new Vector3(0, 0, 0), 1).OnComplete(() => 
 | |
|             {
 | |
|                 isOpen = false;
 | |
|             });
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     private void OnMouseDown()
 | |
|     {
 | |
|         if(isOpen)
 | |
|         {
 | |
|             Close();
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             Open();
 | |
|         }
 | |
|     }
 | |
| }
 |