This commit is contained in:
2026-06-05 21:24:41 +07:00
parent 91183760fb
commit 98806b862d
16 changed files with 6386 additions and 3028 deletions

View File

@@ -38,6 +38,13 @@ namespace Invector
EditorGUILayout.PropertyField(serializedObject.FindProperty("_useTriggerEnter"));
serializedObject.FindProperty("debugTextureName").boolValue = EditorGUILayout.Toggle("Debug Texture Name", serializedObject.FindProperty("debugTextureName").boolValue);
GUILayout.BeginVertical("box");
GUILayout.Box("AI Noise Settings", GUILayout.ExpandWidth(true));
EditorGUILayout.PropertyField(serializedObject.FindProperty("emitAINoise"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("aiNoiseRange"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("npcLayer"));
GUILayout.EndVertical();
if (serializedObject.FindProperty("animationType").enumValueIndex == (int)AnimationType.Humanoid)
{
GUILayout.BeginHorizontal("box");

View File

@@ -20,6 +20,11 @@ namespace Invector
public bool SpawnParticle { get { return _spawnParticle; } set { _spawnParticle = value; } }
public bool SpawnStepMark { get { return _spawnStepMark; } set { _spawnStepMark = value; } }
[Header("AI Noise Settings")]
public bool emitAINoise = true;
public float aiNoiseRange = 10f;
public LayerMask npcLayer;
protected int surfaceIndex = 0;
protected Terrain terrain;
protected TerrainCollider terrainCollider;
@@ -248,6 +253,37 @@ namespace Invector
currentFootStep.spawnParticleEffect = SpawnParticle;
currentFootStep.spawnStepMarkEffect = SpawnStepMark;
SpawnSurfaceEffect(currentFootStep);
if (emitAINoise) EmitAINoise();
}
}
protected virtual void EmitAINoise()
{
float currentRange = aiNoiseRange;
float currentVolume = Volume;
// Kiểm tra trạng thái ngồi từ Animator
Animator anim = GetComponent<Animator>();
if (anim != null)
{
// Nếu đang ngồi (IsCrouching = true), giảm 50% vùng phát hiện và âm lượng
if (anim.GetBool("IsCrouching"))
{
currentRange *= 0.5f;
currentVolume *= 0.5f;
}
}
// Tìm tất cả Collider trong bán kính tiếng động thuộc Layer NPC
Collider[] hitColliders = Physics.OverlapSphere(transform.position, currentRange, npcLayer);
foreach (var hit in hitColliders)
{
var npc = hit.GetComponentInParent<EnemyAI>();
if (npc != null)
{
npc.HearNoise(transform.position, currentVolume);
}
}
}

View File

@@ -115,7 +115,7 @@ Material:
- _ZWrite: 0
m_Colors:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 0.6132076, g: 0.1454958, b: 0.118592024, a: 0.1882353}
- _Color: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
- _Emission: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
@@ -123,6 +123,6 @@ Material:
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0, g: 0, b: 0, a: 0}
- _Specular: {r: 1, g: 1, b: 1, a: 0}
- _TintColor: {r: 0.6132076, g: 0.1454958, b: 0.118592024, a: 0.1882353}
- _TintColor: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
m_BuildTextureStacks: []
m_AllowLocking: 1