using System;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;

namespace WS
{
    public class ShowViewOperateComponent : OperateComponent<ShowViewOperateData>
    {
        public override void Init()
        {

        }

        public override void StartOperate()
        {
            var guideView = FacadeComponent.Instance.GetController<GuideController>();
            if (guideView == null)
            {
                guideView = FacadeComponent.Instance.CreateController<GuideController>();
                guideView.OpenView();
            }
            guideView.SetView(OperateData.imageName, OperateData.audioName, OperateData.showPos, Quaternion.Euler(OperateData.rotation));

            if (OperateData.isEnd)
            {
                guideView.SetEndBtnStatus(true);
            }
            IsComplete = true;
        }

        public override void Update()
        {
        }
        public override Task StartState()
        {

            IsComplete = false;
            return Task.CompletedTask;
        }
        public override Task EndState()
        {

            IsComplete = true;
            return Task.CompletedTask;
        }
        public override void Dispose()
        {
            base.Dispose();

        }
    }
    public class ShowViewOperateData
    {
        /// <summary> 显示位置 </summary>
        public Vector3 showPos;
        /// <summary> 显示旋转 </summary>
        public Vector3 rotation;
        /// <summary> 显示图片 </summary>
        public string imageName;
        /// <summary> 音频名称 </summary>
        public string audioName;
        /// <summary> 是否流程结束 </summary>
        public bool isEnd;
    }
}
