120 lines
3.7 KiB
C#
120 lines
3.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using UnityEngine;
|
|
|
|
public class Tool_PowerMeter : Tool_Base
|
|
{
|
|
public Transform plug;
|
|
#region 电源插头
|
|
public List<Transform> linePoints;
|
|
private LineRenderer lineRenderer;
|
|
#endregion
|
|
|
|
#region 档位
|
|
public ClickMoveMore dangwei_RANGE;
|
|
public ClickMoveMore dangwei_FUNCTION;
|
|
public ClickMoveMore dangwei_POWER;
|
|
#endregion
|
|
|
|
#region 天线插座
|
|
public DeviceTrigger ANT_trigger;
|
|
public DeviceTrigger TX_trigger;
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 收回按钮
|
|
/// </summary>
|
|
public DeviceTrigger backBtn;
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
base.OnAwake();
|
|
lineRenderer = GetComponent<LineRenderer>();
|
|
if(GameManager.RunModelMgr.SceneType != E_SceneType.Site)
|
|
{
|
|
lineRenderer.enabled = false;
|
|
backBtn.gameObject.SetActive(false);
|
|
}
|
|
|
|
//安装插头
|
|
ANT_trigger.clickAction += () =>
|
|
{
|
|
Device_SpecializedVariableAcquisitionTerminal ds= GameObject.FindObjectOfType<Device_SpecializedVariableAcquisitionTerminal>();
|
|
if(ds!=null)
|
|
{
|
|
if(ds.plug_tianxian上.isChose)
|
|
{
|
|
ds.plug_tianxian上.Install(ANT_trigger);
|
|
}
|
|
else if(ds.plug_tianxian下.isChose)
|
|
{
|
|
ds.plug_tianxian下.Install(ANT_trigger);
|
|
}
|
|
}
|
|
};
|
|
|
|
//安装插头
|
|
TX_trigger.clickAction += () =>
|
|
{
|
|
Device_SpecializedVariableAcquisitionTerminal ds = GameObject.FindObjectOfType<Device_SpecializedVariableAcquisitionTerminal>();
|
|
if (ds != null)
|
|
{
|
|
if (ds.plug_tianxian上.isChose)
|
|
{
|
|
ds.plug_tianxian上.Install(TX_trigger);
|
|
}
|
|
else if (ds.plug_tianxian下.isChose)
|
|
{
|
|
ds.plug_tianxian下.Install(TX_trigger);
|
|
}
|
|
}
|
|
};
|
|
|
|
//收回功率计
|
|
backBtn.clickAction += () =>
|
|
{
|
|
Device_SpecializedVariableAcquisitionTerminal ds = GameObject.FindObjectOfType<Device_SpecializedVariableAcquisitionTerminal>();
|
|
if (ds != null)
|
|
{
|
|
//还插着天线,不能收回功率计
|
|
if (ds.plug_tianxian上.currentInstalledTrigger == ANT_trigger || ds.plug_tianxian上.currentInstalledTrigger == TX_trigger ||
|
|
ds.plug_tianxian下.currentInstalledTrigger == ANT_trigger || ds.plug_tianxian下.currentInstalledTrigger == TX_trigger)
|
|
{
|
|
TipPanel.ShowTip("请先拆除连接功率计的天线");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(backBtn.triggerName, true) == 0)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 功率计电源插头插上
|
|
/// </summary>
|
|
/// <param name="device_Socket"></param>
|
|
public void AddSocket(Device_Socket device_Socket)
|
|
{
|
|
plug.parent = device_Socket.transform;
|
|
plug.localPosition = new Vector3(-0.0001296997f, -0.02799988f, -0.03293025f);
|
|
plug.localEulerAngles = new Vector3(0, 0, 180);
|
|
plug.parent = transform;
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
//连线
|
|
List<Vector3> tmps = new List<Vector3>();
|
|
linePoints.ForEach(p => { tmps.Add(p.position); });
|
|
lineRenderer.startWidth = 0.0025f;
|
|
lineRenderer.endWidth = 0.0025f;
|
|
lineRenderer.positionCount = tmps.Count;
|
|
lineRenderer.SetPositions(tmps.ToArray());
|
|
}
|
|
}
|