Forgotten Empires
  • Welcome!
  • Getting Started
  • Why On Chain Game?
  • Why MINA?
  • Architecture of Forgotten Empires
  • Prerequisites
  • Building Forgotten Empires to Unity
  • Game
    • Unity
      • Component
        • Type
          • Animation Type
          • Music Type
          • State Type
          • VFX Type
      • Entity
        • Element
          • Component
            • Enemy
              • Enemy Worker
                • Enemy Animation
                • Enemy Behaviour
                  • Component
                    • Enemy Attack Behaviour
                    • Enemy Attack Stance Behaviour
                    • Enemy Idle Behaviour
            • NPC
              • Citizen
              • Merchant
                • Merchant Interaction
                • Merchant Trade
                • Merchant Trigger
                • Merchant UI
                • Merchant Update
            • Player
              • Player Animation
              • Player Attack
              • Player Camera
              • Player Damage
              • Player Economy
              • Player Fixed Update
              • Player Input
                • Player Attack Input
                • Player Movement Input
                • Player Rotation Input
              • Player Interaction
              • Unity Late Update
              • Player Inventory
                • Player Inventory Slot
              • Player Movement
              • Player Quest
              • Player Rotation
                • Player Attack Rotation
                • Player Movement Rotation
              • Player Start
              • Player State
              • Player Stats
                • Player On Chain Stats
              • Player Trails
              • Player Update
              • Player VFX
          • Element Worker
            • Element Effect
            • Element Event
            • Element Stats
            • Element Update
        • Item
          • Potion
          • Shield
          • Sword
        • Kingdom
      • Manager
        • Client Manager
          • Client Manager Worker
            • Client Login Worker
            • Client Music Manager
            • Client Start Worker
            • Client UI Worker
            • Client Update Worker
        • Server Manager
          • Server Manager Worker
            • Server Day Night Worker
            • Server Enemy Worker
            • Server Kingdom Worker
            • Server Object Pool Worker
            • Server Player Worker
            • Server Start Worker
            • Server Update Worker
    • o1js
      • Player
      • Item
      • Character
    • o1js Tests
Powered by GitBook
On this page
  1. Game
  2. Unity
  3. Manager
  4. Client Manager
  5. Client Manager Worker

Client Music Manager

Last updated 1 year ago

CtrlK

The ClientMusicWorker is responsible for managing the music within the game client.

Properties

  • private AudioSource audioSource: References the AudioSource component used for playing music.

  • private List<AudioClip> currentAudioList, mainMusicList, travelMusicList, battleMusicList: Represents the collections of audio clips for different contexts.

private MusicType musicType: Represents current type of music being played.

  • private bool isMusicChanging: Represents whether a music transition is in progress.

  • private MusicType latestRequestedMusicType: Represents the most recently requested music type.

  • Methods

    • public void OnStart(): Initiates music playback by calling ChangeMusic.

    • public void OnUpdate(): Checks if the music has stopped and, if so, starts a new track by calling ChangeMusic at every frame.

    • private void UpdateMusicType(MusicType musicType): Updates the current music type and sets the currentAudioList based on the new type.

    • public void ChangeMusicType(MusicType musicType): Initiates a change in the music type. If a transition is already in progress, it stores the requested type for later processing.

    • private IEnumerator ChangeMusic(): A coroutine for changing the music. It fades out the current track, selects a new track from the appropriate list based on the current musicType, and fades the new track in.

    • private List<AudioClip> GetAudioList(): Returns the appropriate list of audio clips based on the current musicType.