报错修改
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public struct DigitalHumanPointData
|
||||
{
|
||||
public string pointName;
|
||||
public string boundName;
|
||||
public Transform boundTransform;
|
||||
public Transform pointTransform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ead6b7bbb32b41fbaf9b4cc09a5c707a
|
||||
timeCreated: 1745477826
|
||||
245
Assets/Domain/Main/HotUpdate/kkController/DigitalHumanSystem.cs
Normal file
245
Assets/Domain/Main/HotUpdate/kkController/DigitalHumanSystem.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.AudioCore;
|
||||
using Stary.Evo.TableTextConversion;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public interface IDigitalHuman : ISystem
|
||||
{
|
||||
void LoadKKController(Transform parent);
|
||||
void AddPointData(DigitalHumanPointData pointData);
|
||||
|
||||
void SetStartState();
|
||||
void SetPositionOfPoint(Transform pointTransform);
|
||||
void SetPositionOfPoint();
|
||||
void SetPositionOfBound(string boundName);
|
||||
void SetIdleState(KKIdleStateParam param);
|
||||
|
||||
void SetTalkState(AudioClip clip, List<UITableData.SubtitleInfo> info);
|
||||
void SetTalkState(AudioClip clip, Sprite icon);
|
||||
void SetTalkState(AudioClip clip);
|
||||
void SetTalkState(Sprite icon);
|
||||
void KillTalkState();
|
||||
void SetHintState(bool isContinue);
|
||||
void SetReactState();
|
||||
void SetDigitalHumanCoord(Vector3 position, Vector3 scale);
|
||||
void SetEndState();
|
||||
}
|
||||
|
||||
public class DigitalHuman : AbstractSystem, IDigitalHuman
|
||||
{
|
||||
private GameObject kkController;
|
||||
private Transform fxFlowing;
|
||||
|
||||
private KKFsmSystem fsmSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 点位位置数据
|
||||
/// </summary>
|
||||
private List<DigitalHumanPointData> points = new List<DigitalHumanPointData>();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
public async void LoadKKController(Transform parent)
|
||||
{
|
||||
var package = YooAssets.TryGetPackage("Main");
|
||||
if (package != null)
|
||||
{
|
||||
var handle = package.LoadAssetAsync<GameObject>(R.Res.Main.prefabs.kkcontroller_prefab);
|
||||
await handle.Task;
|
||||
kkController = handle.InstantiateSync(parent);
|
||||
fxFlowing = kkController.transform.Find("fx_spiraltrail_flowing");
|
||||
fsmSystem = new KKFsmSystem(kkController);
|
||||
fsmSystem.AddState(new KKIdleState(fsmSystem));
|
||||
fsmSystem.AddState(new KKHintState(fsmSystem));
|
||||
fsmSystem.AddState(new KKGuideState(fsmSystem));
|
||||
fsmSystem.AddState(new KKReactState(fsmSystem));
|
||||
fsmSystem.AddState(new KKTalkState(fsmSystem));
|
||||
fsmSystem.AddState(new KKRunState(fsmSystem));
|
||||
fsmSystem.AddState(new KKStartState(fsmSystem));
|
||||
fsmSystem.AddState(new KKEndState(fsmSystem));
|
||||
fsmSystem.SetCurState(nameof(DefaultState));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPointData(DigitalHumanPointData pointData)
|
||||
{
|
||||
bool isExist = false;
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
if (points[i].pointName == pointData.pointName)
|
||||
{
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExist)
|
||||
{
|
||||
points.Add(pointData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开场动画
|
||||
/// </summary>
|
||||
public void SetStartState()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKStartState));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置到达点位位置
|
||||
/// </summary>
|
||||
public void SetPositionOfPoint(Transform pointTransform)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKGuideState), pointTransform);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置到达点位位置
|
||||
/// </summary>
|
||||
public void SetPositionOfBound(string boundName)
|
||||
{
|
||||
if (points.Count > 0)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
if (boundName == points[i].boundName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
kkController.transform.position = points[index].boundTransform.position;
|
||||
kkController.transform.rotation = points[index].boundTransform.rotation;
|
||||
kkController.transform.localScale = points[index].boundTransform.localScale;
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置到达点位位置
|
||||
/// </summary>
|
||||
public void SetPositionOfPoint()
|
||||
{
|
||||
if (points.Count > 0)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
if (AppConfig.PackageDomainName == points[i].pointName)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1 && index + 1 < points.Count)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKGuideState), points[index + 1].pointTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置idle站立状态
|
||||
/// </summary>
|
||||
/// <param name="param">是否指引玩家靠近</param>
|
||||
public void SetIdleState(KKIdleStateParam param)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState), (object)param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置讲解状态
|
||||
/// </summary>
|
||||
public void SetTalkState(AudioClip clip, Sprite icon)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKTalkState), clip, icon);
|
||||
}
|
||||
|
||||
public void SetTalkState(AudioClip clip)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKTalkState), clip, (Sprite)null);
|
||||
}
|
||||
|
||||
public void SetTalkState(Sprite icon)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKTalkState), (AudioClip)null, icon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置讲解状态
|
||||
/// </summary>
|
||||
public void SetTalkState(AudioClip clip, List<UITableData.SubtitleInfo> info)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKTalkState), clip, info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制打断讲解状态
|
||||
/// </summary>
|
||||
public void KillTalkState()
|
||||
{
|
||||
AudioCoreManager.StopVoice();
|
||||
fsmSystem.CloseImage();
|
||||
fsmSystem.CloseText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置问答反馈状态
|
||||
/// </summary>
|
||||
/// <param name="isContinue">正确还是错误</param>
|
||||
public void SetHintState(bool isContinue)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKHintState), (object)isContinue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置鼓掌状态
|
||||
/// </summary>
|
||||
public void SetReactState()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKReactState));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置虚拟人坐标
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="scale"></param>
|
||||
public void SetDigitalHumanCoord(Vector3 position, Vector3 scale)
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKRunState));
|
||||
kkController.transform.DOMove(position, 2f).OnComplete(() =>
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState), (object)KKIdleStateParam.NotVoice);
|
||||
});
|
||||
kkController.transform.DOScale(scale, 2f);
|
||||
if (fxFlowing != null)
|
||||
fxFlowing.transform.DOScale(scale, 2f);
|
||||
}
|
||||
|
||||
public void SetEndState()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKEndState));
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
fsmSystem = null;
|
||||
if (kkController != null)
|
||||
{
|
||||
GameObject.Destroy(kkController);
|
||||
kkController = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acbc8c12f9332fa43bcbf8789e101fa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Main;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public interface IDigitalHumanVoiceSystem : ISystem
|
||||
{
|
||||
UniTask PlayVoice(string auid, Action callback = null);
|
||||
UniTask PlayTest(string auid, Action callback = null);
|
||||
void PlayImage(string uiid);
|
||||
}
|
||||
|
||||
public class DigitalHumanVoiceSystem : AbstractSystem, IDigitalHumanVoiceSystem
|
||||
{
|
||||
private CancellationTokenSource tokenSource;
|
||||
|
||||
|
||||
public async UniTask PlayVoice(string auid, Action callback = null)
|
||||
{
|
||||
DisposeTokenSource();
|
||||
tokenSource = new CancellationTokenSource();
|
||||
var info = this.GetData<IAudioTableData>().GetAudioToUIInfo(auid);
|
||||
var handle1 = YooAssets.LoadAssetAsync<AudioClip>(info.audioFileName);
|
||||
await handle1.WithCancellation(tokenSource.Token);
|
||||
AudioClip audioClip = handle1.GetAssetObject<AudioClip>();
|
||||
|
||||
var handle2 = YooAssets.LoadAssetAsync<Sprite>(info.UIMessageInfo.filename);
|
||||
await handle2.WithCancellation(tokenSource.Token);
|
||||
Sprite sprite = handle2.GetAssetObject<Sprite>();
|
||||
|
||||
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState(audioClip, sprite);
|
||||
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(audioClip.length+1f), cancellationToken: tokenSource.Token);
|
||||
callback?.Invoke();
|
||||
}
|
||||
public async UniTask PlayTest(string auid, Action callback = null)
|
||||
{
|
||||
DisposeTokenSource();
|
||||
tokenSource = new CancellationTokenSource();
|
||||
var info = this.GetData<IAudioTableData>().GetAudioToUIInfo(auid);
|
||||
var handle1 = YooAssets.LoadAssetAsync<AudioClip>(info.audioFileName);
|
||||
await handle1.WithCancellation(tokenSource.Token);
|
||||
AudioClip audioClip = handle1.GetAssetObject<AudioClip>();
|
||||
|
||||
|
||||
|
||||
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState(audioClip, info.UIMessageInfo.subtitle);
|
||||
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(audioClip.length), cancellationToken: tokenSource.Token);
|
||||
callback?.Invoke();
|
||||
}
|
||||
public async void PlayImage(string uiid)
|
||||
{
|
||||
DisposeTokenSource();
|
||||
tokenSource = new CancellationTokenSource();
|
||||
var info =this.GetData<IAudioTableData>().GetUIInfo(uiid);
|
||||
var handle1 = YooAssets.LoadAssetAsync<Sprite>(info.filename);
|
||||
await handle1.WithCancellation(tokenSource.Token);
|
||||
Sprite sprite = handle1.GetAssetObject<Sprite>();
|
||||
|
||||
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState( sprite);
|
||||
}
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
private void DisposeTokenSource()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (tokenSource != null && !tokenSource.IsCancellationRequested)
|
||||
{
|
||||
tokenSource.Cancel();
|
||||
tokenSource.Dispose();
|
||||
tokenSource = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log("异步取消操作");
|
||||
}
|
||||
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
DisposeTokenSource();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6788683518a232747ab70e2ad30ed532
|
||||
timeCreated: 1745216067
|
||||
8
Assets/Domain/Main/HotUpdate/kkController/fsm.meta
Normal file
8
Assets/Domain/Main/HotUpdate/kkController/fsm.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7c411cf7fe497343a284f1477d129d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class KKControllerTest : MonoBehaviour
|
||||
{
|
||||
public GameObject kkController;
|
||||
|
||||
public Transform kkGuidePoint;
|
||||
|
||||
public Sprite Sprite;
|
||||
public AudioClip AudioClip;
|
||||
|
||||
|
||||
private KKFsmSystem fsmSystem;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
fsmSystem = new KKFsmSystem(kkController);
|
||||
fsmSystem.AddState(new DefaultState(fsmSystem));
|
||||
fsmSystem.AddState(new KKIdleState(fsmSystem));
|
||||
fsmSystem.AddState(new KKHintState(fsmSystem));
|
||||
fsmSystem.AddState(new KKGuideState(fsmSystem));
|
||||
fsmSystem.AddState(new KKReactState(fsmSystem));
|
||||
fsmSystem.AddState(new KKTalkState(fsmSystem));
|
||||
fsmSystem.SetCurState(nameof(DefaultState));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
fsmSystem.CurState.OnUpdate();
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void IdleIsVoice()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState), (object)KKIdleStateParam.IsVoice);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void IdleNotVoice()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState), (object)KKIdleStateParam.NotVoice);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void GUide()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKGuideState), kkGuidePoint);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void HintTrue()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKHintState), (object)true);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void HintFalse()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKHintState), (object)false);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void React()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKReactState));
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Talk()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKTalkState), AudioClip, Sprite);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Start1()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState));
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void End()
|
||||
{
|
||||
fsmSystem.SetCurState(nameof(KKIdleState));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c88db27930db49249a1c3611ca7284eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Domain/Main/HotUpdate/kkController/fsm/KKEndState.cs
Normal file
38
Assets/Domain/Main/HotUpdate/kkController/fsm/KKEndState.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 结束状态
|
||||
/// </summary>
|
||||
public class KKEndState: AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_disappear";
|
||||
public KKEndState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName, 0.2f,0, 0f);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52167847c2fa440b870fb2a157f1d074
|
||||
timeCreated: 1745399204
|
||||
52
Assets/Domain/Main/HotUpdate/kkController/fsm/KKFsmSystem.cs
Normal file
52
Assets/Domain/Main/HotUpdate/kkController/fsm/KKFsmSystem.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using DG.Tweening;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class KKFsmSystem : FsmSystem, IFsmSystem
|
||||
{
|
||||
public GameObject kk;
|
||||
|
||||
public Animator animator;
|
||||
public Image image;
|
||||
public Text text;
|
||||
public KKFsmSystem(GameObject kk)
|
||||
{
|
||||
this.kk = kk;
|
||||
this.animator = kk.GetComponentInChildren<Animator>();
|
||||
this.image = kk.GetComponentInChildren<Image>();
|
||||
this.image.color = new Color(1, 1, 1, 0);
|
||||
this.text = kk.GetComponentInChildren<Text>();
|
||||
this.text.color = new Color(1, 1, 1, 0);
|
||||
}
|
||||
|
||||
public void OpenImage()
|
||||
{
|
||||
this.image.DOFade(1, 1f);
|
||||
}
|
||||
|
||||
public void CloseImage()
|
||||
{
|
||||
this.image.DOFade(0, 1f);
|
||||
}
|
||||
|
||||
public void OpenText()
|
||||
{
|
||||
this.text.DOFade(1, 1f);
|
||||
}
|
||||
|
||||
public void CloseText()
|
||||
{
|
||||
this.text.DOFade(0, 1f);
|
||||
}
|
||||
|
||||
public float GetAnimationProgress(int layerIndex = 0)
|
||||
{
|
||||
if (animator == null) return 0;
|
||||
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex);
|
||||
return stateInfo.normalizedTime % 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3eb011e76cf4d0ba9059cf92114333f
|
||||
timeCreated: 1745398545
|
||||
@@ -0,0 +1,68 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户未靠近时,“请跟我来”手势
|
||||
/// </summary>
|
||||
public class KKGuideState : AbstractFSMIState
|
||||
{
|
||||
private string aniGuideLeftName = "anim_ip_guide_inviteL";
|
||||
private string aniGuideRightName = "anim_ip_guide_inviteR";
|
||||
|
||||
public KKGuideState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override async UniTask OnEnterAsync<T>(T param)
|
||||
{
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
Transform NextPoint = param as Transform;
|
||||
if (NextPoint != null)
|
||||
{
|
||||
// 获取主摄像机并计算相对位置
|
||||
var camera = Camera.main.transform;
|
||||
Vector3 viewportPos = camera.GetComponent<Camera>().WorldToViewportPoint(NextPoint.position);
|
||||
|
||||
// 根据视口坐标判断左右(视口X坐标<0.5为左侧,>=0.5为右侧)
|
||||
if (viewportPos.x < 0.5f)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniGuideLeftName,0.2f, 0, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniGuideRightName,0.2f, 0, 0f);
|
||||
}
|
||||
|
||||
float animProgress = 0;
|
||||
while (animProgress <= 0.99f)
|
||||
{
|
||||
Debug.Log(animProgress);
|
||||
animProgress=kkFsmSystem.GetAnimationProgress(0);
|
||||
await UniTask.Yield();
|
||||
}
|
||||
|
||||
kkFsmSystem.kk.transform.DOScale(Vector3.zero, 0.5f).OnComplete(() =>
|
||||
{
|
||||
kkFsmSystem.kk.transform.position = NextPoint.position;
|
||||
kkFsmSystem.kk.transform.DOScale(Vector3.one, 0.5f);
|
||||
|
||||
FsmSystem.SetCurState(nameof(KKIdleState),(object)KKIdleStateParam.IsVoice);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72adebd57a5e43c2997efab047224c18
|
||||
timeCreated: 1745399340
|
||||
67
Assets/Domain/Main/HotUpdate/kkController/fsm/KKHintState.cs
Normal file
67
Assets/Domain/Main/HotUpdate/kkController/fsm/KKHintState.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 反馈手势状态
|
||||
/// </summary>
|
||||
public class KKHintState : AbstractFSMIState
|
||||
{
|
||||
private string aniContinueName = "anim_ip_hint_continue";
|
||||
private string aniNotyetName = "anim_ip_hint_notyet";
|
||||
|
||||
public KKHintState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override async UniTask OnEnterAsync(object param)
|
||||
{
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
bool isContinue = (bool)param;
|
||||
if (isContinue)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniContinueName, 0.2f,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniNotyetName,0.2f, 0, 0f);
|
||||
}
|
||||
|
||||
float animProgress = 0;
|
||||
while (animProgress <= 0.99f)
|
||||
{
|
||||
Debug.Log(animProgress);
|
||||
animProgress=kkFsmSystem.GetAnimationProgress(0);
|
||||
await UniTask.Yield();
|
||||
}
|
||||
FsmSystem.SetCurState(nameof(KKIdleState),(object)KKIdleStateParam.NotVoice);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 342e0d1acb234177ac8c44412dcf5046
|
||||
timeCreated: 1745399413
|
||||
68
Assets/Domain/Main/HotUpdate/kkController/fsm/KKIdleState.cs
Normal file
68
Assets/Domain/Main/HotUpdate/kkController/fsm/KKIdleState.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 待机状态
|
||||
/// </summary>
|
||||
public class KKIdleState : AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_idle_loop";
|
||||
|
||||
private float idleTime = 0f;
|
||||
private KKIdleStateParam isVoice;
|
||||
|
||||
public KKIdleState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync(object param)
|
||||
{
|
||||
isVoice = (KKIdleStateParam)param;
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName, 0.2f, 0, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
base.OnUpdate();
|
||||
idleTime += Time.deltaTime;
|
||||
if (idleTime >= 10 && isVoice == KKIdleStateParam.IsVoice)
|
||||
{
|
||||
//播放过来语音
|
||||
idleTime = 0;
|
||||
Debug.Log("KKIdleState::OnUpdate");
|
||||
}
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public enum KKIdleStateParam
|
||||
{
|
||||
IsVoice,
|
||||
NotVoice
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fffa4d1466936449b51e47de374350c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 鼓掌状态
|
||||
/// </summary>
|
||||
public class KKReactState: AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_react_encourage";
|
||||
public KKReactState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override async UniTask OnEnterAsync()
|
||||
{
|
||||
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName,0.2f, 0, 0f);
|
||||
|
||||
float animProgress = 0;
|
||||
while (animProgress <= 0.99f)
|
||||
{
|
||||
Debug.Log(animProgress);
|
||||
animProgress=kkFsmSystem.GetAnimationProgress(0);
|
||||
await UniTask.Yield();
|
||||
}
|
||||
FsmSystem.SetCurState(nameof(KKIdleState),(object)KKIdleStateParam.NotVoice);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
|
||||
}
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66f9860699a14a9cb79b86aac4f938dc
|
||||
timeCreated: 1745399464
|
||||
41
Assets/Domain/Main/HotUpdate/kkController/fsm/KKRunState.cs
Normal file
41
Assets/Domain/Main/HotUpdate/kkController/fsm/KKRunState.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 待机状态
|
||||
/// </summary>
|
||||
public class KKRunState : AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_explain_talk_loop";
|
||||
|
||||
|
||||
|
||||
public KKRunState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName, 0.2f,0, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73d781b0c95b4b769d515a756744df84
|
||||
timeCreated: 1745476983
|
||||
@@ -0,0 +1,38 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 开始状态
|
||||
/// </summary>
|
||||
public class KKStartState: AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_appear";
|
||||
public KKStartState(IFsmSystem system) : base(system)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName, 0.2f,0, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c04d19ca3ec94e58984c3599399ae63a
|
||||
timeCreated: 1745399152
|
||||
128
Assets/Domain/Main/HotUpdate/kkController/fsm/KKTalkState.cs
Normal file
128
Assets/Domain/Main/HotUpdate/kkController/fsm/KKTalkState.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.AudioCore;
|
||||
using Stary.Evo.TableTextConversion;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
/// <summary>
|
||||
/// 讲解状态
|
||||
/// </summary>
|
||||
public class KKTalkState : AbstractFSMIState
|
||||
{
|
||||
private string aniName = "anim_ip_explain_talk_loop";
|
||||
private string aniMouthName = "anim_ip_talk";
|
||||
|
||||
private CancellationTokenSource cts;
|
||||
|
||||
public KKTalkState(IFsmSystem system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
if (cts.IsCancellationRequested)
|
||||
{
|
||||
cts?.Cancel();
|
||||
cts?.Dispose();
|
||||
}
|
||||
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
if (kkFsmSystem != null)
|
||||
{
|
||||
// kkFsmSystem.CloseImage();
|
||||
// kkFsmSystem.CloseText();
|
||||
}
|
||||
|
||||
kkFsmSystem.animator.CrossFade("defaultState", 0.2f, 1, 0f);
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override async UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||
{
|
||||
if (cts != null && !cts.IsCancellationRequested)
|
||||
{
|
||||
cts?.Cancel();
|
||||
cts?.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
|
||||
cts = new CancellationTokenSource();
|
||||
|
||||
KKFsmSystem kkFsmSystem = FsmSystem as KKFsmSystem;
|
||||
AudioClip clip = param1 as AudioClip;
|
||||
if (clip != null)
|
||||
{
|
||||
AudioCoreManager.PlayVoice(new AudioData()
|
||||
{
|
||||
clip = clip,
|
||||
delayOnCompleteTime = 1f,
|
||||
onComplete = async () =>
|
||||
{
|
||||
kkFsmSystem.CloseImage();
|
||||
|
||||
float animProgress = 0;
|
||||
while (animProgress <= 0.99f)
|
||||
{
|
||||
animProgress = kkFsmSystem.GetAnimationProgress(0);
|
||||
await UniTask.Yield();
|
||||
}
|
||||
|
||||
FsmSystem.SetCurState(nameof(KKIdleState), (object)KKIdleStateParam.NotVoice);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (kkFsmSystem.animator != null)
|
||||
{
|
||||
kkFsmSystem.animator.CrossFade(aniName, 0.2f, 0, 0f);
|
||||
kkFsmSystem.animator.CrossFade(aniMouthName, 0.2f, 1, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UnityEvo:KKFsmSystem: animator is null");
|
||||
}
|
||||
|
||||
if (kkFsmSystem.image != null)
|
||||
{
|
||||
if (param2 != null && param2 is Sprite)
|
||||
{
|
||||
kkFsmSystem.image.sprite = param2 as Sprite;
|
||||
kkFsmSystem.image.SetNativeSize();
|
||||
kkFsmSystem.CloseText();
|
||||
kkFsmSystem.OpenImage();
|
||||
}
|
||||
}
|
||||
|
||||
if (kkFsmSystem.text != null)
|
||||
{
|
||||
if (param2 != null && param2 is List<UITableData.SubtitleInfo>)
|
||||
{
|
||||
kkFsmSystem.CloseImage();
|
||||
kkFsmSystem.OpenText();
|
||||
List<UITableData.SubtitleInfo> infos = param2 as List<UITableData.SubtitleInfo>;
|
||||
if (infos.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
kkFsmSystem.text.text = infos[i].subtitle;
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(infos[i].end - infos[i].start),
|
||||
cancellationToken: cts.Token);
|
||||
}
|
||||
|
||||
kkFsmSystem.CloseText();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d5cbc01e12a4a8ba1616131a9a97bef
|
||||
timeCreated: 1745399300
|
||||
Reference in New Issue
Block a user