64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using BITFALL.Entities;
|
|
using BITFALL.Player.Equip;
|
|
using BITFALL.Player.Movement;
|
|
using BITKit;
|
|
using BITKit.Animations;
|
|
using BITKit.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Feel
|
|
{
|
|
public sealed class PlayerHandAnimations : EntityBehavior
|
|
{
|
|
[SerializeField] private AnimancerComponent animancerComponent;
|
|
|
|
[Inject]
|
|
private IPlayerMovement _playerMovement;
|
|
[Inject]
|
|
private IKnockdown _knockdown;
|
|
[Inject]
|
|
private IEquipService _equipService;
|
|
|
|
[SerializeField] private AnimationClip[] knockdownClips;
|
|
[SerializeField] private AnimationClip[] parachuteClips;
|
|
[SerializeField] private AnimationClip[] parachuteClosedClips;
|
|
public override void OnStart()
|
|
{
|
|
_playerMovement.OnParachuteOpened += OnParachuteOpened;
|
|
_playerMovement.OnParachuteClosed += OnParachuteClosed;
|
|
_knockdown.OnKnockdown += OnKnockdown;
|
|
}
|
|
|
|
private void OnKnockdown()
|
|
{
|
|
if (knockdownClips?.Length is 0) return;
|
|
var clip = knockdownClips.Random();
|
|
animancerComponent.Play(clip).Events.OnEnd = OnEnd;
|
|
_equipService.AllowEquip.AddDisableElements(this);
|
|
}
|
|
private void OnParachuteClosed()
|
|
{
|
|
if (parachuteClosedClips?.Length is 0) return;
|
|
var clip = parachuteClosedClips.Random();
|
|
animancerComponent.Play(clip).Events.OnEnd = OnEnd;
|
|
_equipService.AllowEquip.AddDisableElements(this);
|
|
}
|
|
private void OnParachuteOpened()
|
|
{
|
|
if (parachuteClips?.Length is 0) return;
|
|
var clip = parachuteClips.Random();
|
|
animancerComponent.Play(clip).Events.OnEnd = OnEnd;
|
|
_equipService.AllowEquip.AddDisableElements(this);
|
|
}
|
|
private void OnEnd()
|
|
{
|
|
_equipService.AllowEquip.RemoveDisableElements(this);
|
|
animancerComponent.Stop();
|
|
}
|
|
}
|
|
|
|
}
|