灭火bug

This commit is contained in:
杨号敬 2024-12-24 10:58:23 +08:00
parent 4427015945
commit 96391fa3bb
4 changed files with 73 additions and 59 deletions

View File

@ -704,6 +704,52 @@ Transform:
m_CorrespondingSourceObject: {fileID: 470742, guid: 1a983474f33e2a3448edad336be6c954, type: 3} m_CorrespondingSourceObject: {fileID: 470742, guid: 1a983474f33e2a3448edad336be6c954, type: 3}
m_PrefabInstance: {fileID: 39914477} m_PrefabInstance: {fileID: 39914477}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &41603123
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 41603125}
- component: {fileID: 41603124}
m_Layer: 0
m_Name: BurstCollisionWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &41603124
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 41603123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
m_Name:
m_EditorClassIdentifier:
cellSpans:
m_AlignBytes: 16
--- !u!4 &41603125
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 41603123}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 38
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &51381387 --- !u!1 &51381387
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7951,10 +7997,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3} m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
detectionRadius: 10 detectionRadius: 2
fireLayerMask: fireLayerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 0 m_Bits: 1
--- !u!114 &382802819 --- !u!114 &382802819
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -26375,7 +26421,7 @@ Transform:
- {fileID: 1043610486} - {fileID: 1043610486}
- {fileID: 437592030} - {fileID: 437592030}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 38 m_RootOrder: 37
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1670656696 --- !u!1 &1670656696
GameObject: GameObject:
@ -26796,7 +26842,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!81 &1707678917 --- !u!81 &1707678917
AudioListener: AudioListener:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -27568,52 +27614,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: 425252, guid: c1d713571e37c7945aadfdbabc6c59a4, type: 3} m_CorrespondingSourceObject: {fileID: 425252, guid: c1d713571e37c7945aadfdbabc6c59a4, type: 3}
m_PrefabInstance: {fileID: 1750111327} m_PrefabInstance: {fileID: 1750111327}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &1755366624
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1755366626}
- component: {fileID: 1755366625}
m_Layer: 0
m_Name: BurstCollisionWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1755366625
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1755366624}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
m_Name:
m_EditorClassIdentifier:
cellSpans:
m_AlignBytes: 16
--- !u!4 &1755366626
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1755366624}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 37
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1755977750 --- !u!1001 &1755977750
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -19,13 +19,10 @@ public class Skill_watering : MonoBehaviour
/// <param name="currentItem">需要一个物体</param> /// <param name="currentItem">需要一个物体</param>
public void StartWatering(GameObject currentItem) public void StartWatering(GameObject currentItem)
{ {
CharacterAin.SetSkillAin(CharacterSkill.Watering);
// 检测附近的火源并调整角色朝向 // 检测附近的火源并调整角色朝向
DetectAndLookAtFire(); DetectAndLookAtFire(currentItem);
if (currentItem.GetComponent<NoFire>() != null)
{
currentItem.GetComponent<NoFire>().StartFire();
}
} }
/// <summary> /// <summary>
@ -44,8 +41,9 @@ public class Skill_watering : MonoBehaviour
/// <summary> /// <summary>
/// 检测周围的火源,并让角色朝向最近的火源 /// 检测周围的火源,并让角色朝向最近的火源
/// </summary> /// </summary>
private void DetectAndLookAtFire() private void DetectAndLookAtFire(GameObject currentItem)
{ {
Collider[] objectsInRange = Physics.OverlapSphere(transform.position, detectionRadius, fireLayerMask); Collider[] objectsInRange = Physics.OverlapSphere(transform.position, detectionRadius, fireLayerMask);
// 遍历范围内的所有对象,查找标签为 "fire" 的对象 // 遍历范围内的所有对象,查找标签为 "fire" 的对象
@ -61,6 +59,11 @@ public class Skill_watering : MonoBehaviour
{ {
nearestFire = obj; nearestFire = obj;
minDistance = distance; minDistance = distance;
CharacterAin.SetSkillAin(CharacterSkill.Watering);
if (currentItem.GetComponent<NoFire>() != null)
{
currentItem.GetComponent<NoFire>().StartFire();
}
} }
} }
} }

View File

@ -57,6 +57,10 @@ public class UseSkill : MonoBehaviour
{ {
currentItem.transform.Rotate(180f, -80f, -30f); currentItem.transform.Rotate(180f, -80f, -30f);
} }
if (currentItem.transform.name == "gun")
{
currentItem.transform.Rotate(0, 180f, 0);
}
} }
if (Input.GetKeyDown(KeyCode.Q)) if (Input.GetKeyDown(KeyCode.Q))
{ {
@ -75,7 +79,11 @@ public class UseSkill : MonoBehaviour
} }
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
if (currentItem == null)
{
return;
}
Debug.Log(00000000000000000);
_skill_Watering.StartWatering(currentItem); _skill_Watering.StartWatering(currentItem);
if (currentItem.gameObject.name == "gun") if (currentItem.gameObject.name == "gun")
{ {

View File

@ -129,10 +129,13 @@ public class Fire : MonoBehaviour
// 如果玩家按住键达到指定时间,停止火焰 // 如果玩家按住键达到指定时间,停止火焰
StopFire(); StopFire();
isExtinguishing = true; // 防止重复触发灭火 isExtinguishing = true; // 防止重复触发灭火
if (XFS.instance.IShavewater)
{
XFS.instance.water.SetActive(false); XFS.instance.water.SetActive(false);
} }
} }
} }
}
else else
{ {
// 如果松开按键或者离开范围,重置计时 // 如果松开按键或者离开范围,重置计时