91 lines
2.4 KiB
C#
91 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class GuideUI : UIPanelBase
|
|
{
|
|
private GameObject _guide;
|
|
private Animator _effectAnimator;
|
|
|
|
public GudieAnimationManager GuideMgr => _guide.GetComponent<GudieAnimationManager>();
|
|
private void Awake()
|
|
{
|
|
_guide = GameObject.FindWithTag("Guide");
|
|
if (_guide == null)
|
|
{
|
|
Debug.LogError("Guide is null");
|
|
}
|
|
|
|
_effectAnimator = transform.Find("Content").GetComponentInChildren<Animator>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
EventManager.Instance.AddEventListener("PlayAnimation", PlayAnimation);
|
|
EventManager.Instance.AddEventListener("ActionSuccess", ShowSuccessEffect);
|
|
EventManager.Instance.AddEventListener("ActionFailed", ShowFailEffect);
|
|
}
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
{
|
|
EventManager.Instance.RemoveEventListener("PlayAnimation", PlayAnimation);
|
|
EventManager.Instance.RemoveEventListener("ActionSuccess", ShowSuccessEffect);
|
|
EventManager.Instance.RemoveEventListener("ActionFailed", ShowFailEffect);
|
|
}
|
|
|
|
#region Event Func
|
|
private void PlayAnimation(params object[] args)
|
|
{
|
|
var animeType = args.FirstOrDefault();
|
|
if (animeType == null)
|
|
{
|
|
Debug.LogError("PlayAnimation animeType is null");
|
|
return;
|
|
}
|
|
|
|
switch ((AvatarAction)animeType)
|
|
{
|
|
case AvatarAction.HeadTurnLeft:
|
|
GuideMgr.Play("HeadTurnLeft");
|
|
break;
|
|
case AvatarAction.HeadTurnRight:
|
|
GuideMgr.Play("HeadTurnRight");
|
|
break;
|
|
default:
|
|
GuideMgr.Play("Idle");
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void ShowFailEffect()
|
|
{
|
|
_effectAnimator.Play("WindowEffectError", 0, 0f);
|
|
}
|
|
|
|
private void ShowSuccessEffect()
|
|
{
|
|
_effectAnimator.Play("WindowEffectCorrect", 0, 0f);
|
|
}
|
|
#endregion
|
|
|
|
|
|
public override void Init(object[] pageData)
|
|
{
|
|
base.Init(pageData);
|
|
if (_guide == null)
|
|
_guide = GameObject.FindWithTag("Guide");
|
|
}
|
|
|
|
public override void OnEnter()
|
|
{
|
|
base.OnEnter();
|
|
_guide.SetActive(true);
|
|
EventManager.Instance.Dispatch("StartMotionCapture");
|
|
EventManager.Instance.Dispatch("PlayAnimation", AvatarAction.HeadTurnLeft);
|
|
}
|
|
}
|