using DG.Tweening; using Sirenix.Utilities; using System.Collections; using System.Collections.Generic; using System.Linq; 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; /// /// 初始化电能表状态(默认是装好的状态不用设置) /// /// public void Init(bool isIntsalledState) { if(isIntsalledState) { Debug.Log("电能表设置为初始状态"); //盖子装上的状态 CoverInstallState(); //封印安装上 CoverSealInstallState(); //接线螺丝全部拧上状态 JieXianScrewInstallState(); //铭牌 namePlate.isChecked = false; //固定螺丝拧上状态 FixScrewInstall(); gameObject.SetActive(true); } else { Debug.Log("电能表设置为拆下状态"); //盖子拆下状态 CoverUnstallState(); //封印拆掉 CoverSealUninstallState(); //接线螺丝拧下状态 JieXianScrewUninstallState(); //固定螺丝拧下状态 FixScrewUninstall(); } } /// /// 盖子取下的状态 /// public void CoverUnstallState() { //盖子拆除 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, -0.1840515f, -0.2512321f); //右螺丝拧下 cover.cover_screw_Right.isInstall = false; cover.cover_screw_Right.transform.localPosition = new Vector3(cover.cover_screw_Right.transform.localPosition.x, -0.1840515f, -0.2512321f); } /// /// 盖子装上的状态 /// public void CoverInstallState() { //盖子盖上 cover.isOpen = false; cover.transform.localPosition = new Vector3(0.0001220703f, 0.01112366f, -0.09854126f); //左螺丝拧上 cover.cover_screw_Left.isInstall = true; cover.cover_screw_Left.transform.localPosition = new Vector3(cover.cover_screw_Left.transform.localPosition.x, -0.01405334f, -0.1012321f); //右螺丝拧上 cover.cover_screw_Right.isInstall = true; cover.cover_screw_Right.transform.localPosition = new Vector3(cover.cover_screw_Right.transform.localPosition.x, -0.01405334f, -0.1012321f); } /// /// 盖子封印装上 /// public void CoverSealInstallState() { //左封印安装 cover.cover_seal_Left.isCut = false; cover.cover_seal_Left.gameObject.SetActive(true); //右封印安装 cover.cover_seal_Right.isCut = false; cover.cover_seal_Right.gameObject.SetActive(true); } /// /// 封印卸载 /// public void CoverSealUninstallState() { //左封印被剪开 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); } /// /// 接线螺丝拧上状态 /// public void JieXianScrewInstallState() { //接线螺丝全部拧上 jieXian_screws.ForEach(a => { a.isInstall = true; a.transform.localPosition = new Vector3(a.transform.localPosition.x, a.initPostionY, a.transform.localPosition.z); }); } /// /// 接线螺丝拧下状态 /// public void JieXianScrewUninstallState() { 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 FixScrewInstall() { //左固定螺丝拧上 fix_screw_left.isInstall = true; fix_screw_left.transform.localPosition = new Vector3(fix_screw_left.transform.localPosition.x, fix_screw_left.initPostionY, fix_screw_left.transform.localPosition.z); //右固定螺丝拧上 fix_screw_right.isInstall = true; fix_screw_right.transform.localPosition = new Vector3(fix_screw_right.transform.localPosition.x, fix_screw_right.initPostionY, fix_screw_right.transform.localPosition.z); } /// /// 固定螺丝拧下 /// public void FixScrewUninstall() { //左固定螺丝拧下 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); } /// /// 拆下电能表 /// public void Remove(Device_Control_1002 device_MeasuringCabinet) { //拆下电能表 if (!fix_screw_left.isInstall && !fix_screw_right.isInstall) { hand_out_action?.Invoke(); device_MeasuringCabinet.meteringDevice = null; Debug.Log("电能表已拆除"); transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() => { CallScoreAction(false); gameObject.SetActive(false); }); } } /// /// 安装电能表 /// public void Add(Device_Control_1002 device_MeasuringCabinet) { transform.parent = device_MeasuringCabinet.transform; device_MeasuringCabinet.meteringDevice = this; transform.GetComponentsInChildren(true).ToList().ForEach(a => a.Awake()); //默认是拆除的状态 Init(false); hand_out_action?.Invoke(); transform.DOLocalMove(new Vector3(0.1469002f, -0.1793365f, 0.5191498f), 2).OnStart(() => { transform.localEulerAngles = Vector3.zero; }).OnComplete(() => { LiveSceneManager.Instance.OnCheckSubProcess(false); Debug.Log("电能表已安装"); CallScoreAction(true); }); } }