This commit is contained in:
2025-10-29 20:16:08 +08:00
26 changed files with 764 additions and 4 deletions

Binary file not shown.

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b7b2129a14201e34b885d7cdc4ae2d9f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 5c8921fb34c226c47b32fd7563d635c8
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 577e8858b2d83114398c718292442ef8
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 957dfe377c8f4334aa6baeb7f9e0e13a
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 477fd4e31293f704f96ea5dfab139088
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 55ca4d0dac5ebb7408f043347aa87cda
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 8a583f94531576c419052919a737ec3e
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: c30608484fbebf54cb5369393740e335
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -15,6 +15,7 @@ GameObject:
- component: {fileID: 162156210837205425}
- component: {fileID: 4434834246038522293}
- component: {fileID: 7931804082152492731}
- component: {fileID: 5405840786762141308}
m_Layer: 0
m_Name: Button
m_TagString: Untagged
@@ -145,6 +146,9 @@ MonoBehaviour:
isEnableSendSignal: 1
signalDuration: 1
buttonPressPoint: {fileID: 9183523148397755279}
turnSound: {fileID: 8300000, guid: 477fd4e31293f704f96ea5dfab139088, type: 3}
returnSound: {fileID: 8300000, guid: 55ca4d0dac5ebb7408f043347aa87cda, type: 3}
buttonSound: {fileID: 5405840786762141308}
--- !u!114 &7931804082152492731
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -159,6 +163,102 @@ MonoBehaviour:
m_EditorClassIdentifier:
isEnableEdit: 1
isOpenInEditor: 1
--- !u!82 &5405840786762141308
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2052340463965227198}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &9183523148397755279
GameObject:
m_ObjectHideFlags: 0

View File

@@ -242,6 +242,7 @@ GameObject:
- component: {fileID: 4936355834716623489}
- component: {fileID: 7767327858011138776}
- component: {fileID: 3931680811062325468}
- component: {fileID: 792532805521400095}
m_Layer: 0
m_Name: Lever
m_TagString: Untagged
@@ -287,6 +288,9 @@ MonoBehaviour:
componentName:
isEnableSendSignal: 1
rotationPrefab: {fileID: 5655992473923178902}
turnSound: {fileID: 8300000, guid: 477fd4e31293f704f96ea5dfab139088, type: 3}
returnSound: {fileID: 8300000, guid: 55ca4d0dac5ebb7408f043347aa87cda, type: 3}
LeverSound: {fileID: 792532805521400095}
--- !u!65 &7767327858011138776
BoxCollider:
m_ObjectHideFlags: 0
@@ -329,3 +333,99 @@ BoxCollider:
serializedVersion: 3
m_Size: {x: 0.5, y: 2, z: 0.5}
m_Center: {x: 0, y: 0.34, z: 0}
--- !u!82 &792532805521400095
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6227019518059310355}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@@ -10,6 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 4221136162904276318}
- component: {fileID: 9080026706464259533}
- component: {fileID: 3038609949214541956}
m_Layer: 0
m_Name: ScreenGlitchManager
m_TagString: Untagged
@@ -47,3 +48,101 @@ MonoBehaviour:
rendererData: {fileID: 11400000, guid: c40be3174f62c4acf8c1216858c64956, type: 2}
featureName: ScreenGlitchFeature
glitchDuration: 1
GlitchSoundSource: {fileID: 3038609949214541956}
GlitchSoundClip: {fileID: 8300000, guid: c30608484fbebf54cb5369393740e335, type: 3}
--- !u!82 &3038609949214541956
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3963564801859128168}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@@ -156,6 +156,7 @@ GameObject:
- component: {fileID: 5633281206562703781}
- component: {fileID: 4616892119606260346}
- component: {fileID: 3493211357972151578}
- component: {fileID: 327197785400436727}
m_Layer: 8
m_Name: Player
m_TagString: Player
@@ -239,6 +240,9 @@ MonoBehaviour:
groundMask:
serializedVersion: 2
m_Bits: 64
playerSound: {fileID: 327197785400436727}
jumpSound: {fileID: 8300000, guid: 5c8921fb34c226c47b32fd7563d635c8, type: 3}
walkSound: {fileID: 8300000, guid: 957dfe377c8f4334aa6baeb7f9e0e13a, type: 3}
fallDamageThreshold: 3
pushPower: 0.5
--- !u!114 &2963170313432786625
@@ -348,6 +352,102 @@ MonoBehaviour:
m_EditorClassIdentifier:
isEnablePlayerDialogue: 1
firstPersonRaycaster: {fileID: 8217262775185484522}
--- !u!82 &327197785400436727
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550102669167288263}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &3610935294554348573
GameObject:
m_ObjectHideFlags: 0

View File

@@ -15,6 +15,7 @@ GameObject:
- component: {fileID: -7803032184951374842}
- component: {fileID: 5936472319330568279}
- component: {fileID: 6372441752678980756}
- component: {fileID: 1031207251367064294}
m_Layer: 0
m_Name: PressurePlate
m_TagString: Untagged
@@ -128,6 +129,9 @@ MonoBehaviour:
plateSize: {x: 2, y: 0.4, z: 2}
plateOffset: {x: 0, y: 0.5, z: 0}
pressTopPrefab: {fileID: 8314966853544917208}
pressedSound: {fileID: 8300000, guid: 477fd4e31293f704f96ea5dfab139088, type: 3}
returnSound: {fileID: 8300000, guid: 55ca4d0dac5ebb7408f043347aa87cda, type: 3}
plateSound: {fileID: 1031207251367064294}
--- !u!114 &5936472319330568279
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -163,6 +167,102 @@ BoxCollider:
serializedVersion: 3
m_Size: {x: 2, y: 2.0000005, z: 2.0000005}
m_Center: {x: 0, y: 0, z: 0}
--- !u!82 &1031207251367064294
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2191333364839819432}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &8314966853544917208
GameObject:
m_ObjectHideFlags: 0

View File

@@ -14,6 +14,10 @@ namespace Script.Gameplay.Facility
private bool isPressing = false;
private Vector3 buttonInitialPosition;
[SerializeField] private AudioClip turnSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource buttonSound;
private void Awake()
{
buttonInitialPosition = buttonPressPoint.transform.position;
@@ -37,12 +41,16 @@ namespace Script.Gameplay.Facility
isPressing = true;
// 按钮按下的动画或效果可以在这里添加
buttonPressPoint.transform.position = new Vector3(0, 0, 0);
buttonSound.clip = turnSound;
buttonSound.Play();
yield return new WaitForSeconds(signalDuration);
SendSignal(false, this.gameObject);
isPressing = false;
// 按钮弹起的动画或效果可以在这里添加
buttonPressPoint.transform.position = buttonInitialPosition;
buttonSound.clip = returnSound;
buttonSound.Play();
}
}

View File

@@ -9,6 +9,9 @@ namespace Script.Gameplay.Facility
{
private bool isPulled = false;
[SerializeField] private GameObject rotationPrefab;
[SerializeField] private AudioClip turnSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource LeverSound;
public override string GetInteractPrompt()
{
@@ -30,11 +33,15 @@ namespace Script.Gameplay.Facility
{
// 旋转拉杆到下拉位置
rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 45f);
LeverSound.clip = turnSound;
LeverSound.Play();
}
else
{
// 旋转拉杆回到初始位置
rotationPrefab.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
LeverSound.clip = returnSound;
LeverSound.Play();
}
}
}

View File

@@ -11,6 +11,10 @@ namespace Script.Gameplay.Facility
[SerializeField] private Vector3 plateOffset = Vector3.up * 0.1f;
[SerializeField] private GameObject pressTopPrefab;
[SerializeField] private AudioClip pressedSound;
[SerializeField] private AudioClip returnSound;
[SerializeField] private AudioSource plateSound;
private bool lastState = false;
private bool hasObject = false;
@@ -27,13 +31,21 @@ namespace Script.Gameplay.Facility
{
// 被压下动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 0.1f);
plateSound.clip = pressedSound;
plateSound.Play();
}
}
else
{
// 弹起动画
if (pressTopPrefab != null)
{
pressTopPrefab.transform.localPosition = new Vector3(0, 0, 1);
plateSound.clip = returnSound;
plateSound.Play();
}
}
}
}

View File

@@ -17,6 +17,9 @@ namespace Script.Gameplay.Global
[Tooltip("要控制的 RendererFeature 名称")] public string featureName = "ScreenGlitchFeature";
[SerializeField] private float glitchDuration = 1f;
[SerializeField] private AudioSource GlitchSoundSource;
[SerializeField] private AudioClip GlitchSoundClip;
public void SetFeatureActive(bool active)
{
if (rendererData == null)
@@ -42,6 +45,10 @@ namespace Script.Gameplay.Global
public IEnumerator TriggerGlitchEffect()
{
SetFeatureActive(true);
if (GlitchSoundSource != null && GlitchSoundClip != null)
{
GlitchSoundSource.PlayOneShot(GlitchSoundClip);
}
yield return new WaitForSeconds(glitchDuration);
SetFeatureActive(false);
}

View File

@@ -19,6 +19,10 @@ namespace Script.Gameplay.Player
[Tooltip("地面检测半径")] public float groundDistance = 0.4f;
[Tooltip("地面层LayerMask")] public LayerMask groundMask;
[Header("Sound Effects")]
[SerializeField] private AudioSource playerSound;
[SerializeField] private AudioClip jumpSound;
[SerializeField] private AudioClip walkSound;
private float initSpeed;
private CharacterController characterController;
@@ -35,6 +39,10 @@ namespace Script.Gameplay.Player
[Tooltip("推动物体的力量")] [SerializeField]
private float pushPower = 2f;
[Header("Footstep Settings")]
[Tooltip("判定为走路的最小输入强度")] [SerializeField]
private float walkThreshold = 0.1f;
private void Awake()
{
characterController = GetComponent<CharacterController>();
@@ -42,6 +50,9 @@ namespace Script.Gameplay.Player
Debug.LogError("PlayerMoveController 需要 CharacterController 组件!");
initSpeed = speed;
playerSound = playerSound != null ? playerSound : GetComponent<AudioSource>();
if (playerSound == null)
Debug.LogWarning("PlayerMoveController: AudioSource 未设置,音效将不会播放。");
}
private void Start()
@@ -95,9 +106,17 @@ namespace Script.Gameplay.Player
Vector3 move = transform.right * x + transform.forward * z;
characterController.Move(move * speed * Time.deltaTime);
// 走路音效逻辑:在地面且移动输入较大时播放循环走路音效
HandleFootstepAudio(x, z);
// 跳跃
if (isGrounded && inputManager.JumpPressed)
{
// 跳跃时停止走路循环声并播放跳跃音效(一次性)
StopWalkAudioIfPlaying();
if (playerSound != null && jumpSound != null)
playerSound.PlayOneShot(jumpSound);
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
@@ -106,6 +125,45 @@ namespace Script.Gameplay.Player
characterController.Move(velocity * Time.deltaTime);
}
private void HandleFootstepAudio(float x, float z)
{
if (playerSound == null || walkSound == null) return;
float inputMag = new Vector2(x, z).magnitude;
bool shouldPlayWalk = isGrounded && inputMag > walkThreshold;
if (shouldPlayWalk)
{
if (playerSound.clip != walkSound || !playerSound.isPlaying)
{
playerSound.clip = walkSound;
playerSound.loop = true;
playerSound.Play();
}
}
else
{
// 如果当前正在播放走路音效则停止
if (playerSound.clip == walkSound && playerSound.isPlaying)
{
playerSound.Stop();
playerSound.loop = false;
playerSound.clip = null;
}
}
}
private void StopWalkAudioIfPlaying()
{
if (playerSound == null) return;
if (playerSound.clip == walkSound && playerSound.isPlaying)
{
playerSound.Stop();
playerSound.loop = false;
playerSound.clip = null;
}
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
@@ -114,7 +172,7 @@ namespace Script.Gameplay.Player
{
// 忽略从下方碰撞
if (hit.moveDirection.y < -0.3f) return;
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);
body.AddForce(pushDir * pushPower, ForceMode.Impulse);
}
@@ -130,4 +188,4 @@ namespace Script.Gameplay.Player
speed = initSpeed;
}
}
}
}