1
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
"GUID:3bfa6f714e036734185ec6f5b157610a",
|
||||
"GUID:6ef4ed8ff60a7aa4bb60a8030e6f4008",
|
||||
"GUID:84d565da37ad40546a118cfb3c3509f3",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad"
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:3e9ced9430d8ee743b37f99f97066130"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -21,23 +21,6 @@ namespace BITFALL.GameEditor
|
||||
|
||||
window.Show();
|
||||
}
|
||||
|
||||
protected override VisualElement MakeItem()
|
||||
{
|
||||
var container = new VisualElement();
|
||||
var icon = container.Create<VisualElement>(UXConstant.Icon);
|
||||
var label = container.Create<Label>(UXConstant.ContextLabel);
|
||||
|
||||
container.style.flexDirection = FlexDirection.Row;
|
||||
container.style.alignContent = Align.Center;
|
||||
container.style.alignItems = Align.Center;
|
||||
|
||||
icon.style.width = 24;
|
||||
icon.style.height = 24;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
protected override void BindItem(VisualElement arg1, int arg2)
|
||||
{
|
||||
var item = List[arg2];
|
||||
|
34
Assets/Artists/Scripts/Editor/MotionMatchingEditor.cs
Normal file
34
Assets/Artists/Scripts/Editor/MotionMatchingEditor.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Animations;
|
||||
using BITKit.GameEditor;
|
||||
using BITKit.UX;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITFALL.GameEditor
|
||||
{
|
||||
public class MotionMatchingEditor : ScriptableObjectGroupEditor<ScriptableMotionMatchingObject>
|
||||
{
|
||||
protected override string AssetsPath => "Assets/Artists/Configs/MotionMatching/";
|
||||
|
||||
[MenuItem("Tools/ScriptableObjectEditor/Motion Matching")]
|
||||
public static void Open()
|
||||
{
|
||||
var window = GetWindow<MotionMatchingEditor>();
|
||||
window.titleContent = new GUIContent("Motion Matching Editor");
|
||||
|
||||
window.Show();
|
||||
}
|
||||
protected override void BindItem(VisualElement arg1, int arg2)
|
||||
{
|
||||
var item = List[arg2];
|
||||
var container = new UXContainer(arg1);
|
||||
|
||||
container.contextLabel.text = item.name;
|
||||
//container.icon.style.backgroundImage = item.SquareIcon;
|
||||
}
|
||||
}
|
||||
}
|
@@ -35,11 +35,12 @@ namespace BITKit.Entities
|
||||
[SerializeField] protected AssetableItem item;
|
||||
|
||||
|
||||
[Header(Constant.Header.Property)]
|
||||
[SerializeField] public SerializedDictionary<string,AnimationProperty> animationProperties;
|
||||
//[Header(Constant.Header.Property)]
|
||||
//[SerializeField] public SerializedDictionary<string,AnimationProperty> animationProperties;
|
||||
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] private AnimancerComponent animancerComponent;
|
||||
[SerializeField] private AnimancerComponent additionalAnimancerComponent;
|
||||
[SerializeField] protected EntityVFXPlayer vfxPlayer;
|
||||
[SerializeField] private Renderer[] renderers;
|
||||
[SerializeField] protected Transform cameraTransform;
|
||||
@@ -52,6 +53,7 @@ namespace BITKit.Entities
|
||||
public IEntity Entity { get; set; }
|
||||
public Entity UnityEntity=>Entity as Entity;
|
||||
public AnimancerComponent AnimancerComponent=>animancerComponent;
|
||||
public AnimancerComponent AdditionalAnimancerComponent=>additionalAnimancerComponent;
|
||||
public IMotionMatchingService MotionMatchingService=>motionMatchingService;
|
||||
|
||||
public IBasicItem Item
|
||||
@@ -64,7 +66,7 @@ namespace BITKit.Entities
|
||||
}
|
||||
}
|
||||
private IBasicItem _item;
|
||||
public IDictionary<string, float> AnimationProperties = null;
|
||||
//public IDictionary<string, float> AnimationProperties = null;
|
||||
|
||||
[Inject(true),NonSerialized]
|
||||
public InputActionGroup inputActionGroup;
|
||||
@@ -89,7 +91,15 @@ namespace BITKit.Entities
|
||||
public virtual void Entry()
|
||||
{
|
||||
if (animancerComponent)
|
||||
{
|
||||
animancerComponent.enabled = true;
|
||||
animancerComponent.Animator.enabled = true;
|
||||
}
|
||||
if (additionalAnimancerComponent)
|
||||
{
|
||||
additionalAnimancerComponent.enabled = true;
|
||||
additionalAnimancerComponent.Animator.enabled = true;
|
||||
}
|
||||
|
||||
AllowRendering.AddElement(this);
|
||||
//inputActionGroup.allowInput.AddElement(this);
|
||||
@@ -116,10 +126,6 @@ namespace BITKit.Entities
|
||||
public virtual UniTask ExitAsync()
|
||||
{
|
||||
AllowRendering.RemoveElement(this);
|
||||
|
||||
if (animancerComponent)
|
||||
animancerComponent.Animator.enabled = false;
|
||||
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
@@ -130,13 +136,28 @@ namespace BITKit.Entities
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
cameraTransform.localPosition = default;
|
||||
cameraTransform.localRotation = _initialCameraRotation;
|
||||
|
||||
if (animancerComponent)
|
||||
{
|
||||
animancerComponent.enabled = false;
|
||||
animancerComponent.Animator.enabled = false;
|
||||
}
|
||||
if(AdditionalAnimancerComponent)
|
||||
{
|
||||
AdditionalAnimancerComponent.enabled = false;
|
||||
AdditionalAnimancerComponent.Stop();
|
||||
AdditionalAnimancerComponent.Animator.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnAwake()
|
||||
{
|
||||
|
||||
|
||||
AnimationProperties= animationProperties.ToDictionary(x=>x.Key,x=>x.Value.Value);
|
||||
//AnimationProperties= animationProperties.ToDictionary(x=>x.Key,x=>x.Value.Value);
|
||||
|
||||
if (renderers is null or { Length: 0 })
|
||||
{
|
||||
renderers = GetComponentsInChildren<Renderer>(true);
|
||||
}
|
||||
|
||||
foreach (var x in StateDictionary.Values)
|
||||
{
|
||||
@@ -195,10 +216,10 @@ namespace BITKit.Entities
|
||||
|
||||
public virtual void OnUpdate(float deltaTime)
|
||||
{
|
||||
foreach (var pair in animationProperties)
|
||||
{
|
||||
AnimationProperties[pair.Key] = pair.Value.Value;
|
||||
}
|
||||
// foreach (var pair in animationProperties)
|
||||
// {
|
||||
// AnimationProperties[pair.Key] = pair.Value.Value;
|
||||
// }
|
||||
}
|
||||
public virtual bool IsSupportItem(IBasicItem item) =>item is not null && item.AddressablePath == AddressablePath;
|
||||
|
||||
|
@@ -30,20 +30,30 @@ namespace BITFALL.Guns
|
||||
public BITGun root;
|
||||
[Inject]
|
||||
protected IEntityMovement _entityMovement;
|
||||
|
||||
[Inject] protected IEquipService equipService;
|
||||
protected AnimancerComponent animancerComponent=>root.AnimancerComponent;
|
||||
public bool Enabled { get;set; }
|
||||
protected AnimancerState currentState;
|
||||
|
||||
protected string[] AnimationKey;
|
||||
protected bool PlayAnimation(params string[] args)
|
||||
{
|
||||
if (root.MotionMatchingService.TryMatch(out var obj,args) is false) return false;
|
||||
if (root.MotionMatchingService.TryMatch(out var obj,root.SearchKey.Union(args).ToArray()) is false) return false;
|
||||
switch (obj)
|
||||
{
|
||||
case IMotionMatchingClip clip:
|
||||
animancerComponent.Play(clip.Clip,0.1f);
|
||||
currentState = animancerComponent.Play(clip.Clip,0.1f);
|
||||
return true;
|
||||
case IMotionMatchingSequence sequence:
|
||||
//animancerComponent.Play(sequence.Sequence);
|
||||
return true;
|
||||
case IMotionMatchingDualClip dualClip:
|
||||
currentState = animancerComponent.Play(dualClip.Clip1,0.1f);
|
||||
if (root.AdditionalAnimancerComponent)
|
||||
{
|
||||
root.AdditionalAnimancerComponent.Stop();
|
||||
var state2 = root.AdditionalAnimancerComponent.Play(dualClip.Clip2,0.1f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -55,20 +65,28 @@ namespace BITFALL.Guns
|
||||
switch (obj)
|
||||
{
|
||||
case IMotionMatchingClip clip:
|
||||
var state = animancerComponent.Play(clip.Clip, 0.1f);
|
||||
state.Events.OnEnd=OnEnd is null ? null : () =>
|
||||
currentState = animancerComponent.Play(clip.Clip, 0.1f);
|
||||
currentState.Events.OnEnd=OnEnd is null ? null : () =>
|
||||
{
|
||||
state.Events.OnEnd = null;
|
||||
currentState.Events.OnEnd = null;
|
||||
this.OnEnd();
|
||||
};
|
||||
break;
|
||||
case IMotionMatchingDualClip dualClip:
|
||||
currentState = animancerComponent.Play(dualClip.Clip1, 0.1f);
|
||||
root.AdditionalAnimancerComponent.Stop();
|
||||
var state2 = root.AdditionalAnimancerComponent.Play(dualClip.Clip2, 0.1f);
|
||||
currentState.Events.OnEnd = OnEnd is null ? null : () =>
|
||||
{
|
||||
currentState.Events.OnEnd = null;
|
||||
this.OnEnd();
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void Initialize()
|
||||
{
|
||||
root.Entity.Inject(this);
|
||||
_entityMovement.OnStateChanged += OnMovementStateChanged;
|
||||
// AnimationKey = new []{BITGun.C_Weapon,GetType().Name,root._gun.Name};
|
||||
AnimationKey = root.SearchKey.Append(GetType().Name).ToArray();
|
||||
}
|
||||
|
||||
@@ -424,13 +442,14 @@ namespace BITFALL.Guns
|
||||
expectFiring.shouldBe = fireAction.action.WasPressedThisFrame();
|
||||
if(burstFireInterval.AllowUpdate)
|
||||
{
|
||||
switch (AnimationProperties.TryGetValue(BITConstant.Player.AllowFire, out var allowFire))
|
||||
{
|
||||
case false:
|
||||
case true when allowFire >0.9f:
|
||||
Fire();
|
||||
break;
|
||||
}
|
||||
// switch (AnimationProperties.TryGetValue(BITConstant.Player.AllowFire, out var allowFire))
|
||||
// {
|
||||
// case false:
|
||||
// case true when allowFire >0.9f:
|
||||
// Fire();
|
||||
// break;
|
||||
// }
|
||||
Fire();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -440,18 +459,8 @@ namespace BITFALL.Guns
|
||||
Focus = recoilSpring.value.GetLength() > 0.1f,
|
||||
Sender = this
|
||||
});
|
||||
|
||||
if(AnimationProperties.TryGetValue(BITConstant.Player.Aim, out var __aim))
|
||||
{
|
||||
//animator.animator.SetFloat((int)BITHash.Player.Aim,__aim);
|
||||
}
|
||||
|
||||
var length = _movement.GroundVelocity.GetLength();
|
||||
// animator.animator.SetFloat(BITConstant.Player.SqrMagnitude,
|
||||
// Mathf.Clamp(
|
||||
// length / _movement.ReferenceSpeed,0.1f,1
|
||||
// )
|
||||
// );
|
||||
|
||||
if (walkState is not null)
|
||||
{
|
||||
@@ -473,10 +482,9 @@ namespace BITFALL.Guns
|
||||
if (selfViewAdditive)
|
||||
{
|
||||
var positionWeight = recoilPositionWeight;
|
||||
if (AnimationProperties.TryGetValue(BITConstant.Player.Aim, out var aim))
|
||||
{
|
||||
|
||||
var aim = _equipService.Aim;
|
||||
positionWeight *= Mathf.Lerp(2, 1, aim);
|
||||
}
|
||||
//selfViewAdditive.AddEuler(recoilSpring.value);
|
||||
selfViewAdditive.AddRotation(Quaternion.Euler(recoilSpring.value));
|
||||
selfViewAdditive.AddPosition(
|
||||
@@ -489,8 +497,9 @@ namespace BITFALL.Guns
|
||||
);
|
||||
}
|
||||
|
||||
if(AnimationProperties.TryGetValue(BITConstant.Player.Aim, out var _aim))
|
||||
{
|
||||
var _aim = _equipService.Aim;
|
||||
|
||||
_equipService.Zoom.Allow = CurrentState is Aim;
|
||||
_equipService.Zoom.Value =Mathf.Lerp(1,_gun.InitialAimZoom, _aim);
|
||||
_equipService.AllowScope = _aim > 0.5f && _gun.IsScopeAim;
|
||||
@@ -542,15 +551,15 @@ namespace BITFALL.Guns
|
||||
}
|
||||
}
|
||||
|
||||
if (AnimationProperties.TryGetValue(BITConstant.Player.Stable, out var stable))
|
||||
{
|
||||
_equipService.Stable = stable;
|
||||
}
|
||||
|
||||
if(AnimationProperties.TryGetValue(BITConstant.Player.AllowFire, out var _allowFire))
|
||||
{
|
||||
_equipService.AllowAttack = _allowFire > 0.9f;
|
||||
}
|
||||
// if (AnimationProperties.TryGetValue(BITConstant.Player.Stable, out var stable))
|
||||
// {
|
||||
// _equipService.Stable = stable;
|
||||
// }
|
||||
//
|
||||
// if(AnimationProperties.TryGetValue(BITConstant.Player.AllowFire, out var _allowFire))
|
||||
// {
|
||||
// _equipService.AllowAttack = _allowFire > 0.9f;
|
||||
// }
|
||||
|
||||
//AllowRendering.SetDisableElements(64564,_equipService.AllowScope);
|
||||
|
||||
@@ -670,10 +679,6 @@ namespace BITFALL.Guns
|
||||
{
|
||||
InternalAddRecoil();
|
||||
InternalFire(_gun.BuckShot.Value);
|
||||
// for (int i = 0; i < _gun.BuckShot.Value; i++)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -710,6 +715,7 @@ namespace BITFALL.Guns
|
||||
|
||||
private void InternalFire(int count = 1)
|
||||
{
|
||||
var aim = _equipService.Aim;
|
||||
//调用BulletManager生成子弹
|
||||
var _transform = transform;
|
||||
var rotation =_movement.ViewRotation;
|
||||
@@ -720,10 +726,7 @@ namespace BITFALL.Guns
|
||||
{
|
||||
fireRecoil *= spread.Spread;
|
||||
}
|
||||
if(AnimationProperties.TryGetValue(BITConstant.Player.Aim, out var aim))
|
||||
{
|
||||
fireRecoil *= Mathf.Lerp(_gun.InitialHipFireSpread,1,aim);
|
||||
}
|
||||
fireRecoil *= recoilSpring.value.GetLength();
|
||||
var length = fireRecoil.GetLength();
|
||||
for (var i = 0; i < count; i++)
|
||||
|
@@ -39,10 +39,13 @@ namespace BITFALL.Guns.States
|
||||
case Equip:
|
||||
break;
|
||||
default:
|
||||
PlayAnimation();
|
||||
OnMovementStateChanged(null, _entityMovement.CurrentState);
|
||||
if (_entityMovement.CurrentState is IPlayerWalkState)
|
||||
PlayAnimation();
|
||||
else
|
||||
OnMovementStateChanged(null, _entityMovement.CurrentState);
|
||||
break;
|
||||
}
|
||||
|
||||
_selector.OnActive += OnActive;
|
||||
boltActionImmediately = root.RequireBolt;
|
||||
|
||||
@@ -123,13 +126,18 @@ namespace BITFALL.Guns.States
|
||||
_expectRun = newState is IPlayerRunState or IPlayerSprintState;
|
||||
if (newState is IPlayerSlideState)
|
||||
{
|
||||
root.TransitionState<Movement>();
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Slide)).ToArray());
|
||||
if (root.CurrentState != this)
|
||||
root.TransitionState<Movement>();
|
||||
PlayAnimation(BITConstant.Player.Slide);
|
||||
//root.animator.CrossFade(BITConstant.Player.Slide, 0.32f);
|
||||
}else if (newState is IPlayerDodgeState)
|
||||
}
|
||||
else if (newState is IPlayerDodgeState)
|
||||
{
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Dodge)).ToArray());
|
||||
}else if (Enabled)
|
||||
if (root.CurrentState != this)
|
||||
root.TransitionState<Movement>();
|
||||
PlayAnimation(BITConstant.Player.Dodge);
|
||||
}
|
||||
else if (Enabled)
|
||||
{
|
||||
switch (newState)
|
||||
{
|
||||
@@ -172,7 +180,11 @@ namespace BITFALL.Guns.States
|
||||
else if(_expectRun == false)
|
||||
{
|
||||
root.TransitionState<Movement>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentState.Speed = _entityMovement.LocomotionBasedVelocity.GetLength() / _entityMovement.ReferenceSpeed;
|
||||
}
|
||||
}
|
||||
private void OnAim(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -194,8 +206,9 @@ namespace BITFALL.Guns.States
|
||||
private ExpectState<bool> _expectSprint;
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
//root.animator.CrossFade(BITConstant.Player.Sprint, 0.32f);
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Sprint)).ToArray());
|
||||
//PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Sprint)).ToArray());
|
||||
|
||||
root.inputActionGroup.RegisterCallback(root.aimAction, OnAim);
|
||||
}
|
||||
@@ -209,6 +222,10 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
root.TransitionState<Movement>();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentState.Speed = _entityMovement.LocomotionBasedVelocity.GetLength() / _entityMovement.ReferenceSpeed;
|
||||
}
|
||||
}
|
||||
private void OnAim(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -227,17 +244,19 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
switch (old)
|
||||
{
|
||||
case IPlayerRunState:
|
||||
case IPlayerSprintState:
|
||||
//root.animator.CrossFade(BITConstant.Player.Aim, 0.32f);
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Aim)).ToArray());
|
||||
break;
|
||||
default:
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Aim)).ToArray());
|
||||
break;
|
||||
}
|
||||
// switch (old)
|
||||
// {
|
||||
// case IPlayerRunState:
|
||||
// case IPlayerSprintState:
|
||||
// //root.animator.CrossFade(BITConstant.Player.Aim, 0.32f);
|
||||
// PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Aim)).ToArray());
|
||||
// break;
|
||||
// default:
|
||||
// PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Aim)).ToArray());
|
||||
// break;
|
||||
// }
|
||||
base.OnStateEntry(old);
|
||||
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
|
||||
_entityMovement.ExecuteCommand(new PlayerLimitMoveSpeedCommand()
|
||||
@@ -267,6 +286,8 @@ namespace BITFALL.Guns.States
|
||||
root.Fire();
|
||||
}
|
||||
|
||||
equipService.Aim = currentState.Weight;
|
||||
|
||||
if (BITAppForUnity.AllowCursor)
|
||||
{
|
||||
root.TransitionState<Movement>();
|
||||
@@ -351,7 +372,7 @@ namespace BITFALL.Guns.States
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
|
||||
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
|
||||
if (root.RequireBolt)
|
||||
|
@@ -138,10 +138,10 @@ namespace BITFALL.Entities.Player.Movement.States
|
||||
{
|
||||
actor.ForceNotGrounded();
|
||||
|
||||
if (characterController.landFreeze.AllowUpdateWithoutReset is false)
|
||||
{
|
||||
currentVelocity = Vector3.Lerp(currentVelocity, default, 0.8f);
|
||||
}
|
||||
// if (characterController.landFreeze.AllowUpdateWithoutReset is false)
|
||||
// {
|
||||
// currentVelocity = Vector3.Lerp(currentVelocity, default, 0.8f);
|
||||
// }
|
||||
|
||||
currentVelocity.y+= initialJumpForce;
|
||||
|
||||
@@ -190,11 +190,18 @@ namespace BITFALL.Entities.Player.Movement.States
|
||||
// Apply added velocity
|
||||
currentVelocity += addedVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempVelocity = currentVelocity;
|
||||
tempVelocity = Vector3.Lerp(tempVelocity, default, 2*deltaTime);
|
||||
currentVelocity.x = tempVelocity.x;
|
||||
currentVelocity.z = tempVelocity.z;
|
||||
}
|
||||
// Gravity
|
||||
|
||||
currentVelocity += -Vector3.up * (30 * deltaTime);
|
||||
// Drag
|
||||
currentVelocity *= (1f / (1f + (0.1f * deltaTime)));
|
||||
currentVelocity *= (1f / (1f + 0.1f * deltaTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user