using UnityEngine;
using System.Collections.Generic;


public class MainMenuView : MonoBehaviour
{
    public Transform _Transform;
    public Dictionary<FlickDirection, Sprite> FlickSpritePairs { get; } = new Dictionary<FlickDirection, Sprite>();
    public NotePoolManager NotePool { get; private set; } = new NotePoolManager();
    //主界面UI的引用
    public TopPanelView TopPanel { get; private set; }
    public LeftPanelView LeftPanel { get; private set; }
    public ProgressBarView ProgressBar { get; private set; }
    //可游玩物体的预制件引用
    public NoteController NotePrefab { get; private set; }
    public DragController DragPrefab { get; private set; }
    public FlickController FlickPrefab { get; private set; }
    public DataFlowController DataFlowPrefab { get; private set; }
    public LandMineController LandMinePrefab { get; private set; }
    //装饰物件的预制件引用
    public BeatLinesController BeatLinesPrefab { get; private set; }
    //右键窗口的预制件引用
    public GeneralOptionPanelController GeneralOptionPanel { get; private set; }
    public BuildingOptionPanelController BuildingOptionPanel { get; private set; }
    //主界面引导物体的引用
    public SelectView MainMenuSelectView { get; private set; }
    private void Awake()
    {
        _Transform = gameObject.GetComponent<Transform>();

        LoadDirationSprites();
        LoadPlayObjectViewPrefab();
        LoadDecorateObject();
        LoadRightClickDialogWindow();

        FindPenalView();
        LoadGuides();
    }
    /// <summary>
    /// 获得各个面板UI的引用
    /// </summary>
    private void FindPenalView()
    {
        TopPanel = _Transform.Find("TopPanel").GetComponent<TopPanelView>();
        LeftPanel = _Transform.Find("LeftPanel").GetComponent<LeftPanelView>();
        ProgressBar =_Transform.Find("ProgressBar").GetComponent<ProgressBarView>();    
    }
    /// <summary>
    /// 用于加载所有可游玩物件的视觉物件
    /// </summary>
    private void LoadPlayObjectViewPrefab()
    {
        NotePrefab = Resources.Load<NoteController>("NotePrefabs/note");
        DragPrefab = Resources.Load<DragController>("NotePrefabs/Drag");
        FlickPrefab = Resources.Load<FlickController>("NotePrefabs/Flick");
        DataFlowPrefab = Resources.Load<DataFlowController>("NotePrefabs/DataFlow");
        LandMinePrefab = Resources.Load<LandMineController>("NotePrefabs/LandMine");

    }
    /// <summary>
    /// 用于加载FLick所有方向贴图
    /// </summary>
    private void LoadDirationSprites()
    {
        FlickSpritePairs.Add(FlickDirection.Any, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_0"));
        FlickSpritePairs.Add(FlickDirection.Up, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_1"));
        FlickSpritePairs.Add(FlickDirection.RightUp, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_2"));
        FlickSpritePairs.Add(FlickDirection.Right, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_3"));
        FlickSpritePairs.Add(FlickDirection.RightDown, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_4"));
        FlickSpritePairs.Add(FlickDirection.Down, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_5"));
        FlickSpritePairs.Add(FlickDirection.LeftDown, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_6"));
        FlickSpritePairs.Add(FlickDirection.Left, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_7"));
        FlickSpritePairs.Add(FlickDirection.LeftUp, Resources.Load<Sprite>("NoteSprites/AllFlick/AllFlick_8"));
    }
    /// <summary>
    /// 加载其他用于装饰的游玩物件
    /// </summary>
    private void LoadDecorateObject()
    {
        BeatLinesPrefab = Resources.Load<BeatLinesController>("ObjectPrefabs/BeatLine");
    }
    /// <summary>
    /// 加载右键的窗口
    /// </summary>
    private void LoadRightClickDialogWindow()
    {
        GeneralOptionPanel = Resources.Load<GeneralOptionPanelController>("PanelPrefabs/GeneralOptionPanel");
        BuildingOptionPanel = Resources.Load<BuildingOptionPanelController>("PanelPrefabs/BuildingOptionPanel");
    }
    private void LoadGuides()
    {
        MainMenuSelectView = Resources.Load<SelectView>("GuidesPerfabs/Select");
    }
}