Jukebox.Update C# (CSharp) Method

Update() private method

private Update ( ) : void
return void
    void Update()
    {
        //Transition sound handler
        if (diff != jukebox.clip) {
            if(jukebox.clip == death && !menuSwap){
                jukebox.PlayOneShot(toDeath, 1);
                jukebox.PlayDelayed(2.9f);
            } else if(jukebox.clip == HYPE && !menuSwap){
                jukebox.PlayOneShot(toHYPE, 1);
                jukebox.PlayDelayed(1.5f);
            } else if(jukebox.clip == gameFast && !menuSwap){
                jukebox.PlayOneShot(toFaster, 1);
                jukebox.PlayDelayed(.8f);
            } else {
                jukebox.Play();
            }
            diff = jukebox.clip;
            menuSwap = false;
        }
        //Change clips to the correct track
        //Cowboy
        if (trackNo == 0) {
            trackName = "Cowboy";
            title = Cowboy[0];
            gameReg = Cowboy[1];
            gameFast = Cowboy[2];
            HYPE = Cowboy[3];
            death = Cowboy[4];
        }
        //8-BIT
        if (trackNo == 1) {
            trackName = "8-Bit";
            title = EightBit[0];
            gameReg = EightBit[1];
            gameFast = EightBit[2];
            HYPE = EightBit[3];
            death = EightBit[4];
        }

        //Audio state switcher
        if (player.GetComponent<playerCharacter>().currentHealth <= 0 || player.transform.position.y < -5f) {
            jukebox.clip = death;
        }
        else if (ScoreKeeper.HYPED) {
            jukebox.clip = HYPE;
        }
        else if (ScoreKeeper.CarsCompleted >= 1) {
            jukebox.clip = gameFast;
        }
        else {
            jukebox.clip = gameReg;
        }
    }

Usage Example

示例#1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            Container?.Update(gameTime);
            Jukebox.Update(gameTime);

            if (DialogManager.Dialogs.Count != 0)
            {
                Searchbox.Focused = false;
            }
        }