示例#1
0
    public void Right(int myType)
    {
        if (!_manager.PlayerReady())
        {
            return;
        }
        if ((MusicTypes)myType != current_type || inTransition)
        {
            return;
        }

        menu_animator.SetTrigger("Right");
        inTransition = true;

        int new_type = myType - 1;

        current_type = new_type < 0 ? (MusicTypes)new_type + 3 : (MusicTypes)new_type;
        _manager.SetColors((float)current_type / 3F);
        _manager.ResetActionTimer();

        for (int i = 0; i < 3; i++)
        {
            help_panels[i].SetActive(i == (int)current_type);
        }
        _music.Fade((int)current_type);
    }
示例#2
0
        public void PlayMusic(MusicTypes type)
        {
            audioSource.Stop();
            audioSource.loop   = true;
            audioSource.volume = maxVolume;
            switch (type)
            {
            case MusicTypes.normal:
                audioSource.clip = normalMusic;
                break;

            case MusicTypes.nightmare:
                audioSource.clip = nightmareMusic;
                break;

            case MusicTypes.win:
                audioSource.clip = winMusic;
                break;

            case MusicTypes.menu:
                audioSource.clip = menuMusic;
                break;

            default:
                audioSource.clip = normalMusic;
                break;
            }
            audioSource.Play();
        }
示例#3
0
        public async Task <IActionResult> update(int musicTypeId, [FromBody] MusicTypes musicTypes)
        {
            try
            {
                _logger.LogInfo(ControllerContext.ActionDescriptor.DisplayName);
                var isExists = await _musicTypesService.isExists(x => x.Id == musicTypeId);

                if (!isExists)
                {
                    return(CustomNotFound(musicTypeId));
                }
                else
                {
                    var isNameUnique = await _musicTypesService.isExists(x => x.Name.ToLower() == musicTypes.Name.ToLower());

                    if (ModelState.IsValid && isNameUnique == false)
                    {
                        var musicType = await _musicTypesService.GetByID(musicTypeId);

                        musicType.Result.Name = musicTypes.Name;
                        var updateMusicTypes = await _musicTypesService.Update(musicType.Result);

                        InfoLog($"{ControllerContext.ActionDescriptor.DisplayName} MusicTypes Updated Name : {updateMusicTypes.Result.Name} and Id : {updateMusicTypes.Result.Id}");

                        return(Ok(updateMusicTypes));
                    }
                    return(BadRequest());
                }
            }
            catch (Exception exception)
            {
                return(ErrorInternal(exception, $"{ControllerContext.ActionDescriptor.DisplayName} Exception Message : {exception.Message} - {exception.InnerException}"));
            }
        }
示例#4
0
    /*
     * public void PlayAmbient(string n)
     * {
     *  AudioClip clip = GetTemplate(ambientTemplates, n);
     *  if (clip == null) return;
     *
     *  if (Ambient != null)
     *  {
     *      GameObject.Destroy(Ambient.gameObject);
     *      Ambient = null;
     *  }
     *
     *  GameObject prefab = new GameObject();
     *  prefab.name = "Ambient-" + n;
     *  AudioSource ass = prefab.AddComponent<AudioSource>();
     *  ass.clip = clip;
     *  ass.loop = true;
     *  ass.volume = ambientVolume;
     *  ass.mute = MuteAllSound;
     *  prefab.transform.SetParent(ambientContainer);
     *  prefab.transform.position = Vector2.zero;
     *
     *  Ambient = ass;
     *  ass.Play();
     * }
     */
    public void PlayMusic(MusicTypes mt)
    {
        AudioClip clip = GetQuickMusic(mt);

        if (clip == null)
        {
            return;
        }

        if (Music != null)
        {
            GameObject.Destroy(Music.gameObject);
            Music = null;
        }

        GameObject prefab = new GameObject();

        prefab.name = "Music-" + mt;
        AudioSource ass = prefab.AddComponent <AudioSource>();

        ass.clip   = clip;
        ass.loop   = true;
        ass.volume = musicVolume;
        ass.mute   = MuteAllSound;
        prefab.transform.SetParent(musicContainer);
        prefab.transform.position = Vector2.zero;

        Music = ass;
        ass.Play();
    }
示例#5
0
        public async Task <BaseResponse <string> > Delete(MusicTypes musicTypes)
        {
            BaseResponse <string> baseResponse = new BaseResponse <string>();
            var isDeleted = await _musicTypesRepository.Delete(musicTypes);

            baseResponse.Result = isDeleted > 0 ? "Success Delete" : null;
            return(baseResponse);
        }
示例#6
0
        public async Task <BaseResponse <MusicTypesDto> > Insert(MusicTypes musicTypes)
        {
            BaseResponse <MusicTypesDto> baseResponse = new BaseResponse <MusicTypesDto>();
            var newMusicTypes = await _musicTypesRepository.Insert(musicTypes);

            baseResponse.Result = _mapper.Map <MusicTypesDto>(newMusicTypes);
            return(baseResponse);
        }
示例#7
0
        public async Task <BaseResponse <MusicTypesDto> > Update(MusicTypes musicTypes)
        {
            BaseResponse <MusicTypesDto> baseResponse = new BaseResponse <MusicTypesDto>();
            var updatedMusicTypes = await _musicTypesRepository.Update(musicTypes);

            baseResponse.Result = _mapper.Map <MusicTypesDto>(updatedMusicTypes);
            return(baseResponse);
        }
    public void PlayMusic(MusicTypes musicType, bool isLooping)
    {
        AudioClip ac = GetMusicAudioClip(musicType);

        if (ac != null && musicAudioSource != null)
        {
            musicAudioSource.clip = ac;
            musicAudioSource.loop = isLooping;
            musicAudioSource.Play();
        }
    }
示例#9
0
    public AudioClip GetQuickMusic(MusicTypes st)
    {
        if (quickMusic == null)
        {
            quickMusic = new Dictionary <MusicTypes, MusicData>();
            foreach (MusicData sd in musicDatas)
            {
                quickMusic.Add(sd.atype, sd);
            }
        }

        return(quickMusic[st].GetRandom());
    }
示例#10
0
    public AudioClip GetMusicAudioClip(MusicTypes musicType)
    {
        switch (musicType)
        {
        case MusicTypes.Default:
            return(musicInfo.defaultAudio);

            break;

        case MusicTypes.MainMenu:
            return(musicInfo.gameplayAudio);

            break;

        case MusicTypes.Gameplay:
            return(musicInfo.mainMenuAudio);

            break;
        }

        return(null);
    }
    void Play(int sceneAudiosIndex, int clipIndex, string groupName, MusicTypes clipType, bool addToUpcomingSources, bool playedWithDelay)
    {
        AudioSource source = this.gameObject.AddAudioSource();

        switch (clipType)
        {
        case MusicTypes.Default:
            source.Play(scenesAudios[sceneAudiosIndex].defaultAudios[clipIndex].clip, scenesAudios[sceneAudiosIndex].defaultAudios[clipIndex].volume, 1f, true, true, groupName);
            break;

        case MusicTypes.Battle:
            source.Play(scenesAudios[sceneAudiosIndex].battleAudios[clipIndex].clip, scenesAudios[sceneAudiosIndex].battleAudios[clipIndex].volume, 1f, true, true, groupName);
            break;

        case MusicTypes.Victory:
            source.Play(endingAudios.victoryAudios[clipIndex].clip, scenesAudios[sceneAudiosIndex].battleAudios[clipIndex].volume, 1f, true, true, groupName);
            break;

        case MusicTypes.Defeat:
            source.Play(endingAudios.defeatAudios[clipIndex].clip, scenesAudios[sceneAudiosIndex].battleAudios[clipIndex].volume, 1f, true, true, groupName);
            break;

        default:
            break;
        }

        //if (!loop) Destroy(source, source.clip.length);

        if (addToUpcomingSources)
        {
            SourceAndVolume newSource = new SourceAndVolume(source, source.volume);
            upcomingAudioSources.Add(newSource);

            if (playedWithDelay)
            {
                source.Pause();
            }
        }
    }
示例#12
0
        public async Task <IActionResult> store([FromBody] MusicTypes musicTypes)
        {
            try
            {
                _logger.LogInfo(ControllerContext.ActionDescriptor.DisplayName);
                // var isExists = await _musicTypesService.isExists(x => x.Name.ToLower() == musicTypes.Name.ToLower());
                if (ModelState.IsValid)
                {
                    var newMusicTypes = await _musicTypesService.Insert(musicTypes);

                    InfoLog($"{ControllerContext.ActionDescriptor.DisplayName} MusicTypesCreated Name : {newMusicTypes.Result.Name} and Id : {newMusicTypes.Result.Id}");
                    await _musicTypesHub.Clients.All.SendAsync("newMusicTypeAdded", newMusicTypes);

                    return(Created("Created", newMusicTypes));
                }
                return(BadRequest());
            }
            catch (Exception exception)
            {
                return(ErrorInternal(exception, $"{ControllerContext.ActionDescriptor.DisplayName} Exception Message : {exception.Message} - {exception.InnerException}"));
            }
        }
示例#13
0
 public async Task <MusicTypes> Update(MusicTypes musicTypes)
 {
     return(await _baseRepository.Update(musicTypes));
 }
示例#14
0
 public async Task <MusicTypes> Insert(MusicTypes musicTypes)
 {
     return(await _baseRepository.Insert(musicTypes));
 }
示例#15
0
 public async Task <int> Delete(MusicTypes musicTypes)
 {
     return(await _baseRepository.Delete(musicTypes));
 }
 /// <summary>
 /// Funkcja zwracajaca pelna sciezke do pliku z muzyka (mp3) po zadanym
 /// typie muzyki do zagrania
 /// </summary>
 /// <param name="music">Typ muzyki</param>
 /// <returns>Pelna sciezka do pliku mp3 z muzyka</returns>
 public String FindMusic(MusicTypes music)
 {
     return musicDirectoryPath
         + (String)resourcesManager.GetObject(music.ToString());
 }
    /// <summary>
    /// Changes the audio of the game in a smooth way
    /// </summary>
    /// <param name="desiredMusicType"></param> Type of music to play
    /// <param name="transitionTime"></param> Time of the current audios to fade out and the upcoming audios to fade in
    /// <param name="transitionDelayTime"></param> Delay of the audio transition
    public void SetMusicType(MusicTypes desiredMusicType, float transitionTime, float transitionDelayTime) //Metodo para hacer blending de audios
    {
        if (!scenesAudios.Exists(scene => scene.name == SceneManager.GetActiveScene().name))
        {
            return;
        }

        if (desiredMusicType == musicType)
        {
            return;
        }

        transitionWithDelay = (transitionDelayTime > 0) ? true : false;

        if (isTransitioning)
        {
            if (previousMusicType == desiredMusicType)  //Musica previa a la actual == Musica por venir
            {
                transitionTimer         = (transitionTimer / transitionDuration) * transitionTime;
                transitionDuration      = transitionTime;
                transitionDelayTimer    = (1 - (transitionDelayTimer / transitionDelayDuration)) * transitionDelayTime;
                transitionDelayDuration = transitionDelayTime;

                List <SourceAndVolume> tempCurrentAudioSources = currentAudioSources;

                currentAudioSources  = upcomingAudioSources;
                upcomingAudioSources = tempCurrentAudioSources;
            }
            else
            {
                transitionTimer    = 0;
                transitionDuration = transitionTime;
                if (transitionWithDelay)
                {
                    transitionDelayTimer = transitionDelayDuration = transitionDelayTime;
                }

                currentAudioSources.AddRange(upcomingAudioSources);

                foreach (SourceAndVolume audioSource in currentAudioSources)
                {
                    audioSource.volume = audioSource.source.volume;
                }

                upcomingAudioSources.Clear();

                int sceneAudiosIndex = scenesAudios.FindIndex(scene => scene.name == SceneManager.GetActiveScene().name);

                switch (desiredMusicType)
                {
                case MusicTypes.Default:
                    for (int index = 0; index < scenesAudios[sceneAudiosIndex].defaultAudios.Length; index++)
                    {
                        string clipGroupName = " ";

                        if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_Forest")
                        {
                            clipGroupName = (index == 0 || index == 1) ? "Ambient" : "Music";
                        }
                        else if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_FenrirBoss")
                        {
                            clipGroupName = (index == 0) ? "Music" : "Ambient";
                        }

                        Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                        upcomingAudioSources[index].source.volume = 0;
                    }
                    break;

                case MusicTypes.Battle:
                    for (int index = 0; index < scenesAudios[sceneAudiosIndex].battleAudios.Length; index++)
                    {
                        string clipGroupName = " ";

                        if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_Forest")
                        {
                            clipGroupName = (index == 0) ? "Music" : "Ambient";
                        }
                        else if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_FenrirBoss")
                        {
                            clipGroupName = (index == 0) ? "Music" : "Ambient";
                        }

                        Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                        upcomingAudioSources[index].source.volume = 0;
                    }
                    break;

                case MusicTypes.Victory:
                    for (int index = 0; index < endingAudios.victoryAudios.Length; index++)
                    {
                        string clipGroupName = (index == 0) ? "Music" : "Ambient";
                        Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                        upcomingAudioSources[index].source.volume = 0;
                    }
                    break;

                case MusicTypes.Defeat:
                    for (int index = 0; index < endingAudios.defeatAudios.Length; index++)
                    {
                        string clipGroupName = (index == 0) ? "Music" : "Ambient";
                        Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                        upcomingAudioSources[index].source.volume = 0;
                    }
                    break;

                default:
                    break;
                }
            }
        }
        else
        {
            transitionTimer    = 0;
            transitionDuration = transitionTime;
            if (transitionWithDelay)
            {
                transitionDelayTimer = transitionDelayDuration = transitionDelayTime;
            }

            if (currentAudioSources.Capacity > 0)
            {
                currentAudioSources.Clear();
            }
            if (upcomingAudioSources.Capacity > 0)
            {
                upcomingAudioSources.Clear();
            }

            foreach (AudioSource source in gameObject.GetComponents <AudioSource>())
            {
                SourceAndVolume sourceAndVolume = new SourceAndVolume(source, source.volume);
                currentAudioSources.Add(sourceAndVolume);
            }

            int sceneAudiosIndex = scenesAudios.FindIndex(scene => scene.name == SceneManager.GetActiveScene().name);

            switch (desiredMusicType)
            {
            case MusicTypes.Default:
                for (int index = 0; index < scenesAudios[sceneAudiosIndex].defaultAudios.Length; index++)
                {
                    string clipGroupName = " ";

                    if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_Forest")
                    {
                        clipGroupName = (index == 0 || index == 1) ? "Ambient" : "Music";
                    }
                    else if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_FenrirBoss")
                    {
                        clipGroupName = (index == 0) ? "Music" : "Ambient";
                    }

                    Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                    upcomingAudioSources[index].source.volume = 0;
                }
                break;

            case MusicTypes.Battle:
                for (int index = 0; index < scenesAudios[sceneAudiosIndex].battleAudios.Length; index++)
                {
                    string clipGroupName = " ";

                    if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_Forest")
                    {
                        clipGroupName = (index == 0) ? "Music" : "Ambient";
                    }
                    else if (scenesAudios[sceneAudiosIndex].name == "Thor_Tunderlord_FenrirBoss")
                    {
                        clipGroupName = (index == 0) ? "Music" : "Ambient";
                    }

                    Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                    upcomingAudioSources[index].source.volume = 0;
                }
                break;

            case MusicTypes.Victory:
                for (int index = 0; index < endingAudios.victoryAudios.Length; index++)
                {
                    string clipGroupName = (index == 0) ? "Music" : "Ambient";
                    Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                    upcomingAudioSources[index].source.volume = 0;
                }
                break;

            case MusicTypes.Defeat:
                for (int index = 0; index < endingAudios.defeatAudios.Length; index++)
                {
                    string clipGroupName = (index == 0) ? "Music" : "Ambient";
                    Play(sceneAudiosIndex, index, clipGroupName, desiredMusicType, true, transitionWithDelay);
                    upcomingAudioSources[index].source.volume = 0;
                }
                break;

            default:
                break;
            }

            isTransitioning = true;
        }

        previousMusicType = musicType;
        musicType         = desiredMusicType;
    }
示例#18
0
 /// <summary>
 /// Funkcja grajaca zadana muzyke w tle gry
 /// </summary>
 /// <param name="music">Typ wyliczeniowy z typem muzyki do zagrania</param>
 public static void PlayMusic(MusicTypes music)
 {
     if (backgroundMusic != null)
     {
         StopMusic();
     }
     String musicName = nameFinder.FindMusic(music); //znalezienie sciezki
     backgroundMusic = new Audio(musicName, true);
 }