75 lines
1.7 KiB
C#
75 lines
1.7 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class GuideUI : UIPanelBase
|
||
|
{
|
||
|
[HideInInspector]
|
||
|
private GameObject _guide;
|
||
|
|
||
|
public GudieAnimationManager GuideMgr => _guide.GetComponent<GudieAnimationManager>();
|
||
|
private void Awake()
|
||
|
{
|
||
|
_guide = GameObject.FindWithTag("Guide");
|
||
|
if (_guide == null)
|
||
|
{
|
||
|
Debug.LogError("Guide is null");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OnEnable()
|
||
|
{
|
||
|
EventManager.Instance.AddEventListener("PlayAnimation", PlayAnimation);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
private void OnDisable()
|
||
|
{
|
||
|
EventManager.Instance.RemoveEventListener("PlayAnimation", PlayAnimation);
|
||
|
}
|
||
|
|
||
|
#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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#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("PlayAnimation", AvatarAction.HeadTurnLeft);
|
||
|
}
|
||
|
}
|