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