add sniper
This commit is contained in:
@@ -7,6 +7,7 @@ using BITKit.Animations;
|
||||
using BITKit.StateMachine;
|
||||
using System.Linq;
|
||||
using System.Security.Permissions;
|
||||
using AYellowpaper.SerializedCollections;
|
||||
using BITFALL;
|
||||
using BITFALL.Entities.Equipment;
|
||||
using BITFALL.Player.Equip;
|
||||
@@ -23,6 +24,9 @@ namespace BITKit.Entities
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] protected AssetableItem item;
|
||||
|
||||
[Header(Constant.Header.Property)]
|
||||
[SerializeField] public SerializedDictionary<string,AnimationProperty> animationProperties;
|
||||
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] public UnityAnimator animator;
|
||||
[SerializeField] protected EntityVFXPlayer vfxPlayer;
|
||||
@@ -36,6 +40,8 @@ namespace BITKit.Entities
|
||||
public Entities.IEntity Entity { get; set; }
|
||||
public Entity UnityEntity=>Entity as Entity;
|
||||
public IBasicItem Item { get; set; }
|
||||
|
||||
public IDictionary<string,float> AnimationProperties => animationProperties.ToDictionary(x=>x.Key,x=>x.Value.Value);
|
||||
|
||||
public readonly InputActionGroup inputActionGroup = new()
|
||||
{
|
||||
@@ -49,6 +55,9 @@ namespace BITKit.Entities
|
||||
|
||||
public virtual void Entry()
|
||||
{
|
||||
if (animator)
|
||||
animator.enabled = true;
|
||||
|
||||
AllowRendering.AddElement(this);
|
||||
inputActionGroup.allowInput.AddElement(this);
|
||||
|
||||
@@ -79,6 +88,7 @@ namespace BITKit.Entities
|
||||
|
||||
inputActionGroup.allowInput.RemoveElement(this);
|
||||
}
|
||||
|
||||
public virtual UniTask ExitAsync()
|
||||
{
|
||||
AllowRendering.RemoveElement(this);
|
||||
@@ -87,16 +97,17 @@ namespace BITKit.Entities
|
||||
cameraTransform.localPosition = default;
|
||||
cameraTransform.localRotation = _initialCameraRotation;
|
||||
}
|
||||
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void OnAwake()
|
||||
{
|
||||
AllowRendering.AddListener(x => renderers.ForEach(y =>
|
||||
{
|
||||
y.enabled = x;
|
||||
animator.enabled = x;
|
||||
}));
|
||||
AllowRendering.AddListener(x => renderers.ForEach(y => { y.enabled = x; }));
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
AllowRendering.Invoke();
|
||||
if (cameraTransform is not null)
|
||||
_initialCameraRotation = cameraTransform.localRotation;
|
||||
@@ -152,13 +163,16 @@ namespace BITKit.Entities
|
||||
public class EntityEquipment : EntityBehavior,IEquipService,IEntityEquipment
|
||||
{
|
||||
public IOptional<float> Zoom { get; } = new Optional<float>(){Value = 1};
|
||||
|
||||
public float InitialFov;
|
||||
public float Stable { get; set; }
|
||||
public bool AllowAttack { get; set; }
|
||||
public bool AllowScope { get; set; }
|
||||
|
||||
[SerializeField] private CinemachineVirtualCamera virtualCamera;
|
||||
|
||||
[SerializeField] private Optional<int> overrideIndex;
|
||||
|
||||
[SerializeField] private AnimationCurve zoomCurve;
|
||||
|
||||
public event Action<IBasicItem> OnEquip;
|
||||
public event Action<IBasicItem> OnUnEquip;
|
||||
public event Action<string> OnEquipAddressable;
|
||||
@@ -230,10 +244,7 @@ namespace BITKit.Entities
|
||||
|
||||
if (virtualCamera is not null)
|
||||
{
|
||||
var current = virtualCamera.m_Lens.FieldOfView;
|
||||
current= Mathf.Lerp(current,Zoom.Allow ? InitialFov / Zoom.Value : PlayerConfig.Singleton.Fov , deltaTime * 5);
|
||||
current = Mathf.Clamp(current, 10, PlayerConfig.Singleton.Fov);
|
||||
virtualCamera.m_Lens.FieldOfView = current;
|
||||
virtualCamera.m_Lens.FieldOfView =zoomCurve.Evaluate(Zoom.Allow?Zoom.Value:0);
|
||||
}
|
||||
|
||||
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
|
||||
|
@@ -51,13 +51,15 @@ namespace BITKit.Entities
|
||||
}
|
||||
private void Melee(int _damage)
|
||||
{
|
||||
var forward = Transform.forward;
|
||||
meleeService.Melee(new MeleeCommand()
|
||||
{
|
||||
PlayerId = Entity.Id,
|
||||
Position = Transform.position + Vector3.up,
|
||||
Force = Transform.forward * 128,
|
||||
Force = forward * 128,
|
||||
Range = 1.6f,
|
||||
Damage = _damage,
|
||||
Forward = forward
|
||||
});
|
||||
unityAnimator.Play("Attack");
|
||||
//entity.Invoke(Constant.Animation.Play, "Melee");
|
||||
|
Reference in New Issue
Block a user