private void BombLauncherShooting() { if (ManageGame.instance.IsTimingDown == true) { //Bomb Launcher Shooting - Ammo Consumption if (Input.GetButton("Shoot" + Player.playerNum)) { if (Ammo > 0) { if (/*CanShoot == true &&*/ hasShot == false) { audioHandler.SetSFX("Pop"); GameObject bomb = bombPool.GetPooledObject(); bomb.transform.rotation = GunMuzzle.transform.rotation; bomb.transform.position = GunMuzzle.transform.position; bomb.GetComponent <Bomb>().SetParent(PlayerBase); bomb.SetActive(true); StartCoroutine(BombLaunchedDelay()); } } } //Reseting to Default Weapon when no ammo left if (Ammo <= 0) { PlayerBase.ResetWeapon(); PlayerBase.DefaultWeaponSet(); } } }
private void InputSelect() { audioHandler.SetSFX("Accept"); if (selectId == 0) { StartCoroutine("CameraDown"); } else if (selectId == 1) { doorAnimation.enabled = true; doorAnimation.speed = animationSpeed; doorAnimation.SetInteger("DoorAnim", 0); StartCoroutine("CameraIn"); } else if (selectId == 2) { quitPanel.gameObject.SetActive(true); canPressBtn = false; } }
private void RicochetShooting() { if (ManageGame.instance.IsTimingDown == true) { //Using right Bumper if (Input.GetButtonDown("Shoot" + Player.playerNum)) { if (Ammo > 0) { if (CanShoot == true) { //if it's equal to false if (IsAxisInUse == false) { audioHandler.SetSFX("RicochetShoot"); Ammo -= ricochetAmmoConsumption; UpdateFillBar(); if (ManageGame.instance.IsTimingDown == true) { Debug.Log("Shooting"); GameObject newBullet = bullets.GetPooledObject(); newBullet.transform.position = GunMuzzle.transform.position; newBullet.transform.rotation = GunMuzzle.transform.rotation; newBullet.GetComponent <Bullet>().SetPlayerId(Player); newBullet.gameObject.SetActive(true); } IsAxisInUse = true; } } } if (Input.GetButton("Shoot" + Player.playerNum)) { IsAxisInUse = false; } } //Reseting to Default Weapon when no ammo left if (Ammo <= 0) { PlayerBase.ResetWeapon(); PlayerBase.DefaultWeaponSet(); } } }
private void DefaultWeapon() { if (ManageGame.instance.IsTimingDown == true) { if (Input.GetButtonDown("Shoot" + Player.playerNum)) { //TODO: Change color of particle based on player if (Ammo > 0) { Particle.Play(); } } else if (Input.GetButtonUp("Shoot" + Player.playerNum)) { Particle.Stop(); audioHandler.StopSFX("Spray"); canPlaySplat = true; } //Using right Bumper - Ammo Consumption if (Input.GetButton("Shoot" + Player.playerNum) && !reloading) { if (Ammo > 0) { if (!Particle.isPlaying) { Particle.Play(); } if (dazeState.CanShoot == true) { //if it's equal to false if (IsAxisInUse == false) { if (canPlaySplat) { audioHandler.SetSFX("Spray"); StartCoroutine(SplatSFXCooldown()); } range += rangeRateIncrease * Time.deltaTime; //Debug.Log(range); if (range > maxRange) { range = maxRange; } Ammo -= (ammoConsumption - (AmmoConsumptionModifier)) * Time.deltaTime; UpdateFillBar(); Vector3 _lineOffset = ray.direction * range; ray = new Ray(GunMuzzle.transform.position, GunMuzzle.transform.forward); Debug.DrawRay(GunMuzzle.transform.position, GunMuzzle.transform.forward * range, Color.green); if (ManageGame.instance.IsTimingDown == true) { Vector3 _endRayCopy = ray.origin + range * ray.direction; if (Physics.Raycast(ray, out hit, range)) { CollideWith(hit.collider.gameObject.tag, PlayerBase); } else { for (int i = 0; i < anglePrecision; i++) { //rotation is bugged at some angles, replace "parent.transform.up" if fixed //var _rotation = Quaternion.Euler(0, 0, 30) * parent.transform.up; Ray _newRay = new Ray(_endRayCopy, (this.transform.forward - this.transform.up).normalized); Debug.DrawRay(_newRay.origin, _newRay.direction * range, Color.blue); if (Physics.Raycast(_newRay, out hit, range)) { CollideWith(hit.collider.gameObject.tag, PlayerBase); i = anglePrecision; return; } _endRayCopy = _newRay.origin + _newRay.direction * 1; } } } IsAxisInUse = true; } } } else { if (Particle.isPlaying) { Particle.Stop(); audioHandler.StopSFX("Spray"); canPlaySplat = true; } reloading = true; } if (Input.GetButton("Shoot" + Player.playerNum)) { IsAxisInUse = false; } } //Ammo Regeneration if (!Input.GetButton("Shoot" + Player.playerNum)) { range = 1.0f; //Resetting Range when player isnt pressing button Ammo += (ammoRegeneration + (AmmoRegenModifier)) * Time.deltaTime; //Setting Maximum Cap on player ammo if (Ammo >= 100) { Ammo = 100; } UpdateFillBar(); } else if (Input.GetButton("Shoot" + Player.playerNum) && reloading) { range = 1.0f; //Resetting Range when player isnt pressing button Ammo += (ammoRegeneration + (AmmoRegenModifier)) * Time.deltaTime; //Setting Maximum Cap on player ammo if (Ammo >= 100) { Ammo = 100; reloading = false; } UpdateFillBar(); } } }
private void Update() { if (ManageGame.instance.IsTimingDown == true) { if (Input.GetButtonDown("Shoot" + Player.playerNum)) { //TODO: Change color of particle based on player if (Ammo > 0) { Particle.Play(); rightParticle.Play(); } } else if (Input.GetButtonUp("Shoot" + Player.playerNum)) { Particle.Stop(); rightParticle.Stop(); audioHandler.StopSFX("Spray"); } if (Input.GetButton("Shoot" + Player.playerNum)) { IsAxisInUse = false; if (Ammo > 0) { if (dazeState.CanShoot == true) { if (IsAxisInUse == false) { if (canPlaySplat) { audioHandler.SetSFX("Spray"); StartCoroutine(SplatSFXCooldown()); } if (range > maxRange) { range = maxRange; } Ammo -= (ammoConsumption - (AmmoConsumptionModifier)) * Time.deltaTime; TwinSprayShooting(); TwinShootTwo(); UpdateFillBar(); if (!Input.GetButton("Shoot" + Player.playerNum)) { range = 1.0f; //Resetting Range when player isnt pressing button Ammo += (ammoRegeneration + (AmmoRegenModifier)) * Time.deltaTime; //Setting Maximum Cap on player ammo if (Ammo >= 100) { Ammo = 100; } UpdateFillBar(); } } } } else { if (Particle.isPlaying) { Particle.Stop(); rightParticle.Stop(); audioHandler.StopSFX("Spray"); } } } if (Ammo <= 0) { PlayerBase.ResetWeapon(); PlayerBase.DefaultWeaponSet(); } } }