using DG.Tweening; using Sirenix.Utilities; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 3相4线电能表 /// public class Device_3Phase4WireMeter : Device_Base { /// /// 铭牌 /// public Device_NamePlate namePlate; /// /// 接线盖子 /// public Device_Cover cover; /// /// 电能表固定螺丝左 /// public Tool_Screw fix_screw_left; /// /// 电能表固定螺丝右 /// public Tool_Screw fix_screw_right; /// /// 电能表接线螺丝 /// public List jieXian_screws; private BoxCollider boxCollider; //protected override void OnAwake() //{ // base.OnAwake(); // boxCollider = GetComponent(); // if(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name== "05_LiveScene") // { // boxCollider.enabled = false; // } //} /// /// 初始化电能表状态(默认是装好的状态不用设置) /// /// public void Init(bool isIntsalledState) { if(!isIntsalledState) { Debug.Log("电能表设置为拆下状态"); //盖子拆除 cover.isOpen = true; cover.transform.localPosition = new Vector3(0.0001220703f, -0.1388763f, -0.2485413f); //左螺丝拧下 cover.cover_screw_Left.isInstall = false; cover.cover_screw_Left.transform.localPosition = new Vector3(cover.cover_screw_Left.transform.localPosition.x, cover.cover_screw_Left.initPostionY-0.03f, cover.cover_screw_Left.transform.localPosition.z); //右螺丝拧下 cover.cover_screw_Right.isInstall = false; cover.cover_screw_Right.transform.localPosition = new Vector3(cover.cover_screw_Right.transform.localPosition.x, cover.cover_screw_Right.initPostionY-0.03f, cover.cover_screw_Right.transform.localPosition.z); //左封印被剪开 cover.cover_seal_Left.isCut = true; cover.cover_seal_Left.gameObject.SetActive(false); //右封印被剪开 cover.cover_seal_Right.isCut = true; cover.cover_seal_Right.gameObject.SetActive(false); //左固定螺丝拧下 fix_screw_left.isInstall = false; fix_screw_left.transform.localPosition = new Vector3(fix_screw_left.transform.localPosition.x, fix_screw_left.initPostionY-0.03f, fix_screw_left.transform.localPosition.z); //右固定螺丝拧下 fix_screw_right.isInstall = false; fix_screw_right.transform.localPosition = new Vector3(fix_screw_right.transform.localPosition.x, fix_screw_right.initPostionY-0.03f, fix_screw_right.transform.localPosition.z); //接线螺丝全部拧下 jieXian_screws.ForEach(a => { a.isInstall = false; a.transform.localPosition = new Vector3(a.transform.localPosition.x, a.initPostionY-0.03f, a.transform.localPosition.z); }); } } /// /// 拆下电能表 /// public void Remove() { //拆下电能表 if (!fix_screw_left.isInstall && !fix_screw_right.isInstall) { SiteManager.instance.measuringCabinet.meteringDevice = null; Debug.Log("电能表已拆除"); transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() => { gameObject.SetActive(false); }); } } /// /// 安装电能表 /// public void Add() { transform.parent = SiteManager.instance.measuringCabinet.transform; //默认是拆除的状态 Init(false); transform.DOLocalMove(new Vector3(0.1469002f, -0.1793365f, 0.5191498f), 2).OnStart(() => { transform.localEulerAngles = Vector3.zero; }).OnComplete(() => { SiteManager.instance.measuringCabinet.meteringDevice = this; LiveSceneManager.Instance.currentTool = null; Debug.Log("电能表已安装"); }); } }