From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/PlayerSounds.cs | 126 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 GameCode/PlayerSounds.cs (limited to 'GameCode/PlayerSounds.cs') diff --git a/GameCode/PlayerSounds.cs b/GameCode/PlayerSounds.cs new file mode 100644 index 0000000..aeffb32 --- /dev/null +++ b/GameCode/PlayerSounds.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using Sonigon; +using UnityEngine; + +public class PlayerSounds : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundCharacterJump; + + public SoundEvent soundCharacterJumpBig; + + public SoundEvent soundCharacterJumpEnsnare; + + public SoundEvent soundCharacterLand; + + public SoundEvent soundCharacterLandBig; + + private SoundParameterIntensity parameterIntensityLand = new SoundParameterIntensity(0f); + + public SoundEvent soundCharacterStickWall; + + public SoundEvent soundCharacterStickWallBig; + + private SoundParameterIntensity parameterIntensityStickWall = new SoundParameterIntensity(0f); + + public SoundEvent soundCharacterDamageScreenEdge; + + private CharacterData data; + + private List ensnareEffectList = new List(); + + private bool ensnareEnabled; + + public void AddEnsnareEffect(EnsnareEffect ensnareEffect) + { + ensnareEffectList.Add(ensnareEffect); + } + + public void RemoveEnsnareEffect(EnsnareEffect ensnareEffect) + { + ensnareEffectList.Remove(ensnareEffect); + } + + private void Start() + { + data = GetComponent(); + CharacterData characterData = data; + characterData.TouchGroundAction = (Action)Delegate.Combine(characterData.TouchGroundAction, new Action(TouchGround)); + CharacterData characterData2 = data; + characterData2.TouchWallAction = (Action)Delegate.Combine(characterData2.TouchWallAction, new Action(TouchWall)); + PlayerJump jump = data.jump; + jump.JumpAction = (Action)Delegate.Combine(jump.JumpAction, new Action(Jump)); + } + + public void Jump() + { + ensnareEnabled = false; + for (int num = ensnareEffectList.Count - 1; num >= 0; num--) + { + if (ensnareEffectList[num] == null) + { + ensnareEffectList.RemoveAt(num); + } + } + for (int i = 0; i < ensnareEffectList.Count; i++) + { + if (ensnareEffectList[i].soundEnsnareJumpChange) + { + ensnareEnabled = true; + } + } + if (ensnareEnabled) + { + if (ensnareEnabled) + { + SoundManager.Instance.Play(soundCharacterJumpEnsnare, base.transform); + } + } + else if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterJumpBig, base.transform); + } + else + { + SoundManager.Instance.Play(soundCharacterJump, base.transform); + } + } + + public void TouchGround(float sinceGrounded, Vector3 pos, Vector3 normal, Transform ground) + { + if (sinceGrounded > 0.05f) + { + parameterIntensityLand.intensity = sinceGrounded; + if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterLandBig, base.transform, parameterIntensityLand); + } + else + { + SoundManager.Instance.Play(soundCharacterLand, base.transform, parameterIntensityLand); + } + } + } + + public void TouchWall(float sinceWall, Vector3 pos, Vector3 normal) + { + float num = sinceWall; + if (data.sinceGrounded < num) + { + num = data.sinceGrounded; + } + if (num > 0.05f) + { + parameterIntensityStickWall.intensity = num; + if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterStickWallBig, base.transform, parameterIntensityStickWall); + } + else + { + SoundManager.Instance.Play(soundCharacterStickWall, base.transform, parameterIntensityStickWall); + } + } + } +} -- cgit v1.1-26-g67d0