override public void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Change Player's?", isPlayer); if (!isPlayer) { parameterID = Action.ChooseParameterGUI("FootstepSounds:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; footstepSounds = null; } else { footstepSounds = (FootstepSounds)EditorGUILayout.ObjectField("FootstepSounds:", footstepSounds, typeof(FootstepSounds), true); constantID = FieldToID <FootstepSounds> (footstepSounds, constantID); footstepSounds = IDToField <FootstepSounds> (footstepSounds, constantID, false); } } footstepSoundType = (FootstepSoundType)EditorGUILayout.EnumPopup("Clips to change:", footstepSoundType); newSounds = ShowClipsGUI(newSounds, (footstepSoundType == FootstepSoundType.Walk) ? "New walk sounds:" : "New run sounds:"); AfterRunningOption(); }
public void PlayPlayerFootsteps(FootstepSoundType stepType, float vol) { // int ind = 0; if (FPSInputController.inst.motor.slidingNow) { return; } vol += Random.Range(0.0f, 0.1f); float pitch = Random.Range(0.85f, 1.10f); AudioClip clip = null; switch (stepType) { case FootstepSoundType.Concrete: clip = footstepsConcrete[Random.Range(0, footstepsConcrete.Length)]; vol *= 0.41f; break; case FootstepSoundType.Grass: vol = Random.Range(0.1f, 0.15f); clip = footstepsGrass[Random.Range(0, footstepsGrass.Length)]; break; case FootstepSoundType.Wood: clip = footstepsWood[Random.Range(0, footstepsWood.Length)]; break; case FootstepSoundType.Glass: clip = footstepsGlass[Random.Range(0, footstepsGlass.Length)]; pitch = Random.Range(0.95f, 1f); //Random.Range(0.7f,.9f); break; case FootstepSoundType.Sponge: clip = footstepsSponge[Random.Range(0, footstepsSponge.Length)]; vol += 0.25f; break; default: break; } if (clip) { PlayLocationSound(clip, Player.inst.transform.position, vol, pitch, 0.5f); } }
public void DetermineFootstepAudioType() { soundType = FootstepSoundType.Grass; // the default RaycastHit hit = new RaycastHit(); if (Physics.Raycast(Player.inst.transform.position, Vector3.down, out hit, 1f)) { Renderer r = hit.collider.GetComponent <Renderer>(); if (r && r.material && r.material) { string ln = r.material.name.ToLower(); if (ln.Contains("moss") || ln.Contains("dirt")) { soundType = FootstepSoundType.Grass; } else if (ln.Contains("wood")) { soundType = FootstepSoundType.Wood; } else if (ln.Contains("stone") || ln.Contains("concrete")) { soundType = FootstepSoundType.Concrete; } else if (ln.Contains("glass")) { soundType = FootstepSoundType.Glass; } else if (ln.Contains("sponge")) { soundType = FootstepSoundType.Sponge; } // Here we do a (crappy) relation hash for EffectsManager colors. If we are hitting one of these colors, make the corresponding sound. Unforuntaely // if (r.material.mainTexture.name.Contains // Debug.Log("material texture;"+r.material.mainTexture); // use a texture matrix to decide what type of footstep we have } } }
public override void ShowGUI(List <ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle("Change Player's?", isPlayer); if (isPlayer) { if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow) { parameterID = ChooseParameterGUI("Player ID:", parameters, parameterID, ParameterType.Integer); if (parameterID < 0) { playerID = ChoosePlayerGUI(playerID, true); } } } else { parameterID = Action.ChooseParameterGUI("FootstepSounds:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; footstepSounds = null; } else { footstepSounds = (FootstepSounds)EditorGUILayout.ObjectField("FootstepSounds:", footstepSounds, typeof(FootstepSounds), true); constantID = FieldToID <FootstepSounds> (footstepSounds, constantID); footstepSounds = IDToField <FootstepSounds> (footstepSounds, constantID, false); } } footstepSoundType = (FootstepSoundType)EditorGUILayout.EnumPopup("Clips to change:", footstepSoundType); newSounds = ShowClipsGUI(newSounds, (footstepSoundType == FootstepSoundType.Walk) ? "New walk sounds:" : "New run sounds:"); AfterRunningOption(); }
/** * <summary>Creates a new instance of the 'Sound: Change footsteps' Action</summary> * <param name = "footstepSoundsToModify">The FootstepSounds component to affect</param> * <param name = "footstepSoundType">The type of footsteps (Walk / Run) to change</param> * <param name = "newSounds">An array of sounds to set as the new sounds</param> * <returns>The generated Action</returns> */ public static ActionFootstepSounds CreateNew(FootstepSounds footstepSoundsToModify, FootstepSoundType footstepSoundType, AudioClip[] newSounds) { ActionFootstepSounds newAction = (ActionFootstepSounds)CreateInstance <ActionFootstepSounds>(); newAction.footstepSounds = footstepSoundsToModify; newAction.footstepSoundType = footstepSoundType; newAction.newSounds = newSounds; return(newAction); }