private void _OnBodyExited(object body) { //Decrement number of bodies Bodies -= 1; //Search for GroundSound Node. If found, update sound library. GroundSound groundSound = NX.Find <GroundSound>((Node)body); if (groundSound != null && groundSound == OverlappedGroundSounds[groundSound.Priority]) { OverlappedGroundSounds.Remove(groundSound.Priority); UpdateAudioPlayers(); } }
private void UpdateAudioPlayers() { //Check if empty //GD.Print(OverlappedGroundSounds.Count); if (OverlappedGroundSounds.Count == 0) { return; } //Check for groundsound with highest priority int idx = OverlappedGroundSounds.Count - 1; if (OverlappedGroundSounds.GetByIndex(idx) != CurrentGroundSound) { GroundSound newGroundSound = (GroundSound)OverlappedGroundSounds.GetByIndex(idx); StepPlayer.Stream = newGroundSound.StepSound; JumpPlayer.Stream = newGroundSound.JumpSound; LandPlayer.Stream = newGroundSound.LandSound; CurrentGroundSound = newGroundSound; } }
private void _OnBodyEntered(object body) { //Increment number of bodies Bodies += 1; //Search for GroundSound Node. If found, update sound library. GroundSound groundSound = NX.Find <GroundSound>((Node)body); if (groundSound != null) { if (!OverlappedGroundSounds.ContainsKey(groundSound.Priority)) { OverlappedGroundSounds.Add(groundSound.Priority, groundSound); UpdateAudioPlayers(); } else { OverlappedGroundSounds[groundSound.Priority] = groundSound; } } //Allow character to bunny hop again CanBunnyHop = true; }