using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using XFrame.Core.UI;

public class Main_interface_Panel : XUIPanel
{
    public static Button fanhui_btn;//返回初始界面
    public Button train;
    public Button replay;
    public Button appQuet;
    public Text accountName;
    public Main_interface_Panel() : base(UIType.Fixed, UIMode.None, UICollider.None)
    {
        uiPath = "UIPanel/Main_interface_Panel";
    }
    public override void Awake(GameObject go)
    {
        replay = this.transform.Find("UPBG/double_quotation_btn").GetComponent<Button>();
        train = this.transform.Find("UPBG/training_task_btn").GetComponent<Button>();
        appQuet = this.transform.Find("UPBG/Power_Off_btn").GetComponent<Button>();
        fanhui_btn = this.transform.Find("UPBG/Back_bton").GetComponent<Button>();
        fanhui_btn.onClick.AddListener(() =>
        {
            UIBootstrap.Instance.OnLogout();
            SceneManager.LoadScene("SampleScene");
        });
        ShowPanel<View_Panel2>();
       
        replay.onClick.AddListener(() => { ReplayPanel(); });
        train.onClick.AddListener(() => { TrainPanel(); });
        appQuet.onClick.AddListener(() => { Application.Quit();
            //Debug.Log("退出");
        });
        accountName = this.transform.Find("UPBG/avatar_btn/Text").GetComponent<Text>();
        accountName.text = GlobalFlag.currentUser.login_name;
    }

    /// <summary>
    /// 训练界面控制
    /// </summary>
    public void TrainPanel()
    {
        //ClosePanel<ReplayPanel>();
        ClosePanel<DoublePlay>();
        //ClosePanel<IntroducePanel>();
        ShowPanel<View_Panel2>();
    }
    /// <summary>
    /// 复盘回放界面控制
    /// </summary>
    public void ReplayPanel()
    {
        //ShowPanel<ReplayPanel>();
        ShowPanel<DoublePlay>();
        ClosePanel<View_Panel2>();
    }
}