灭火bug
This commit is contained in:
parent
fd53218661
commit
6f287d0279
@ -38845,7 +38845,7 @@ MonoBehaviour:
|
||||
fireHurt: 10
|
||||
dis: 0
|
||||
maxfiredis: 2
|
||||
firedis: 20
|
||||
firedis: 4
|
||||
ps: {fileID: 0}
|
||||
us: {fileID: 0}
|
||||
--- !u!135 &5825030608256766515
|
||||
@ -38859,7 +38859,7 @@ SphereCollider:
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 1.5
|
||||
m_Radius: 4
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &4208561955345259803
|
||||
PrefabInstance:
|
||||
|
@ -7951,7 +7951,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 177156116ddbf5a4c811e0da050f8c9d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
detectionRadius: 2
|
||||
detectionRadius: 4
|
||||
fireLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
@ -9684,6 +9684,52 @@ MonoBehaviour:
|
||||
arrowDistanceText: {fileID: 1368271979}
|
||||
edgePadding: 50
|
||||
textOffset: {x: 0, y: -30}
|
||||
--- !u!1 &496089506
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 496089508}
|
||||
- component: {fileID: 496089507}
|
||||
m_Layer: 0
|
||||
m_Name: BurstCollisionWorld
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &496089507
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 496089506}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cellSpans:
|
||||
m_AlignBytes: 16
|
||||
--- !u!4 &496089508
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 496089506}
|
||||
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 &496425324
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -10455,52 +10501,6 @@ MonoBehaviour:
|
||||
Character: {fileID: 382802812}
|
||||
target: {fileID: 1149486592}
|
||||
distanceText: {fileID: 1878753544}
|
||||
--- !u!1 &556106642
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 556106644}
|
||||
- component: {fileID: 556106643}
|
||||
m_Layer: 0
|
||||
m_Name: BurstCollisionWorld
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &556106643
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 556106642}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cellSpans:
|
||||
m_AlignBytes: 16
|
||||
--- !u!4 &556106644
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 556106642}
|
||||
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!1001 &558790587
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -55,7 +55,7 @@ public class Skill_watering : MonoBehaviour
|
||||
if (obj.CompareTag("fire")) // 如果对象的标签是 "fire"
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, obj.transform.position);
|
||||
if (distance < minDistance)
|
||||
if (distance < detectionRadius)
|
||||
{
|
||||
nearestFire = obj;
|
||||
minDistance = distance;
|
||||
@ -64,8 +64,14 @@ public class Skill_watering : MonoBehaviour
|
||||
{
|
||||
currentItem.GetComponent<NoFire>().StartFire();
|
||||
}
|
||||
|
||||
if (currentItem.gameObject.name == "gun")
|
||||
{
|
||||
XFS.instance.water.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 如果找到了最近的火源,让角色朝向它
|
||||
@ -74,6 +80,10 @@ public class Skill_watering : MonoBehaviour
|
||||
Vector3 directionToFire = (nearestFire.transform.position - transform.position).normalized;
|
||||
directionToFire.y = 0; // 保持角色在水平方向上朝向火源
|
||||
transform.forward = directionToFire;
|
||||
if (currentItem.gameObject.name == "gun")
|
||||
{
|
||||
currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
/*
|
||||
@ -20,7 +21,7 @@ public class UseSkill : MonoBehaviour
|
||||
public Skill_Jump _skill_Jump;
|
||||
public Skill_watering _skill_Watering;
|
||||
//Fire fire = new Fire();
|
||||
|
||||
public bool IsWater = false;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -38,10 +39,23 @@ public class UseSkill : MonoBehaviour
|
||||
|
||||
}
|
||||
//Á¬½ÓË®¹Ü
|
||||
public void Initgun(GameObject ob)
|
||||
public void Initgun()
|
||||
{
|
||||
ob = _skill_Pick.Pick();
|
||||
ob.transform.localRotation = new Quaternion(0, 180, 0, 0);
|
||||
if (currentItem != null)
|
||||
{
|
||||
currentItem = _skill_Pick.Drop(currentItem);
|
||||
currentItem = null;
|
||||
}
|
||||
currentItem = _skill_Pick.Pick();
|
||||
|
||||
if (currentItem.transform.name == "NoFire")
|
||||
{
|
||||
currentItem.transform.Rotate(180f, -80f, -30f);
|
||||
}
|
||||
if (currentItem.transform.name == "gun")
|
||||
{
|
||||
currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Ê°È¡
|
||||
@ -65,7 +79,7 @@ public class UseSkill : MonoBehaviour
|
||||
}
|
||||
if (currentItem.transform.name == "gun")
|
||||
{
|
||||
currentItem.transform.Rotate(0, 180f, 0);
|
||||
currentItem.transform.rotation = new Quaternion(61.7036781f, 186.325302f, 348.049622f, 0);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
@ -90,18 +104,14 @@ public class UseSkill : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
Debug.Log(00000000000000000);
|
||||
IsWater=true;
|
||||
_skill_Watering.StartWatering(currentItem);
|
||||
if (currentItem.gameObject.name == "gun")
|
||||
{
|
||||
if (XFS.instance.IShavewater)
|
||||
{
|
||||
XFS.instance.water.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
IsWater = false;
|
||||
_skill_Watering.StopWatering(currentItem);
|
||||
if (currentItem.gameObject.name == "gun")
|
||||
{
|
||||
@ -109,6 +119,9 @@ public class UseSkill : MonoBehaviour
|
||||
{
|
||||
XFS.instance.water.SetActive(false);
|
||||
}
|
||||
|
||||
//currentItem.transform.rotation = new Quaternion(0, 180f,0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class Fire : MonoBehaviour
|
||||
|
||||
float timer = 0;
|
||||
//private Firestate firestate = Firestate.NotExtinguishFire;
|
||||
|
||||
private CharacterControl characterControl;//玩家控制器
|
||||
public UseSkill UseSkill;
|
||||
public CharacterControl characterControl;//玩家控制器
|
||||
void Start()
|
||||
{
|
||||
us = GameObject.Find("player").GetComponent<UseSkill>();
|
||||
@ -106,14 +106,11 @@ public class Fire : MonoBehaviour
|
||||
// // 恢复玩家控制器
|
||||
// if (!Input.GetMouseButton(0)) EnablePlayerControl();
|
||||
//}
|
||||
if (isPlayerInRange && Input.GetMouseButton(0))
|
||||
if (isPlayerInRange&& UseSkill.IsWater)
|
||||
{
|
||||
// 计算玩家与火源的距离
|
||||
dis = Vector3.Distance(GameObject.Find("player").transform.position, this.transform.position);
|
||||
if (XFS.instance.IShavewater)
|
||||
{
|
||||
XFS.instance.water.SetActive(true);
|
||||
}
|
||||
|
||||
// 如果玩家距离火源足够近且按下鼠标左键才触发灭火
|
||||
if (dis <= firedis)
|
||||
{
|
||||
@ -163,6 +160,9 @@ public class Fire : MonoBehaviour
|
||||
this.characterControl.Restore();
|
||||
this.gameObject.SetActive(false);
|
||||
Debug.Log("火焰已被熄灭");
|
||||
UseSkill = null;
|
||||
isPlayerInRange = false; // 玩家离开范围
|
||||
characterControl = null;
|
||||
}
|
||||
|
||||
// 当玩家进入火焰范围时触发
|
||||
@ -176,19 +176,20 @@ public class Fire : MonoBehaviour
|
||||
//}
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log(111111111);
|
||||
isPlayerInRange = true; // 玩家进入范围
|
||||
characterControl = other.GetComponent<CharacterControl>();
|
||||
|
||||
// 可以调整此处的触发范围
|
||||
float playerDistance = Vector3.Distance(other.transform.position, this.transform.position);
|
||||
if (playerDistance <= maxfiredis)
|
||||
{
|
||||
isPlayerInRange = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isPlayerInRange = false;
|
||||
}
|
||||
UseSkill= other.GetComponent<UseSkill>();
|
||||
//// 可以调整此处的触发范围
|
||||
//float playerDistance = Vector3.Distance(other.transform.position, this.transform.position);
|
||||
//if (playerDistance <= maxfiredis)
|
||||
//{
|
||||
// isPlayerInRange = true;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// isPlayerInRange = false;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +205,7 @@ public class Fire : MonoBehaviour
|
||||
{
|
||||
isPlayerInRange = false; // 玩家离开范围
|
||||
characterControl = null;
|
||||
UseSkill= null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class XFS : MonoBehaviour
|
||||
|
||||
public void connectGun()
|
||||
{
|
||||
|
||||
//UseSkill.Initgun(Gun);
|
||||
CharacterControl.enabled = true;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class XFS : MonoBehaviour
|
||||
CharacterControl.enabled = true;
|
||||
water.SetActive(false);
|
||||
IShavewater = true;
|
||||
|
||||
UseSkill.Initgun();
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
Loading…
Reference in New Issue
Block a user