GQ_Communicate/GQ_URP/GQ/Assets/Scripts/WJ/LineGroup/LineItem.cs

121 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.UI;
using static PortQuery;
public class LineItem : MonoBehaviour
{
public LineGroupItem lineGroupItem;
public string id;
public Text info_text;
public Text item_tittle_start_text;
public Text item_tittle_end_text;
public Button delete_button;
public Button set_button;
bool do_init = false;
public LineItem(string _id, Text _info_text, Button _delete_button, Button _set_button, bool isgo = false)
{
if (isgo)
{
id = _id;
info_text = _info_text;
delete_button = _delete_button;
set_button = _set_button;
}
}
private void OnEnable()
{
var g = GameManager.Inst.FindParent(gameObject, GameManager.Inst.IsFindLineGroupItem);
if (g != null && !lineGroupItem)
lineGroupItem = g.GetComponent<LineGroupItem>();
}
// Start is called before the first frame update
void Start()
{
if (!do_init)
Init();
}
public void Init()
{
do_init = true;
if (set_button)
set_button.onClick.AddListener(() =>
{
LineGroupManager.Instance.panel_object.SetActive(false);
Debug.Log("ÐÞ¸Ä");
//ÅжÏÆðʼ¶Ë¿Ú
LocatingCable locatingCable = GetComponent<LocatingCable>();
PortQuery p = new PortQuery();
if (locatingCable.lines[0].GetComponent<PortQuery>().portList.startFlag == 1)
{
p = locatingCable.lines[0].GetComponent<PortQuery>();
GameManager.Inst.nowDevice = locatingCable.lines[0].gameObject;
RedactPort.Inst.PortList1_game = locatingCable.lines[0].gameObject;
RedactPort.Inst.PortList2 = locatingCable.lines[1].GetComponent<PortQuery>().portList;
RedactPort.Inst.PortList2_game = locatingCable.lines[1].gameObject;
}
else
{
p = locatingCable.lines[1].GetComponent<PortQuery>();
GameManager.Inst.nowDevice = locatingCable.lines[1].gameObject;
RedactPort.Inst.PortList1_game = locatingCable.lines[1].gameObject;
RedactPort.Inst.PortList2 = locatingCable.lines[0].GetComponent<PortQuery>().portList;
RedactPort.Inst.PortList2_game = locatingCable.lines[0].gameObject;
}
GameManager.Inst.nowDeviceID = p.portList.id;
RedactPort.Inst.PortList1 = p.portList;
RedactPort.Inst.deviceName_dic.Add(RedactPort.Inst.PortList1.deviceName, RedactPort.Inst.PortList1.id);
RedactPort.Inst.conDevice_dic.Add(RedactPort.Inst.PortList2.deviceName, RedactPort.Inst.PortList2.id);
RedactPort.Inst.OnToggleChanged(RedactPort.Inst.toggle);
var _PortList2 = RedactPort.Inst.PortList2;// ¼Ç¼P2Êý¾Ý
RedactPort.Inst.PortList2 = null;// ΪÁËÈÃP2×Ô¶¯»ñÈ¡£¬ÏÈÖÿÕ
RedactPort.Inst.AutoShowInfo(p, true);
PatternChoose.Inst.dk_bj_page.SetActive(true);
RedactPort.Inst.PortList2 = _PortList2;
GameManager.Inst.portOpenFlashing(locatingCable.lines[0].gameObject, locatingCable.lines[1].gameObject);
});
delete_button.onClick.AddListener(() =>
{
//ɾ³ýÈ·ÈÏ
SecondConfirmPanel.DeleteConform((delete) =>
{
if (delete)
{
//LineGroupItem lineGroup = transform.parent.parent.GetComponent<LineGroupItem>();
//LineQuery.Inst.deleteCableName(lineGroupItem.info_text.text, info_text.text, (x) =>
LineQuery.Inst.deleteCableName(GetComponent<LocatingCable>(), (x) =>
{
if (!string.IsNullOrEmpty(x))
{
LineObjectPool.Instance.PushItemToPool(this);
}
else
{
Debug.Log("¶Ë¿ÚIDΪ¿Õ");
}
});
}
});
});
}
/// <summary>
/// Çå³ý×ÔÉíÐÅÏ¢ÒÔ¹©Ï´ÎʹÓÃ
/// </summary>
public void Clear()
{
id = string.Empty;
info_text.text = string.Empty;
lineGroupItem = null;
}
}