// Update is called once per frame void Update() { enemyAnimator.SetInteger("WalkingMode", VelocityToWalkingMode(enemyBrain.legs.GetEnemyVelocity())); enemyAnimator.SetBool("Equiped", enemyBrain.arms.GetWeaponOut()); enemyAnimator.SetInteger("WeaponMode", (int)enemyBrain.arms.GetEquipedWeapon().weaponType); enemyAnimator.SetBool("Aim", enemyBrain.arms.IsAimingWithWeapon()); //If we aim, do we shoot ? if (enemyBrain.arms.IsAimingWithWeapon()) { //Shoot if (enemyBrain.arms.IsShootingWithWeapon()) { Weapon.ShootOutput output = enemyBrain.arms.GetEquipedWeapon().GetShootOutput(); switch (output) { //Shoot is valid, we do anim shoot ! case Weapon.ShootOutput.VALID: enemyAnimator.SetBool("Shoot", true); enemyAnimator.SetTrigger("TriggerPulled"); break; //Oups, we need to reload, play reload animation case Weapon.ShootOutput.RELOAD: enemyAnimator.SetBool("Shoot", false); enemyAnimator.SetTrigger("Reload"); break; } } else { //We stop the shoot animation in case it's a loop (machine gun) enemyAnimator.SetBool("Shoot", false); } } if (lastCurrentLife != enemyHitbox.getCurrentLife() && enemyHitbox.getCurrentLife() > 0f) { enemyAnimator.SetTrigger("Hurt"); lastCurrentLife = enemyHitbox.getCurrentLife(); } }
public void UpdateShootBehavior() { Weapon.ShootOutput output = GetEquipedWeapon().Shoot(); switch (output) { case Weapon.ShootOutput.VALID: SoundManager.instance.play(GetEquipedWeapon().shootSound, transform.position, SoundManager.AudioType.SOUND); break; case Weapon.ShootOutput.EMPTY: SoundManager.instance.play("EmptyAmmo", transform.position, SoundManager.AudioType.SOUND); break; case Weapon.ShootOutput.RELOAD: SoundManager.instance.play("Reload", transform.position, SoundManager.AudioType.SOUND); break; } }
public void Shoot() { Weapon.ShootOutput output = equipedWeapon.Shoot(); switch (output) { case Weapon.ShootOutput.VALID: SoundManager.instance.play(equipedWeapon.shootSound, transform.position, SoundManager.AudioType.SOUND); break; case Weapon.ShootOutput.EMPTY: SoundManager.instance.play("EmptyAmmo", transform.position, SoundManager.AudioType.SOUND); break; case Weapon.ShootOutput.RELOAD: SoundManager.instance.play("Reload", transform.position, SoundManager.AudioType.SOUND); break; } isShooting = true; }
// Update is called once per frame void Update() { playerAnimator.SetInteger("WalkingMode", VelocityToWalkingMode(playerBehaviour.GetPlayerVelocity())); playerAnimator.SetBool("Equiped", playerBehaviour.GetEquipedWeapon() != null); isCollidingWithWall = playerBehaviour.GetPlayerWallMovement() >= PlayerBehaviour.PlayerWallMovement.COLLIDE; playerAnimator.SetBool("AgainstAWall", isCollidingWithWall); if (isCollidingWithWall) { playerAnimator.SetBool("OrientedRight", playerBehaviour.isPlayerMovingRight()); playerAnimator.SetBool("Look", playerBehaviour.GetPlayerWallMovement() == PlayerBehaviour.PlayerWallMovement.LOOK); } if (playerBehaviour.GetEquipedWeapon() != null) { playerAnimator.SetInteger("WeaponMode", (int)playerBehaviour.GetEquipedWeapon().weaponType); playerAnimator.SetBool("Aim", Input.GetButton("Aim")); //If we aim, do we shoot ? if (Input.GetButton("Aim")) { //Shoot if (Input.GetButtonDown("Shoot")) { Weapon.ShootOutput output = playerBehaviour.GetEquipedWeapon().GetShootOutput(); switch (output) { //Shoot is valid, we do anim shoot ! case Weapon.ShootOutput.VALID: playerAnimator.SetBool("Shoot", true); playerAnimator.SetTrigger("TriggerPulled"); break; //Oups, we need to reload, play reload animation case Weapon.ShootOutput.RELOAD: playerAnimator.SetBool("Shoot", false); playerAnimator.SetTrigger("Reload"); break; } } //We stop the shoot animation in case it's a loop (machine gun) if (Input.GetButtonUp("Shoot")) { playerAnimator.SetBool("Shoot", false); } } else { //If we are not aiming but clic the shoot button, it reloads the weapon if (Input.GetButtonDown("Shoot") && playerBehaviour.GetEquipedWeapon().GetShootOutput() == Weapon.ShootOutput.RELOAD) { playerAnimator.SetTrigger("Reload"); } } } if (lastCurrentLife != playerHitbox.getCurrentLife() && playerHitbox.getCurrentLife() > 0f) { playerAnimator.SetTrigger("Hurt"); lastCurrentLife = playerHitbox.getCurrentLife(); } }