private void Awake() { //오디오 소스 찾기 if (BGMAudio.Equals(null) || SFXAudio.Equals(null) || MasterAudio.Equals(null)) { print("오디오 소스가 없습니다."); } Button_AddListener(); Cursor_Confined(); // 저장된 파일주소가 없으면 주소 생성하고 기본해상도로 설정 if (SaveFilePath.Equals(string.Empty)) { SaveFilePath = Path.Combine(Application.streamingAssetsPath, "Option.Json"); } // 해당 주소에 파일이 없으면 기본세팅하고 파일 저장 if (!File.Exists(SaveFilePath)) { GraphicSetting_Reset(); VolumeSetting_Reset(); SaveOptionJson(); } // 파일이 있으면 불러옴 else { LoadOptionJson(); } }
/* * This method plays a music track based on the enum MusicTrack parameter value. The values are as follows: * The used enum values: WorldMap = 0, BubbleWarehouse = 1, BubbleWarehouseCutscene = 2, EndingCutscene = 3, GameOverJingle = 4, HedgeMaze = 5, * HedgeMazeCutscene = 6, MysticCards = 7, MysticCardsCutscene = 8, VictoryJingle = 9, WinterForestMarathon = 10, * WinterForestMarathonCutscene = 11 */ private void Play(MusicTrack musicTrack) { AudioSource currentlyPlayingTrack = GetCurrentlyPlayingMusicTrack(); int trackIndex = (int)musicTrack; //The track is a jingle that pauses the current track and resumes it after the jingle has played. if (trackIndex == 4 || trackIndex == 9) { StartCoroutine(PlayJingle(audioSources[trackIndex])); return; } //Ignore this function if the track is already playing. if (currentlyPlayingTrack.Equals(audioSources[(int)musicTrack]) && audioSources[(int)musicTrack].isPlaying) { return; } Stop(); //If the track is the World map theme, it's starting time is loaded from the worldMapMusicSamples variable //which is updated in the Stop() -method. if (trackIndex == 0) { audioSources[0].timeSamples = worldMapMusicTimeSamples; } audioSources[trackIndex].Play(); Debug.Log("New music track playing."); }
private void Awake() { //오디오 소스 찾기 if (BGMAudio.Equals(null) || SFXAudio.Equals(null) || MasterAudio.Equals(null)) { print("오디오 소스가 없습니다."); } }
public void Play(string name) { AudioSource s = sounds[name] as AudioSource; if (s.Equals(null)) { Debug.Log("Âm thanh chưa đưuọc khởi tạo"); } else { s.Stop(); s.Play(); } }
void Update() { //Colide and switch direction algorithm if (wallSprite.size.x >= maxWallWidth) { inc = -Mathf.Abs(inc); currentSound.Stop(); if (currentSound.Equals(sound1)) { currentSound = sound2; } else { currentSound = sound1; } currentSound.Play(); } else if (wallSprite.size.x <= minWallWidth) { inc = Mathf.Abs(inc); currentSound.Stop(); if (currentSound.Equals(sound1)) { currentSound = sound2; } else { currentSound = sound1; } currentSound.Play(); } newWidth = newWidth + inc; wallSprite.size = new Vector2(newWidth, wallSprite.size.y); }
void Update() { if (oldGlobalVolume != globalVolume) { foreach (Object item in sounds.Values) { AudioSource s = item as AudioSource; if (!s.Equals(null)) { s.volume = s.volume / oldGlobalVolume * globalVolume; } } oldGlobalVolume = globalVolume; } }
public void PlayerManager(AudioSource audio, int pavelN) { if (playingAudio == null) { playingAudio = audio; playingAudio.Play(); } else { if (!playingAudio.Equals(audio)) { playingAudio.Stop(); playingAudio = audio; playingAudio.Play(); } } pavelNumber = pavelN; }
/// <summary> /// 执行相应的事件 /// </summary> /// <param name="index"></param> /// <param name="state"></param> static void excuteEvent(AudioSource _as, AS_State state) { if (_as) { for (int i = 0; i < _asList.Count; i++) { if (_as.Equals(_asList[i])) { //更新音频组件的状态 _asStateList[i] = state; //执行对应状态的回调函数 if (_funcBodyList[i]._eventType == state) { _funcBodyList[i]._func(); } } } } }
private void raiseVolume(AudioSource src, float vol) { if (src.volume == 1f) { return; } if (!src.isPlaying) { src.Play(); if (lastSrc != null && !lastSrc.Equals(src)) { src.time = lastSrc.time; } } src.volume += vol; lastSrc = src; }
// Update is called once per frame void Update() { if (isFiring) { shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; if (!gunSound.Equals(null)) { gunSound.Play(); } BulletController newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation) as BulletController; newBullet.setDamage(damage); newBullet.speed = bulletSpeed; } } else { shotCounter = 0; } }
public bool IsAudioSourceSelected() { return(!string.IsNullOrEmpty(AudioSource) && !AudioSource.Equals("None", StringComparison.InvariantCultureIgnoreCase)); }
/** * Boucle principale de PlayerMovement */ void Update() { if (Input.GetKeyDown(KeyCode.RightControl)) { SaveSystem.Save(); } if (!BloqueMouvement) { isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask); #region Mouvement float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); enMouvement = x > 0 || z > 0; Vector3 move = transform.right * x + transform.forward * z; controller.Move(move * speed * Time.deltaTime); if (!this.isGrounded) { velocity.y += gravity * Time.deltaTime; } else { if (velocity.y <= -20f) { SanteJoueur.Instance.EstMort = true; } } controller.Move(velocity * Time.deltaTime); #endregion #region Bruitages if (!BruitagePas.Equals(null)) { if (enMouvement && BruitagePas.isPlaying == false) { BruitagePas.Play(); } else if (!enMouvement) { BruitagePas.Stop(); } } #endregion #region Récupération objets if (Input.GetKeyDown(KeyCode.E) && mouseLook.hitsmthg) { if (mouseLook.objectHitName.transform.gameObject.tag == "Objet") { inventaire_Player.ajout_Objet_Inventaire(mouseLook.objectHitName.transform.gameObject.name); } else if (mouseLook.objectHitName.transform.gameObject.tag == "Ingredient") { inventaire_Player.ajout_Ingredient_Inventaire(mouseLook.objectHitName.transform.gameObject.name); } Destroy(mouseLook.objectHitName.transform.gameObject); } #endregion #region Torche if (Input.mouseScrollDelta == new Vector2(0, 1) && gameObject.tag == "Enigme") { activeTorche = !activeTorche; torchePrefab.SetActive(activeTorche); } #endregion } #region Canvas if (Input.GetKeyDown(KeyCode.C) && gameObject.tag == "Exploration") { if (craft_Livre_Canvas.activeInHierarchy) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; BloqueMouvement = false; craft_Livre_Canvas.SetActive(false); } else if (!Inventaire_Book_Manager.Instance.canvas_Inventaire.activeInHierarchy) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; BloqueMouvement = true; craft_Livre_Canvas.SetActive(true); } } #endregion if (Input.GetKeyDown(KeyCode.I) && gameObject.tag == "Exploration") { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; inventaire_Book.canvas_Inventaire_Active(); } #region Respawn if (ARespawn) { GetComponent <Transform>().position = SpawnPoint; ARespawn = false; } #endregion }