public static void PlaySoundPlayer(AudioClip clip, bool loop, Block player, PlayerAudioType type) { if (clip == null) return; var audio = _instance.PlayerAudioSource; if (!audio.enabled) return; if (player == Block.Player1) _instance._player1 = type; else if (player == Block.Player2) _instance._player2 = type; if (type == PlayerAudioType.Idle) if (_instance._player1 == PlayerAudioType.Move || _instance._player2 == PlayerAudioType.Move) return; if (audio.clip == clip && audio.isPlaying) return; audio.loop = loop; audio.clip = clip; audio.Play(); }
private void DeathEvent(Player player) { if (player.IsMainPlayer) { audioSource.clip = PlayerAudioType.GetClip(PlayerAudioType.DEAD.Sounds[Random.Range(0, PlayerAudioType.DEAD.Sounds.Length)]); audioSource.Play(); } }
private void Jump() { if (isGrounded) { velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity); movementType = MovementType.JUMPING; playerAudio.Jump(PlayerAudioType.GetJumpByPlayerType(this.playerType)); } }
public void Jump(PlayerAudioType type) { audioSource.clip = PlayerAudioType.GetClip(type.Sounds[Random.Range(0, type.Sounds.Length)]); audioSource.Play(); StopCoroutine("DoStepCooldown"); canStep = false; StartCoroutine("DoStepCooldown"); }
private void ShowMessage(MessageTypes messageType, string message) { displayField.text = message; StartCoroutine("StopShowingMessage"); //Also play the appropriate audio :) PlayerAudioType type = PlayerAudioType.GetByMessageType(messageType); audioSource.clip = PlayerAudioType.GetClip(type.Sounds[Random.Range(0, type.Sounds.Length)]); audioSource.Play(); }
private void SeeingSeeker(bool isSeeing) { if (isSeeing) { //Give the player a hands up.. if (!audioSource.isPlaying) { audioSource.clip = PlayerAudioType.GetClip(PlayerAudioType.HIDER_SEES_SEEKER.Sounds[Random.Range(0, PlayerAudioType.HIDER_SEES_SEEKER.Sounds.Length)]); audioSource.Play(); } } }
public static void PlaySoundPlayer(AudioClip clip, bool loop, Block player, PlayerAudioType type) { if (clip == null) { return; } var audio = _instance.PlayerAudioSource; if (!audio.enabled) { return; } if (player == Block.Player1) { _instance._player1 = type; } else if (player == Block.Player2) { _instance._player2 = type; } if (type == PlayerAudioType.Idle) { if (_instance._player1 == PlayerAudioType.Move || _instance._player2 == PlayerAudioType.Move) { return; } } if (audio.clip == clip && audio.isPlaying) { return; } audio.loop = loop; audio.clip = clip; audio.Play(); }
private void Move() { Vector3 direction3d = new Vector3(direction.x, 0, direction.y); direction3d = transform.right * direction3d.x + transform.forward * direction3d.z; float speed = normalSpeed; if (isCrouching) { speed = crouchSpeed; } else if (isSprinting && direction.y > 0) { speed = sprintSpeed; } character.Move(direction3d * speed * Time.deltaTime); //Audio if (direction.y < 0 && !isCrouching) { movementType = MovementType.BACKWARDS_WALKING; playerAudio.Walk(PlayerAudioType.GetWalkByPlayerType(this.playerType)); return; } if (speed == normalSpeed) { movementType = MovementType.WALKING; playerAudio.Walk(PlayerAudioType.GetWalkByPlayerType(this.playerType)); } else if (isSprinting) { movementType = MovementType.RUNNING; playerAudio.Walk(PlayerAudioType.GetRunByPlayerType(this.playerType)); } else if (isCrouching) { movementType = MovementType.CROUCHING_WALK; } }