private void Fire() { if (!gameSession.isPlayerAlive) { return; } if (gameSession.gunAllow) { // Check if player holds gun gameSession.AimBigContr(); if (gameSession.pistolAmmo > 0 && avoidBulletRep) { avoidBulletRep = false; gameSession.DecreasePistolAmmo(); // Check if player is running or standing while shooting if (myRigidBody.velocity.x == 0) { myAnim.SetBool("Shooting", true); myAnim.SetBool("ShootingWR", false); } else { myAnim.SetBool("ShootingWR", true); myAnim.SetBool("Shooting", false); } Vector2 bulPos; Vector2 shellPos; Vector2 fireDustPos; if (transform.localScale.x == 1) { bulPos = new Vector2(transform.position.x + 0.20f, transform.position.y - 0.1f); fireDustPos = new Vector2(transform.position.x + 0.23f, transform.position.y + 0.07f); shellPos = new Vector2(transform.position.x + 0.13f, transform.position.y - 0.44f); } else { bulPos = new Vector2(transform.position.x - 0.20f, transform.position.y - 0.1f); fireDustPos = new Vector2(transform.position.x - 0.23f, transform.position.y + 0.07f); shellPos = new Vector2(transform.position.x - 0.13f, transform.position.y - 0.44f); } Instantiate(bullet, bulPos, Quaternion.identity); Instantiate(fireDust, fireDustPos, Quaternion.identity); Instantiate(shell, shellPos, Quaternion.identity); Invoke("SetBackBulletRep", 0.3f); } else { myAnim.SetBool("ShootingWR", false); myAnim.SetBool("Shooting", false); if (gameSession.pistolAmmo <= 0) { myAudioSource.clip = emptyGun; myAudioSource.volume = 0.2f; myAudioSource.Play(); /// Change color of pistol ammo text gameSession.ChangeColorForPistolAmmo(); } } } // Pistol shooting check ends here // Shotgun check begins else if (gameSession.shotgunAllow) { gameSession.AimBigContr(); if (gameSession.shotgunAmmo > 0 && avoidBulletRep) { avoidBulletRep = false; gameSession.DecreaseShotgunAmmo(); // Check if player is running or standing while shooting if (myRigidBody.velocity.x == 0) { myAnim.SetBool("ShotgunShooting", true); myAnim.SetBool("ShotgunShootingWR", false); } else { myAnim.SetBool("ShotgunShootingWR", true); myAnim.SetBool("ShotgunShooting", false); } Vector2 shotgunBulPos; Vector2 shellPos; Vector2 fireDustPos; if (transform.localScale.x == 1) { shotgunBulPos = new Vector2(transform.position.x + 0.41f, transform.position.y - 0.1f); fireDustPos = new Vector2(transform.position.x + 0.41f, transform.position.y + 0.07f); shellPos = new Vector2(transform.position.x + 0.13f, transform.position.y - 0.44f); } else { shotgunBulPos = new Vector2(transform.position.x - 0.41f, transform.position.y - 0.1f); fireDustPos = new Vector2(transform.position.x - 0.41f, transform.position.y + 0.07f); shellPos = new Vector2(transform.position.x - 0.13f, transform.position.y - 0.44f); } Instantiate(shotgunBullet, shotgunBulPos, Quaternion.identity); Instantiate(shotgunFireDust, fireDustPos, Quaternion.identity); Instantiate(shotgunShell, shellPos, Quaternion.identity); Invoke("SetBackBulletRep", 0.3f); } else { myAnim.SetBool("ShotgunShootingWR", false); myAnim.SetBool("ShotgunShooting", false); if (gameSession.shotgunAmmo <= 0) { myAudioSource.clip = emptyGun; myAudioSource.volume = 0.2f; myAudioSource.Play(); /// Change color of shotgun ammo text gameSession.ChangeColorForShotgunAmmo(); } } } }