added enemy dead animation
This commit is contained in:
@@ -136,6 +136,15 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Reload"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""7bd7b761-fbb1-426d-8c5c-a9e053597a89"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
@@ -237,6 +246,17 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
""action"": ""ADS Camera"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""f7aa340a-d21d-48a8-81a9-d673d57059d8"",
|
||||
""path"": ""<Keyboard>/r"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Reload"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -250,6 +270,7 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
|
||||
m_Player_Shoot = m_Player.FindAction("Shoot", throwIfNotFound: true);
|
||||
m_Player_ADSCamera = m_Player.FindAction("ADS Camera", throwIfNotFound: true);
|
||||
m_Player_Reload = m_Player.FindAction("Reload", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@GameInputAction()
|
||||
@@ -335,6 +356,7 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
private readonly InputAction m_Player_Jump;
|
||||
private readonly InputAction m_Player_Shoot;
|
||||
private readonly InputAction m_Player_ADSCamera;
|
||||
private readonly InputAction m_Player_Reload;
|
||||
/// <summary>
|
||||
/// Provides access to input actions defined in input action map "Player".
|
||||
/// </summary>
|
||||
@@ -367,6 +389,10 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
/// </summary>
|
||||
public InputAction @ADSCamera => m_Wrapper.m_Player_ADSCamera;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Reload".
|
||||
/// </summary>
|
||||
public InputAction @Reload => m_Wrapper.m_Player_Reload;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action map instance.
|
||||
/// </summary>
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
@@ -407,6 +433,9 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
@ADSCamera.started += instance.OnADSCamera;
|
||||
@ADSCamera.performed += instance.OnADSCamera;
|
||||
@ADSCamera.canceled += instance.OnADSCamera;
|
||||
@Reload.started += instance.OnReload;
|
||||
@Reload.performed += instance.OnReload;
|
||||
@Reload.canceled += instance.OnReload;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -433,6 +462,9 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
@ADSCamera.started -= instance.OnADSCamera;
|
||||
@ADSCamera.performed -= instance.OnADSCamera;
|
||||
@ADSCamera.canceled -= instance.OnADSCamera;
|
||||
@Reload.started -= instance.OnReload;
|
||||
@Reload.performed -= instance.OnReload;
|
||||
@Reload.canceled -= instance.OnReload;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -508,5 +540,12 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnADSCamera(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Reload" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnReload(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Reload",
|
||||
"type": "Button",
|
||||
"id": "7bd7b761-fbb1-426d-8c5c-a9e053597a89",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -151,6 +160,17 @@
|
||||
"action": "ADS Camera",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f7aa340a-d21d-48a8-81a9-d673d57059d8",
|
||||
"path": "<Keyboard>/r",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Reload",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Darkmatter.Core
|
||||
bool canAttack { get; }
|
||||
string WeaponName { get; }
|
||||
public int AmmoCount { get; }
|
||||
public int maxAmmoCount { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Darkmatter.Core
|
||||
{
|
||||
public event Action OnJumpPerformed;
|
||||
public event Action OnAdsCameraSwitch;
|
||||
public event Action OnReloadPerformed;
|
||||
public Vector2 moveInput { get; }
|
||||
public Vector2 lookInput { get; }
|
||||
public bool isShooting { get; }
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Darkmatter.Core
|
||||
|
||||
public event Action OnJumpPerformed;
|
||||
public event Action OnAdsCameraSwitch;
|
||||
public event Action OnReloadPerformed;
|
||||
public bool isShooting { get; private set; }
|
||||
public Vector2 moveInput { get; private set; }
|
||||
public Vector2 lookInput { get; private set; }
|
||||
@@ -62,5 +63,13 @@ namespace Darkmatter.Core
|
||||
OnAdsCameraSwitch?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReload(InputAction.CallbackContext context)
|
||||
{
|
||||
if(context.performed)
|
||||
{
|
||||
OnReloadPerformed?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: d868e8202f5ceae4ea496e56b0db9db9, type: 3}
|
||||
m_Name: PlayerConfigSO
|
||||
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.PlayerConfigSO
|
||||
moveSpeed: 3
|
||||
moveSpeed: 2
|
||||
jumpForce: 5
|
||||
gravity: -15
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Darkmatter.Domain
|
||||
public override void Enter()
|
||||
{
|
||||
Debug.Log("Entering Player AirboneState ");
|
||||
inputReader.OnReloadPerformed += HandleManualReload;
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
@@ -22,11 +23,6 @@ namespace Darkmatter.Domain
|
||||
CheckForStateBreak();
|
||||
}
|
||||
|
||||
private void HandleShoooting()
|
||||
{
|
||||
runner.Shoot(inputReader.isShooting);
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
HandlePlayerRotation();
|
||||
@@ -35,6 +31,7 @@ namespace Darkmatter.Domain
|
||||
public override void Exit()
|
||||
{
|
||||
Debug.Log("Exiting Player AriboneState");
|
||||
inputReader.OnReloadPerformed -= HandleManualReload;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,5 +53,15 @@ namespace Darkmatter.Domain
|
||||
runner.ChangeState(new LocomotionState(runner));
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleShoooting()
|
||||
{
|
||||
runner.Shoot(inputReader.isShooting);
|
||||
}
|
||||
|
||||
private void HandleManualReload()
|
||||
{
|
||||
runner.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Darkmatter.Domain
|
||||
{
|
||||
Debug.Log("Starting player Locomotion");
|
||||
inputReader.OnJumpPerformed += HandlePlayerJump;
|
||||
inputReader.OnReloadPerformed += HandleManualReload;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@@ -24,10 +25,6 @@ namespace Darkmatter.Domain
|
||||
|
||||
}
|
||||
|
||||
private void HandleShooting()
|
||||
{
|
||||
runner.Shoot(inputReader.isShooting);
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
@@ -38,6 +35,7 @@ namespace Darkmatter.Domain
|
||||
{
|
||||
Debug.Log("Exiting Player Locomotion State");
|
||||
inputReader.OnJumpPerformed -= HandlePlayerJump;
|
||||
inputReader.OnReloadPerformed -= HandleManualReload;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +65,17 @@ namespace Darkmatter.Domain
|
||||
playerAnim.PlayJumpAnim();
|
||||
}
|
||||
|
||||
private void HandleShooting()
|
||||
{
|
||||
runner.Shoot(inputReader.isShooting);
|
||||
}
|
||||
|
||||
private void HandleManualReload()
|
||||
{
|
||||
runner.Reload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,5 +65,13 @@ namespace Darkmatter.Domain
|
||||
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
if(GunWeapon.AmmoCount < GunWeapon.maxAmmoCount)
|
||||
{
|
||||
playerAnim.PlayReloadAnim(GunWeapon);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ namespace Darkmatter.Domain
|
||||
|
||||
public abstract string WeaponName {get; }
|
||||
|
||||
public abstract void Attack();
|
||||
public virtual int AmmoCount { get; set; }
|
||||
|
||||
public virtual int AmmoCount { get; protected set; }
|
||||
public int maxAmmoCount { get; private set; } = 40;
|
||||
|
||||
public abstract void Attack();
|
||||
|
||||
public virtual void Reload()
|
||||
{
|
||||
|
||||
@@ -26,19 +26,39 @@ namespace Darkmatter.Presentation
|
||||
|
||||
IEnumerator ReloadRoutine(IWeapon currentWeapon)
|
||||
{
|
||||
animator.SetLayerWeight(1, 1);
|
||||
yield return BlendLayerWeight(1, 1, 0.2f);
|
||||
//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);
|
||||
// animator.SetLayerWeight(1, 0);
|
||||
yield return BlendLayerWeight(1, 0, 0.2f);
|
||||
HandOnGunIK.weight = 1f;
|
||||
currentWeapon.Reload();
|
||||
reloadCoroutine = null;
|
||||
|
||||
}
|
||||
|
||||
IEnumerator BlendLayerWeight(int layerIndex, float targetWeight, float blendTime)
|
||||
{
|
||||
float startWeight = animator.GetLayerWeight(layerIndex);
|
||||
float time = 0f;
|
||||
|
||||
while (time < blendTime)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
float t = time / blendTime;
|
||||
float weight = Mathf.Lerp(startWeight, targetWeight, t);
|
||||
animator.SetLayerWeight(layerIndex, weight);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
animator.SetLayerWeight(layerIndex, targetWeight);
|
||||
}
|
||||
|
||||
|
||||
public void PlayShootAnim()
|
||||
{
|
||||
Debug.Log("player Shoot");
|
||||
|
||||
@@ -7,19 +7,24 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
public float health = 100f;
|
||||
public Animator enemyAnimator;
|
||||
public bool isDead = false;
|
||||
public void Die()
|
||||
{
|
||||
isDead = true;
|
||||
Debug.Log("Dead");
|
||||
this.gameObject.SetActive(false);
|
||||
enemyAnimator.SetLayerWeight(0, 1);
|
||||
enemyAnimator.SetTrigger("Death");
|
||||
Destroy(this.gameObject, 5f);
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
{ if(isDead) return;
|
||||
health -= damage;
|
||||
enemyAnimator.SetLayerWeight(1, 1);
|
||||
enemyAnimator.SetTrigger("Hit");
|
||||
if (health <= 0) Die();
|
||||
Debug.Log("Damage Taken");
|
||||
|
||||
enemyAnimator.SetLayerWeight(1, 1);
|
||||
enemyAnimator.SetTrigger("Hit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,14 @@ namespace Darkmatter.Presentation
|
||||
|
||||
[Header("Weapon Data")]
|
||||
public float fireRate = 0.1f;
|
||||
public override int AmmoCount { get; protected set; } = 40;
|
||||
[SerializeField] private int ammoCount = 40;
|
||||
private float lastUsedTime;
|
||||
public GameObject BulletHole;
|
||||
public override string WeaponName => "Rifel";
|
||||
public override int AmmoCount { get => this.ammoCount; set => ammoCount = value; }
|
||||
|
||||
|
||||
public override bool canAttack => Time.time >= lastUsedTime + fireRate && AmmoCount > 0;
|
||||
public override bool canAttack => Time.time >= lastUsedTime + fireRate && ammoCount > 0;
|
||||
|
||||
[Inject] private ITargetProvider targetProvider;
|
||||
private RaycastHit hitPoint => targetProvider.hitPoint;
|
||||
@@ -30,7 +31,7 @@ namespace Darkmatter.Presentation
|
||||
public override void Attack()
|
||||
{
|
||||
lastUsedTime = Time.time;
|
||||
AmmoCount--;
|
||||
ammoCount--;
|
||||
|
||||
PlayMuzzleFlash();
|
||||
if (hitPoint.transform != null) PlayBulletHitEffectParticle();
|
||||
@@ -61,7 +62,7 @@ namespace Darkmatter.Presentation
|
||||
public override void Reload()
|
||||
{
|
||||
base.Reload();
|
||||
AmmoCount = 40;
|
||||
ammoCount = maxAmmoCount;
|
||||
}
|
||||
|
||||
private void PlayMuzzleFlash()
|
||||
|
||||
Reference in New Issue
Block a user