private void Shoot() { if (shotTimer <= 0) { if (CustomInput.BoolHeld(CustomInput.UserInput.Shoot2)) { GameObject b = BulletPool.Instance.GetBullet(BulletPool.BulletTypes.Basic); if (b != null) { fireGun.Play(); b.transform.position = this.barrel.position; b.transform.rotation = Quaternion.Euler(0, 0, Vector2.SignedAngle(Vector2.right, this.aimDir)); this.shotTimer = this.shotTime; } } else if (CustomInput.BoolHeld(CustomInput.UserInput.Shoot1)) { if (this.prevBullet == null || !this.prevBullet.gameObject.activeSelf) { GameObject b = BulletPool.Instance.GetBullet(BulletPool.BulletTypes.Space); if (b != null) { fireSpaceGun.Play(); b.transform.position = this.barrel.position; b.transform.rotation = Quaternion.Euler(0, 0, Vector2.SignedAngle(Vector2.right, this.aimDir)); this.prevBullet = b.GetComponent <SpaceBullet>(); this.shotTimer = this.spaceTime; } } } } }
private void Update() { if (Managers.GameManager.Instance.IsPaused) { return; } if (this.player.IsDead) { this.anim.SetBool(this.aimHash, false); this.anim.SetBool(this.shootHash, false); return; } bool shouldAim = ShouldAim(); if (shouldAim) { this.aimDir = GetAimDir(); CalculateClipSet(Vector2.SignedAngle(Vector2.right, this.aimDir)); } bool shouldShoot = false; if (this.shotTimer > 0) { this.shotTimer -= Time.deltaTime; } if (CustomInput.BoolHeld(CustomInput.UserInput.Shoot1) || CustomInput.BoolHeld(CustomInput.UserInput.Shoot2)) { shouldShoot = true; } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot1)) { if (this.prevBullet != null && this.prevBullet.gameObject.activeSelf) { this.prevBullet.Detonate(); this.prevBullet = null; this.shotTimer = this.spaceTime / 2f; } } this.anim.SetBool(this.aimHash, shouldAim); this.anim.SetBool(this.shootHash, shouldShoot); this.currentState = this.mapper.GetCurrentState(); switch (this.currentState) { case State.Idle: Idle(); break; case State.Aim: Aim(); break; case State.Shoot: Shoot(); break; } }