2023-11-07 13:55:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2023-11-07 17:51:34 +00:00
|
|
|
|
using TMPro;
|
2023-11-07 13:55:35 +00:00
|
|
|
|
using UnityEngine;
|
2023-11-07 17:51:34 +00:00
|
|
|
|
using UnityEngine.UI;
|
2023-11-07 13:55:35 +00:00
|
|
|
|
|
|
|
|
|
public class GuideUI : UIPanelBase
|
|
|
|
|
{
|
|
|
|
|
private GameObject _guide;
|
2023-11-07 15:28:19 +00:00
|
|
|
|
private Animator _effectAnimator;
|
2023-11-07 17:51:34 +00:00
|
|
|
|
private Transform _content;
|
2023-11-07 13:55:35 +00:00
|
|
|
|
|
|
|
|
|
public GudieAnimationManager GuideMgr => _guide.GetComponent<GudieAnimationManager>();
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_guide = GameObject.FindWithTag("Guide");
|
|
|
|
|
if (_guide == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("Guide is null");
|
|
|
|
|
}
|
2023-11-07 15:28:19 +00:00
|
|
|
|
|
|
|
|
|
_effectAnimator = transform.Find("Content").GetComponentInChildren<Animator>();
|
2023-11-07 17:51:34 +00:00
|
|
|
|
_content = transform.Find("Content");
|
2023-11-07 13:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
EventManager.Instance.AddEventListener("PlayAnimation", PlayAnimation);
|
2023-11-07 15:28:19 +00:00
|
|
|
|
EventManager.Instance.AddEventListener("ActionSuccess", ShowSuccessEffect);
|
2023-11-07 17:51:34 +00:00
|
|
|
|
EventManager.Instance.AddEventListener("UpdateProgress", UpdateSuccessCount);
|
2023-11-07 15:28:19 +00:00
|
|
|
|
EventManager.Instance.AddEventListener("ActionFailed", ShowFailEffect);
|
2023-11-07 13:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
EventManager.Instance.RemoveEventListener("PlayAnimation", PlayAnimation);
|
2023-11-07 15:28:19 +00:00
|
|
|
|
EventManager.Instance.RemoveEventListener("ActionSuccess", ShowSuccessEffect);
|
2023-11-07 17:51:34 +00:00
|
|
|
|
EventManager.Instance.RemoveEventListener("UpdateProgress", UpdateSuccessCount);
|
2023-11-07 15:28:19 +00:00
|
|
|
|
EventManager.Instance.RemoveEventListener("ActionFailed", ShowFailEffect);
|
2023-11-07 13:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 17:51:34 +00:00
|
|
|
|
private void UpdateSuccessCount(params object[] args)
|
|
|
|
|
{
|
|
|
|
|
//args[0] = successCount args[1] = excutedCount args[2] = totalCount
|
|
|
|
|
if (args.Length < 3)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("UpdateSuccessCount args is not enough");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var successCount = (int)args[0];
|
|
|
|
|
var excutedCount = (int)args[1];
|
|
|
|
|
var totalCount = (int)args[2];
|
|
|
|
|
var totalProgress = (float)excutedCount / totalCount;
|
|
|
|
|
|
|
|
|
|
var radial = _content.Find("Radial");
|
|
|
|
|
var img = radial.Find("Background/Loading Bar").GetComponent<Image>();
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
if (totalCount > excutedCount)
|
|
|
|
|
img.fillAmount = totalProgress;
|
|
|
|
|
else
|
|
|
|
|
img.fillAmount = 1;
|
|
|
|
|
}
|
|
|
|
|
var text = radial.Find("Text").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
if (text != null)
|
|
|
|
|
{
|
|
|
|
|
if (totalCount > excutedCount)
|
|
|
|
|
text.text = $"{(int)(totalProgress * 100)}%";
|
|
|
|
|
else
|
|
|
|
|
text.text = "100%";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var successDisplay = _content.Find("SuccessDisplay");
|
|
|
|
|
var successText = successDisplay.Find("SuccessCount").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
if (successText != null)
|
|
|
|
|
{
|
|
|
|
|
successText.text = successCount.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var totalText = successDisplay.Find("TotalCount").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
if (totalText != null)
|
|
|
|
|
{
|
|
|
|
|
totalText.text =$"/ {totalCount}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 15:28:19 +00:00
|
|
|
|
private void ShowFailEffect()
|
|
|
|
|
{
|
2023-11-07 17:51:34 +00:00
|
|
|
|
_effectAnimator.Play("WindowEffectError", 0, 0f);//<2F>߿<EFBFBD><DFBF><EFBFBD>˸
|
2023-11-07 15:28:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowSuccessEffect()
|
|
|
|
|
{
|
2023-11-07 17:51:34 +00:00
|
|
|
|
_effectAnimator.Play("WindowEffectCorrect", 0, 0f);//<2F>߿<EFBFBD><DFBF><EFBFBD>˸
|
2023-11-07 15:28:19 +00:00
|
|
|
|
}
|
2023-11-07 13:55:35 +00:00
|
|
|
|
#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);
|
2023-11-07 16:51:42 +00:00
|
|
|
|
EventManager.Instance.Dispatch("StartMotionCapture");
|
2023-11-07 13:55:35 +00:00
|
|
|
|
EventManager.Instance.Dispatch("PlayAnimation", AvatarAction.HeadTurnLeft);
|
|
|
|
|
}
|
|
|
|
|
}
|