public static AudioSource[] getAudioSources(this DeckSounds ds) { List <AudioSource> sources = new List <AudioSource>(new AudioSource[9] { ds.bearingSource, ds.deckSource, ds.grindHitSource, ds.grindLoopSource, ds.shoesBoardHitSource, ds.shoesScrapeSource, ds.wheelHitSource, ds.wheelRollingLoopHighSource, ds.wheelRollingLoopLowSource, }); for (int i = 0; i < sources.Count; i++) { if (sources[i] == null) { sources.RemoveAt(i); Debug.LogWarning("AudioSource at index " + i + " is null"); } } return(sources.ToArray()); //ds.GetComponentsInChildren<AudioSource>() }
private void Awake() { if (DeckSounds._instance == null) { DeckSounds._instance = this; } this._allSources = base.GetComponentsInChildren <AudioSource>(); }
static bool Prefix(DeckSounds __instance, float scoop) { if (PlayerController.Instance.boardController.isSliding) { PlayerController.Instance.boardController.isSliding = false; return(false); } return(true); }
static public void Start() { deckSounds = DeckSounds.Instance; var deckSounds_traverse = Traverse.Create(deckSounds); clipForName = deckSounds_traverse.Field("clipForName").GetValue <Dictionary <string, AudioClip> >(); // get new rolling sounds LoadSound(ref deckSounds.rollingSoundSlow, "rolling_sound_slow.wav"); LoadSound(ref deckSounds.rollingSoundFast, "rolling_sound_fast.wav"); // replace source clip deckSounds.wheelRollingLoopLowSource.clip = deckSounds.rollingSoundSlow; deckSounds.wheelRollingLoopHighSource.clip = deckSounds.rollingSoundFast; // start playing deckSounds.wheelRollingLoopLowSource.Play(); deckSounds.wheelRollingLoopHighSource.Play(); // load single sounds LoadSound(ref deckSounds.tutorialBoardImpact, "tutorial_board_impact.wav"); LoadSound(ref deckSounds.grassRollLoop, "grass_roll_loop.wav"); // load arrays LoadSounds(ref deckSounds.bumps, "bumps*.wav"); LoadSounds(ref deckSounds.ollieScooped, "ollie_scooped*.wav"); LoadSounds(ref deckSounds.ollieSlow, "ollie_slow*.wav"); LoadSounds(ref deckSounds.ollieFast, "ollie_fast*.wav"); LoadSounds(ref deckSounds.boardLand, "board_land*.wav"); LoadSounds(ref deckSounds.boardImpacts, "board_impacts*.wav"); LoadSounds(ref deckSounds.bearingSounds, "bearing_sounds*.wav"); LoadSounds(ref deckSounds.shoesBoardBackImpacts, "shoes_board_back_impacts*.wav"); LoadSounds(ref deckSounds.shoesImpactGroundSole, "shoes_impact_ground_sole*.wav"); LoadSounds(ref deckSounds.shoesImpactGroundUpper, "shoes_impact_ground_upper*.wav"); LoadSounds(ref deckSounds.shoesMovementShort, "shoes_movement_short*.wav"); LoadSounds(ref deckSounds.shoesMovementLong, "shoes_movement_long*.wav"); LoadSounds(ref deckSounds.shoesPivotHeavy, "shoes_pivot_heavy*.wav"); LoadSounds(ref deckSounds.shoesPivotLight, "shoes_pivot_light*.wav"); LoadSounds(ref deckSounds.shoesPushImpact, "shoes_push_impact*.wav"); LoadSounds(ref deckSounds.shoesPushOff, "shoes_push_off*.wav"); LoadSounds(ref deckSounds.concreteGrindGeneralStart, "concrete_grind_start*.wav"); LoadSounds(ref deckSounds.concreteGrindGeneralLoop, "concrete_grind_loop*.wav"); LoadSounds(ref deckSounds.concreteGrindGeneralEnd, "concrete_grind_end*.wav"); LoadSounds(ref deckSounds.metalGrindGeneralStart, "metal_grind_start*.wav"); LoadSounds(ref deckSounds.metalGrindGeneralLoop, "metal_grind_loop*.wav"); LoadSounds(ref deckSounds.metalGrindGeneralEnd, "metal_grind_end*.wav"); LoadSounds(ref deckSounds.woodGrindGeneralStart, "wood_grind_start*.wav"); LoadSounds(ref deckSounds.woodGrindGeneralLoop, "wood_grind_loop*.wav"); LoadSounds(ref deckSounds.woodGrindGeneralEnd, "wood_grind_end*.wav"); Logger.Log("Sounds loaded"); }
static bool Prefix(DeckSounds __instance, float vol) { if (deckSoundsTraverse == null) { deckSoundsTraverse = Traverse.Create(DeckSounds.Instance); } vol *= 0.032f; var boardImpact = deckSoundsTraverse.Field <bool>("_boardImpactAllowed"); if (boardImpact.Value && vol > 0.01f) { // change volume vol = Mathf.Clamp(vol, 0.6f, 1.2f); var PlayRandomMethod = deckSoundsTraverse.Method("PlayRandomOneShotFromArray", new Type[] { typeof(AudioClip[]), typeof(AudioSource), typeof(float) }); switch (PlayerController.Instance.GetSurfaceTag(PlayerController.Instance.boardController.GetSurfaceTagString())) { case SkaterXL.Core.SurfaceTags.None: case SkaterXL.Core.SurfaceTags.Concrete: case SkaterXL.Core.SurfaceTags.Brick: PlayRandomMethod.GetValue(__instance.boardImpacts, __instance.deckSource, vol); break; case SkaterXL.Core.SurfaceTags.Tarmac: PlayRandomMethod.GetValue(__instance.boardTarmacImpacts, __instance.deckSource, vol); break; case SkaterXL.Core.SurfaceTags.Wood: PlayRandomMethod.GetValue(__instance.boardWoodImpacts, __instance.deckSource, vol); break; case SkaterXL.Core.SurfaceTags.Grass: PlayRandomMethod.GetValue(__instance.boardGrassImpacts, __instance.deckSource, vol); break; } boardImpact.Value = false; // change reset time __instance.Invoke("ResetBoardImpactAllowed", 0.1f); } return(false); }