public void SetSound(AudioClip newSound, SOUND type) { switch (type) { case SOUND.FOOTSTEP: footstep = newSound; break; case SOUND.ATTACK: attack = newSound; break; case SOUND.DAMAGED: damaged = newSound; break; case SOUND.DEATH: death = newSound; break; case SOUND.ATTACKHIT: attackHit = newSound; break; case SOUND.AMBIENT: ambient.Add(newSound); break; case SOUND.BLOCKED: blocked = newSound; break; } }
public void PlayEffSound(SOUND idx, float volume = 1f, bool loop = false, bool overlap = true) { if (!overlap) { if (checkOverLap(idx)) { return; } } for (int i = 0; i < effSource.Length; ++i) { if (loop == false) { if (!effSource[i].isPlaying) { effSource[i].clip = _soundDictionary[idx]; effSource[i].volume = volume; effSource[i].Play(); return; } } else { if (!effSource[i].isPlaying && effSource[i].loop) { effSource[i].clip = _soundDictionary[idx]; effSource[i].volume = volume; effSource[i].Play(); return; } } } }
public void PlayBGMSound(SOUND idx, float volume = 1f) { bgmSource.clip = _soundDictionary[idx]; bgmSource.volume = volume; bgmSource.loop = true; bgmSource.Play(); }
public void PlaySoundEffect(SOUND sound) { bool isPlay = true; switch(sound) { case SOUND.AHA: chosenAudio = aha; break; case SOUND.COMBO: chosenAudio = combo; break; case SOUND.WRONG: chosenAudio = wrong; break; case SOUND.CUBECLICK: chosenAudio = cubeClick; break; default: isPlay = false; break; } if(isPlay) { audioSource.PlayOneShot(chosenAudio, 1); } }
/////////////////////////////////// ///// Collision Section ///// /////////////////////////////////// /// private void OnCollisionEnter(Collision collision) { if (collision.gameObject.GetComponent <StockSave>() != null) { basket.OnStockCollision(collision.gameObject.GetComponent <StockSave>(), _playerIndex); } if (collision.gameObject.name.Contains("apple") && !basket.IsFull() && !collision.gameObject.GetComponent <Projectile>()) { basket.OnAppleCollision(collision.gameObject); } if (collision.gameObject.name.Contains("Tree") && _dashing) { collision.gameObject.GetComponent <TreeApplesGrow>().DropApples(); } if (_dashing && collision.gameObject.tag == "Obstacle") { Bump(collision.contacts[0].point, true); SOUND.HitTree(); } else if (_dashing && collision.gameObject.tag == "Player") { BumpOtherPlayer(collision.gameObject, collision.contacts[0].point); Bump(collision.contacts[0].point, false); } }
private IEnumerator BumpByPlayerCoroutine(Vector3 direction) { float startTime = Time.time; float currentTime = 0f; Vector3 startPosition = transform.position; Vector3 desiredPosition = startPosition + Vector3.Normalize(direction) * _bumpOnTargetForce; SwitchToHitSprite(_bumpDuration); while (currentTime < _stunOnTargetDuration) { if (currentTime < _bumpDuration) { float fracComplete = (Time.time - startTime) / _bumpDuration; _rigidbody.position = Vector3.Lerp(transform.position, desiredPosition, fracComplete); } else { _animator.enabled = true; } currentTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } _animator.enabled = true; _bumped = false; SOUND.Stun(); }
// Start is called before the first frame update void Start() { SOUND.StartAmbiance(); _players = FindObjectsOfType <PlayerController>(); _seconds = 0; InvokeRepeating("AddSecond", 1f, 1f); _nextMeteorite = delayMeteorite + Random.Range(-1 * varTimeMeteorite, varTimeMeteorite); }
public void AddApple(GameObject apple, int playerIndex) { SOUND.WinPoint(); playerScore[playerIndex] += 1; GameObject.Find("P" + playerIndex).GetComponent <CharacterUI>().textScore.text = "x" + playerScore[playerIndex]; Destroy(apple); }
public void PlayAudio_Sound(SOUND _clip) { AudioSource_Sound.clip = AudioClips_Sound[(int)_clip]; if (AudioSource_Sound.clip != null && AudioSource_Sound.enabled == true) { AudioSource_Sound.Play(); } }
public void AddApple(GameObject apple) { _apples.Push(apple); SOUND.Grab(); apple.transform.position = _appleAnchors[_apples.Count - 1].transform.position; apple.transform.parent = _appleAnchors[_apples.Count - 1].transform; }
//================================================================================================================// public void PlaySoundEffect(SOUND effect, float volumeScale = 1f) { var index = (int)effect; var pitchRange = _effectProfiles[index].pitchRange; masterMixer.SetFloat("EffectPitch", Random.Range(pitchRange.x, pitchRange.y)); effectsSource.PlayOneShot(effects[index], volumeScale); }
public void PlaySound(SOUND type) { switch (type) { case SOUND.FOOTSTEP: audioManager.instance.PlaySound( footstep, sourceID ); break; case SOUND.ATTACK: audioManager.instance.PlaySound( attack, sourceID ); break; case SOUND.DAMAGED: audioManager.instance.PlaySound( damaged, sourceID ); break; case SOUND.DEATH: audioManager.instance.PlaySound( death, sourceID ); break; case SOUND.ATTACKHIT: audioManager.instance.PlaySound( attackHit, sourceID ); break; case SOUND.AMBIENT: audioManager.instance.PlaySound( ambient[Random.Range(0, ambient.Count - 1)], sourceID ); break; case SOUND.BLOCKED: audioManager.instance.PlaySound( blocked, sourceID ); break; } }
public void SetSoundIntoSource(SOUND type) { switch (type) { case SOUND.FOOTSTEP: audioManager.instance.SetSoundIntoSource( footstep, SOUND.FOOTSTEP ); break; case SOUND.ATTACK: audioManager.instance.SetSoundIntoSource( attack, SOUND.ATTACK ); break; case SOUND.DAMAGED: audioManager.instance.SetSoundIntoSource( damaged, SOUND.DAMAGED ); break; case SOUND.DEATH: audioManager.instance.SetSoundIntoSource( death, SOUND.DEATH ); break; case SOUND.ATTACKHIT: audioManager.instance.SetSoundIntoSource( attackHit, SOUND.ATTACKHIT ); break; case SOUND.BLOCKED: audioManager.instance.SetSoundIntoSource( blocked, SOUND.BLOCKED ); break; case SOUND.AMBIENT: audioManager.instance.SetSoundIntoSource( ambient[Random.Range(0, ambient.Count - 1)], SOUND.AMBIENT ); break; } }
public void PlayEffSound(SOUND idx) { for (int i = 0; i < effSource.Length; ++i) { if (!effSource[i].isPlaying) { effSource[i].clip = _soundDictionary[idx]; effSource[i].Play(); } } }
// Start is called before the first frame update void Start() { Debug.Log("PlayerManger"); SOUND.StartMusic(); for (int i = 0; i < 4; ++i) { playerIsSet.Add(i, false); playerIsReleaseStick.Add(i, true); playerIsReady.Add(i, false); } }
private bool checkOverLap(SOUND idx) { for (int i = 0; i < effSource.Length; ++i) { if (effSource[i].isPlaying && effSource[i].clip.Equals(_soundDictionary[idx])) { return(true); } } return(false); }
public void OffEffSound(SOUND idx) { for (int i = 0; i < effSource.Length; ++i) { if (effSource[i].isPlaying && effSource[i].clip == _soundDictionary[idx]) { effSource[i].Stop(); return; } } }
/////////////////////////////////// ///// Dash boost Section ///// /////////////////////////////////// public void Dash() { if (_dashing || _currentDashJauge < _dashCost) { return; } SOUND.Dash(); _dashing = true; _currentDashJauge -= _dashCost; Invoke("ResetDash", _dashDuration); }
public void Play(SOUND sound) { switch (sound) { case SOUND.Falling: SFXSource.clip = Falling[(int)Random.Range(0f, Falling.Length - 0.00001f)]; SFXSource.Play(); break; case SOUND.Pain: SFXSource.clip = Pain[(int)Random.Range(0f, Pain.Length - 0.00001f)]; SFXSource.Play(); break; case SOUND.Conga: SFXSource.clip = Conga; SFXSource.Play(); break; case SOUND.Landing: SFXSource.clip = Landing[(int)Random.Range(0f, Landing.Length - 0.00001f)]; SFXSource.Play(); break; case SOUND.Meow: // Meow should only play occasionally if(Random.value<0.3) { SFXSource.clip = Meow[(int)Random.Range(0f, Meow.Length - 0.00001f)]; SFXSource.Play(); } break; case SOUND.Snarl: SFXSource.clip = Snarl; SFXSource.Play(); break; case SOUND.Step: if (Random.value < 0.5) { FootStepSource.clip = Step[(int)Random.Range(0f, Step.Length - 0.00001f)]; FootStepSource.Play(); } break; case SOUND.Vine: SFXSource.clip = Vine[(int)Random.Range(0f, Vine.Length - 0.00001f)]; SFXSource.Play(); break; case SOUND.WoodClick: SFXSource.clip = WoodClick; SFXSource.Play(); break; case SOUND.WoodToggle: SFXSource.clip = WoodToggle; SFXSource.Play(); break; } }
public void playSound(SOUND sound) { switch (sound) { case SOUND.ERROR: source.PlayOneShot(errorClip, sfxVolume); break; case SOUND.TURN_READY: source.PlayOneShot(turnReadyClip, sfxVolume); break; } }
// AudioClipを取得する // soundKeyに対して複数のAudioClipが存在する場合、ランダムで1つ取得する private AudioClip getAudio(SOUND soundKey) { if (!audioClips.ContainsKey(soundKey)) { return(null); } List <AudioClip> sounds = audioClips [soundKey]; int selectedIndex = Mathf.FloorToInt(Random.Range(0, sounds.Count - 1)); //Debug.Log ("soundKey : " + soundKey + " / selectedIndex : " + selectedIndex +" / maxIndex : " + sounds.Count); return(sounds[selectedIndex]); }
// ループ無し再生(SE) public void play(SOUND soundName) { AudioClip audioClip = getAudio(soundName); if (audioClip == null) { return; } initializeAudioSource(); m_SeAudioSource.PlayOneShot(audioClip); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } DontDestroyOnLoad(this.gameObject); }
// ループあり再生(BGM) public void playBgm(SOUND soundName) { AudioClip audioClip = getAudio(soundName); if (audioClip == null) { return; } initializeAudioSource(); m_BgmAudioSource.clip = audioClip; m_BgmAudioSource.Play(); }
public void Shoot() { _shooting = false; if (_projectile != null) { Destroy(_sight); _projectile.GetComponent <Rigidbody>().isKinematic = false; _projectile.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation; _projectile.GetComponent <Rigidbody>().AddForce((Vector3.Normalize(transform.forward) + new Vector3(0, 0.1f, 0)) * 1000); _projectile.transform.parent = null; StartCoroutine(DisableProjectileTrigger(_projectile)); _projectile = null; SOUND.ThrowApple(); } }
public static ResponseBase CreateOrUpdate(SOUND soundObj) { var result = new ResponseBase(); var flag = true; try { var db = new PMSEntities(); if (soundObj.Id == 0) { db.SOUNDs.Add(soundObj); } else { var sound = db.SOUNDs.FirstOrDefault(x => !x.IsDeleted && x.Id == soundObj.Id); if (sound != null) { sound.Code = soundObj.Code; sound.Name = soundObj.Name; sound.IsActive = soundObj.IsActive; sound.Path = soundObj.Path; sound.Description = soundObj.Description; } else { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Không tìm thấy thông tin tệp bạn đang thao tác." }); } } if (flag) { db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Lưu thành công." }); } } catch (Exception ex) { throw ex; } return(result); }
void playSound(SOUND sound) { Sound s = Array.Find <Sound>(sounds, (ss) => { return(ss.name == sound); }); audioSource.clip = s.clip; audioSource.loop = s.oneShot ? false : true; audioSource.Play(); if (s.name == SOUND.typing) { if (!(typing = !typing)) { audioSource.Stop(); } } }
public void PlayBGM(SOUND sound) { if (m_CurPlayBGM == sound) { return; } if (m_AudioSource.isPlaying) { m_AudioSource.Stop(); } m_CurPlayBGM = sound; m_AudioSource.clip = m_mAudio[sound]; m_AudioSource.Play(); m_AudioSource.loop = true; }
public static void PlaySound(SOUND currentSound) { if (currentSound == SOUND.ButtonClick) { instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundDie); } if (currentSound == SOUND.die) { instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundDie); instance.Invoke("PlaySoundDie", 0.8f); } if (currentSound == SOUND.Scored) { instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundScored); } }
private SOUND GetSoundData() { try { var sound = new SOUND(); sound.Id = soundId; sound.Code = txtCode.Text; sound.Name = txtName.Text; sound.Description = txtDescription.Text; sound.Path = txtPath.Text; sound.IsActive = chkIsActive.Checked; return(sound); } catch (Exception ex) { throw ex; } }
// AudioClipsを追加する。重複判定しないので注意 private void addAudio(SOUND soundKey, string filePath) { List <AudioClip> sounds; if (!audioClips.ContainsKey(soundKey)) { sounds = new List <AudioClip> (); audioClips.Add(soundKey, sounds); } else { sounds = audioClips [soundKey]; } //Debug.Log ("sounds : " + sounds.Count); sounds.Add((AudioClip)Resources.Load(filePath)); //audioClips.Add (soundKey, (AudioClip)Resources.Load (filePath)); }
protected override bool Init() { m_mAudio = new Dictionary <SOUND, AudioClip>(); AudioClip[] arry = Resources.LoadAll <AudioClip>("03Sound"); if (m_AudioSource == null) { m_AudioSource = gameObject.AddComponent <AudioSource>(); } for (SOUND i = SOUND.BGM_MAIN; i <= (SOUND)arry.Length; i++) { m_mAudio.Add(i, arry[(int)i - 1]); } return(true); }