using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using AX.NetworkSystem;

/// <summary>
/// 登录大厅需提供的数据类
/// </summary>
public class UserData
{
    public User UserInfo;
    public Role Role;//角色名
    public Organization Org;//角色组织机构
    public bool IsReady;//是否准备
}

public class StartController : MonoBehaviour
{
    public UI_Control_ScrollFlow SelectionController;
    private Button StartBtn;
    public Text WrongText;
    private float timmer = 1f;

    void Start()
    {
        StartBtn = GetComponent<Button>();
        StartBtn.onClick.AddListener(
            () =>
            {
                if (GameSettings.othersSettings.mode != Mode.manoeuvre && ArmyDropDownDataBind.IsEmpty)
                {
                    Debug.Log("空选!");
                    WrongText.gameObject.SetActive(true);
                }
                else
                {
                    WrongText.gameObject.SetActive(false);
                    timmer = 1f;
                    Debug.Log(SelectionController.Current.name);
                    CurrentUserInfo.role = SelectionController.Current.GetComponent<UI_Control_ScrollFlow_Item>().role;
                    //SceneManager.LoadScene("Lobby");
                    UserData data = new UserData()
                    {
                        UserInfo = CurrentUserInfo.mySelf,
                        Role = CurrentUserInfo.role,
                        Org = CurrentUserInfo.organization,
                        IsReady = false
                };
                NetworkManager.Default.SendAsync("LOBBY_ENTER_SYNC", data);
            }
            }
            );
    }
void Update()
{
    if (WrongText.gameObject.activeSelf)
    {
        timmer -= Time.deltaTime;
        if (timmer <= 0)
        {
            WrongText.gameObject.SetActive(false);
            timmer = 1f;
        }
    }
}
}