using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// 
/// 检查接线完好
/// 
public class Check_JieXian : PermanentTriggerBase
{
    /// 
    /// 是否已检查接线完好
    /// 
    public bool isChecked;
    /// 
    /// 接线
    /// 
    public List tool_Lines;
    /// 
    /// 接线螺丝
    /// 
    public List tool_Screws;
    protected override void OnStart()
    {
        base.OnStart();
        tool_Screws.ForEach(screw => 
        {
            screw.AddCheckAction(() => 
            {
                //接线螺丝要先点击检查接线
                return isChecked;
            });
        });
    }
    protected override void OnMEnter()
    {
        base.OnMEnter();
        _highlight.SetHighlighted(true);
    }
    protected override void OnMDown()
    {
        base.OnMDown();
        if (tool_Lines.TrueForAll(a => a.isConnected) && tool_Screws.TrueForAll(a => a.isInstall))
        {
            Invoke("Check", 1);
        }
    }
    protected override void OnMExit()
    {
        base.OnMExit();
        _highlight.SetHighlighted(false);
    }
    /// 
    /// 检查成功
    /// 
    public void Check()
    {
        if (GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
        {
            Debug.Log("接线完好");
            isChecked = true;
            GetComponent().enabled = false;
            if (GameManager.UIMgr != null)
            {
                GameObject tip2 = Instantiate(Resources.Load("UI/UI_Tip/TipPanel"), GameManager.UIMgr.canvas.transform);
                TipPanel tipPanel = tip2.GetComponent();
                tipPanel.Init("接线完好!");
            }
            //GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(triggerName, true);
            base.CallScoreAction(true);
        }
    }
}