using AX.InputSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ShowFightDeployWin : BaseToggle
{
    private void Awake()
    {
        transform.parent.Find("NumImage").gameObject.SetActive(false);
    }

    public override void OnEnable()
    {
        base.OnEnable();

        //再到场之前接收过作战部署消息,到场后显示消息提醒
        if (GameObject.Find("Canvas").GetComponent<FIREDEPLOY_SYNC>().fireDepolySYNCInfo != null)
        {//到场之前接收过作战部署消息,到场后fireDepolySYNCInfo不为null
            transform.parent.Find("NumImage").gameObject.SetActive(true);
        }
    }

    public override void RespondFun(bool value)
    {
        //显示作战部署窗口
        if (value)
        {
            GameObject.Find("Canvas").transform.Find("OperationalPreparations").gameObject.SetActive(true);

            GameObject.Find("Canvas/OperationalPreparations/Clonse").GetComponent<FireDeployClose>().gameObjId = 
                transform.GetComponent<BaseGameObjInfo>().gameObjID;

            //打开时隐藏作战部署消息提醒标识
            transform.parent.Find("NumImage").gameObject.SetActive(false);

            //打开作战部署窗口时,自动取消场景中物体的选中,
            //避免删除作战部署图标时,也会删除场景中选中物体,且造成删除作战部署图标报数据类型错误(因用的一样的删除命令)
            if (SelectedObjs.selectedObj || SelectedObjs.selectedCharacters.Count != 0)
            {
                CancelSelectedCommand.Instance.Execute(0, new CmdArgs());
            }
        }
        else
        {
            //关掉作战部署面板时,需要重置克隆类型,
            //避免造成InputManager中cloneObjType == CloneObjType.None情况下几个方法的执行
            InputManager.cloneObjType = CloneObjType.None;

            GameObject.Find("Canvas/OperationalPreparations/Clonse").GetComponent<FireDeployClose>().gameObjId = -1;

            GameObject.Find("Canvas").transform.Find("OperationalPreparations").gameObject.SetActive(false);
        }
    }
}