void Update() { if (fBulletsFired > fOverHeatRate) { fBulletsFired = fOverHeatRate; } if (Input.GetKey(KeyCode.F) && weaponManager.go_CurrentWeapon.name == this.name && blackBoard.fPlayerHealth > 0 && fBulletsFired > 0 && bCanShoot == true) { fBulletsFired--; StartCoroutine("FireRate"); ShootSound.Play(); fLastShot = Time.time; } else if (!Input.GetKey(KeyCode.F) && fBulletsFired <= fOverHeatRate && bRecharging == false) { Debug.Log("Recharging"); StartCoroutine("Recharge"); } else if (fBulletsFired <= 0) { StartCoroutine("CoolDown"); } }
public override void Update(GameTime gameTime) { if (Helper.CurrentGameStatus == GameStatus.PLAYING) { PreviousPosition = PixelPosition; OrbLight.Position = new Vector2(CentrePos.X, CentrePos.Y) - Camera.CamPos; switch (projectileState) { case PROJECTILE_STATUS.Idle: this.Visible = false; OrbLight.Enabled = false; break; case PROJECTILE_STATUS.Firing: flyTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; this.Visible = true; this.gotDirection = false; this.PixelPosition += (Direction * Velocity); OrbLight.Enabled = true; OrbLight.Scale = defaultScale; FaceThis(gameTime); CollisionCheck(); // Play sounds if (!ShootSoundPlayed) { ShootSound.Play(); ShootSoundPlayed = true; } break; case PROJECTILE_STATUS.Exploding: this.Visible = false; ShootSoundPlayed = false; OrbLight.Scale = defaultScale * 2; timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (timer > explosionLifeSpan - explosionLifeSpan + 0.1f) { OrbLight.Enabled = false; } if (timer > explosionLifeSpan) { timer = 0f; // Reload Projectile projectileState = PROJECTILE_STATUS.Idle; } break; } base.Update(gameTime); } }
static public void PlayShootSound() { ShootSound.Play(); }