예제 #1
0
    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");
        }
    }
예제 #2
0
        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);
            }
        }
예제 #3
0
 static public void PlayShootSound()
 {
     ShootSound.Play();
 }