48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using Darkmatter.Core;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.Animations.Rigging;
|
|
using VContainer;
|
|
|
|
namespace Darkmatter.Presentation
|
|
{
|
|
public class PlayerAnimController : HumonoidAnim, IPlayerAnim
|
|
{
|
|
private readonly int shootHash = Animator.StringToHash("IsShooting");
|
|
private readonly int reloadHash = Animator.StringToHash("Reload");
|
|
public TwoBoneIKConstraint HandOnGunIK; //for gunHand Ik
|
|
private Coroutine reloadCoroutine;
|
|
|
|
public void PlayReloadAnim(IWeapon currentWeapon)
|
|
{
|
|
if (reloadCoroutine == null)
|
|
{
|
|
reloadCoroutine = StartCoroutine(ReloadRoutine(currentWeapon));
|
|
}
|
|
}
|
|
|
|
IEnumerator ReloadRoutine(IWeapon currentWeapon)
|
|
{
|
|
animator.SetLayerWeight(1, 1);
|
|
HandOnGunIK.weight = 0f;
|
|
animator.SetTrigger(reloadHash);
|
|
|
|
yield return new WaitForSeconds(3f); //gave the length of the animation very bad practice
|
|
|
|
animator.SetLayerWeight(1, 0);
|
|
HandOnGunIK.weight = 1f;
|
|
currentWeapon.Reload();
|
|
reloadCoroutine = null;
|
|
|
|
}
|
|
|
|
public void PlayShootAnim()
|
|
{
|
|
Debug.Log("player Shoot");
|
|
}
|
|
}
|
|
}
|