public void PlayRandomClip(FootStepObject footStepObject) { // If there are no clips to play return. if (audioClips == null || audioClips.Count == 0) { return; } // initialize variable if not already started if (randomSource == null) { randomSource = new FisherYatesRandom(); } // Find a random clip and play it. var audioObject = new GameObject("audioObject"); audioObject.transform.position = footStepObject.sender.position; var source = audioObject.AddComponent <AudioSurfaceControl>(); if (audioMixerGroup != null) { source.outputAudioMixerGroup = audioMixerGroup; } int index = randomSource.Next(audioClips.Count); if (particleObject) { var particle = Instantiate(particleObject, footStepObject.sender.position, footStepObject.sender.rotation) as GameObject; particle.SendMessage("StepMark", footStepObject.sender, SendMessageOptions.DontRequireReceiver); } source.PlayOneShot(audioClips[index]); }
public void PlayRandomClip(FootStepObject footStepObject) { if (audioClips == null || audioClips.Count == 0) { return; } if (randomSource == null) { randomSource = new FisherYatesRandom(); } soundPool.Invoke(audioSource.gameObject, footStepObject, audioMixerGroup, audioClips); }
private FisherYatesRandom randomSource = new FisherYatesRandom(); // For randomly reordering clips. #endregion Fields #region Methods public void PlayRandomClip() { // If there are no clips to play return. if (audioClips == null || audioClips.Count == 0) return; // initialize variable if not already started if (randomSource == null) randomSource = new FisherYatesRandom(); // Find a random clip and play it. int index = randomSource.Next(audioClips.Count); source.PlayOneShot(audioClips[index]); }
public void Init() { if (randomWaypoint == null) { randomWaypoint = new FisherYatesRandom(); } if (randomPatrolPoint == null) { randomPatrolPoint = new FisherYatesRandom(); } currentWaypoint = -1; currentPatrolPoint = -1; agent = GetComponent <NavMeshAgent>(); agent.updateRotation = false; agentPath = new NavMeshPath(); animator = GetComponent <Animator>(); meleeManager = GetComponent <MeleeEquipmentManager>(); canAttack = true; sideMovement = GetRandonSide(); destination = transform.position; _rigidbody = GetComponent <Rigidbody>(); _rigidbody.useGravity = false; _rigidbody.isKinematic = false; _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; _capsuleCollider = GetComponent <CapsuleCollider>(); healthSlider = GetComponentInChildren <SpriteHealth>(); head = animator.GetBoneTransform(HumanBodyBones.Head); oldPosition = transform.position; currentHealth = startingHealth; method = OffMeshLinkMoveMethod.Grounded; if (vGameController.instance != null && vGameController.instance.currentPlayer != null) { target = vGameController.instance.currentPlayer.transform; } }
private FisherYatesRandom randomSource = new FisherYatesRandom(); // For randomly reordering clips. public void PlayRandomClip() { // If there are no clips to play return. if (audioClips == null || audioClips.Count == 0) { return; } // initialize variable if not already started if (randomSource == null) { randomSource = new FisherYatesRandom(); } // Find a random clip and play it. int index = randomSource.Next(audioClips.Count); if (!source.isPlaying) { source.PlayOneShot(audioClips[index]); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (_random == null) { _random = new FisherYatesRandom(); } GameObject audioObject = null; if (audioSource != null) { audioObject = Instantiate(audioSource.gameObject, animator.transform.position, Quaternion.identity) as GameObject; } else { audioObject = new GameObject("audioObject"); audioObject.transform.position = animator.transform.position; } if (audioObject != null) { var source = audioObject.gameObject.GetComponent <AudioSource>(); var clip = sounds[_random.Next(sounds.Count)]; source.PlayOneShot(clip); } }
public override void Init() { base.Init(); if (randomWaypoint == null) { randomWaypoint = new FisherYatesRandom(); } if (randomPatrolPoint == null) { randomPatrolPoint = new FisherYatesRandom(); } currentWaypoint = -1; currentPatrolPoint = -1; fwd = transform.forward; destination = transform.position; agent = GetComponent <NavMeshAgent>(); agentPath = new NavMeshPath(); sphereSensor = GetComponentInChildren <AISphereSensor>(); if (sphereSensor) { sphereSensor.SetColliderRadius(maxDetectDistance); sphereSensor.tagsToDetect = tagsToDetect; sphereSensor.passiveToDamage = passiveToDamage; } else { Debug.Log("sphereSensor가 컴포넌트에 등록되지않으면 타겟을 찾을수없습니다."); } animator = GetComponent <Animator>(); meleeManager = GetComponent <MeleeManager>(); canAttack = true; attackCount = 0; sideMovement = GetRandonSide(); destination = transform.position; _rigidbody = GetComponent <Rigidbody>(); _rigidbody.useGravity = true; _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation; agent.updatePosition = false; agent.updateRotation = false; agent.enabled = false; _capsuleCollider = GetComponent <CapsuleCollider>(); // avoid collision detection with inside colliders Collider[] AllColliders = this.GetComponentsInChildren <Collider>(); Collider thisCollider = GetComponent <Collider>(); for (int i = 0; i < AllColliders.Length; i++) { Physics.IgnoreCollision(thisCollider, AllColliders[i]); } // healthSlider = GetComponentInChildren<v_SpriteHealth>(); head = animator.GetBoneTransform(HumanBodyBones.Head); oldPosition = transform.position; currentHealth = maxHealth; startPosition = transform.position; }