阶段性完成
This commit is contained in:
@@ -8,26 +8,24 @@ using Opsive.Shared.Utility;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Chaaracters.AI
|
||||
namespace Cielonos.MainGame.Characters.AI
|
||||
{
|
||||
[Description("让角色播放一个功能动画,播放过程中会检测打断情况。")]
|
||||
[NodeIcon("Assets/Sprites/Icon/Play.png")]
|
||||
[Category("Cielonos")]
|
||||
public class PlayFuncAnim : Action
|
||||
public class PlayFuncAnim : AutomataActionBase
|
||||
{
|
||||
private Automata self;
|
||||
private CharacterBase target;
|
||||
private AnimationSubcontrollerBase animationSc => self.animationSc;
|
||||
private FunctionalAnimationSubmodule funcAnimSm;
|
||||
private RuntimeFuncAnim funcAnim;
|
||||
private float currentPlayTime => funcAnimSm.currentPlayTime;
|
||||
|
||||
[Header("AI Settings")]
|
||||
protected CharacterBase target;
|
||||
[Tooltip("是否选择其他目标,默认目标为玩家。")]
|
||||
public bool isOtherTarget = false;
|
||||
[Tooltip("如果选择了其他目标,则需要指定目标对象。")]
|
||||
public SharedVariable<GameObject> targetGameObject;
|
||||
|
||||
private AnimationSubcontrollerBase animationSc => self.animationSc;
|
||||
private FunctionalAnimationSubmodule funcAnimSm;
|
||||
private RuntimeFuncAnim funcAnim;
|
||||
private float currentPlayTime => funcAnimSm.currentPlayTime;
|
||||
|
||||
[Header("Animation Settings")]
|
||||
[Tooltip("要播放的功能动画名称。")]
|
||||
public string animationName;
|
||||
@@ -47,12 +45,17 @@ namespace Cielonos.MainGame.Chaaracters.AI
|
||||
public bool willAdjustAdsorption = true;
|
||||
[Tooltip("根吸附调整的最小距离。")]
|
||||
public float adsorptionMinDistance = 2;
|
||||
|
||||
[Header("Other Settings")]
|
||||
[Tooltip("是否记录此动作到动作记录子模块中。")]
|
||||
public bool willRecordAction = true;
|
||||
|
||||
private bool successPlayed = false;
|
||||
private bool failureBuffer;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
self = gameObject.GetComponent<Automata>();
|
||||
base.OnAwake();
|
||||
funcAnimSm = isOtherFuncAnimSm ? null : animationSc.fullBodyFuncAnimSm;
|
||||
target = isOtherTarget ? targetGameObject.Value.GetComponent<CharacterBase>() : MainGameManager.Player;
|
||||
}
|
||||
@@ -74,6 +77,15 @@ namespace Cielonos.MainGame.Chaaracters.AI
|
||||
{
|
||||
funcAnim.AddUpdateUntilEvent(new SetRootAdsorptionAdjustment(target, adsorptionMinDistance));
|
||||
}
|
||||
|
||||
if (willRecordAction)
|
||||
{
|
||||
self.actionRecordSm.AddRecord(animationName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
failureBuffer = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +93,22 @@ namespace Cielonos.MainGame.Chaaracters.AI
|
||||
{
|
||||
if (!successPlayed)
|
||||
{
|
||||
return TaskStatus.Failure;
|
||||
if (!failureBuffer)
|
||||
{
|
||||
failureBuffer = true;
|
||||
return TaskStatus.Running;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("功能动画播放失败:" + animationName);
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
}
|
||||
|
||||
if (funcAnimSm.currentRuntimeFuncAnim == funcAnim && !funcAnim.isLooping &&
|
||||
funcAnimSm.CheckDisruption(DisruptionType.NormalAction))
|
||||
{
|
||||
Debug.Log("动画播放完成:" + animationName);
|
||||
return TaskStatus.Success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user