From 48e66423e69dfb4549e53ee40f3c17dbfb5e210b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Wed, 25 Dec 2024 11:12:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AD=E7=81=AB=EF=BC=8C=E6=B0=B4=E7=AE=A1?= =?UTF-8?q?=EF=BC=8C=E4=BB=BB=E5=8A=A1=E6=B6=88=E9=98=B2=E6=A0=93=EF=BC=8C?= =?UTF-8?q?=E6=B0=B4=E6=9E=AA=EF=BC=8C=E6=91=84=E5=83=8F=E5=A4=B4BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Scenes/Tmap 1.unity | 184 +++++++++++++----- .../Script/Character/Skills/Skill_Pick.cs | 3 +- .../Script/Character/Skills/UseSkill.cs | 5 + xiaofang/Assets/Script/Item/Fire.cs | 14 +- xiaofang/Assets/Script/Item/Firelive.cs | 6 +- xiaofang/Assets/Script/XFS.cs | 15 +- .../Script/hylScripts/JoystickController.cs | 23 ++- 7 files changed, 188 insertions(+), 62 deletions(-) diff --git a/xiaofang/Assets/Scenes/Tmap 1.unity b/xiaofang/Assets/Scenes/Tmap 1.unity index 610508f1..7761c121 100644 --- a/xiaofang/Assets/Scenes/Tmap 1.unity +++ b/xiaofang/Assets/Scenes/Tmap 1.unity @@ -122,6 +122,52 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 23800000, guid: 488ef2130110f294c9514fb87604a470, type: 2} +--- !u!1 &309057 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 309059} + - component: {fileID: 309058} + m_Layer: 0 + m_Name: BurstCollisionWorld + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &309058 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 309057} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} + m_Name: + m_EditorClassIdentifier: + cellSpans: + m_AlignBytes: 16 +--- !u!4 &309059 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 309057} + 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 &772510 PrefabInstance: m_ObjectHideFlags: 0 @@ -18488,6 +18534,11 @@ Transform: m_CorrespondingSourceObject: {fileID: 459604, guid: 3c43c669847c1ac448012026c6b64464, type: 3} m_PrefabInstance: {fileID: 1111438060} m_PrefabAsset: {fileID: 0} +--- !u!1 &1111533235 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 7256832922758735076, guid: 2b6da6cb0c6edad4eb364a43fc9035cd, type: 3} + m_PrefabInstance: {fileID: 772510} + m_PrefabAsset: {fileID: 0} --- !u!64 &1119338101 MeshCollider: m_ObjectHideFlags: 0 @@ -20238,52 +20289,6 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 9042771077998628582, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} ---- !u!1 &1255556698 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1255556700} - - component: {fileID: 1255556699} - m_Layer: 0 - m_Name: BurstCollisionWorld - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1255556699 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1255556698} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} - m_Name: - m_EditorClassIdentifier: - cellSpans: - m_AlignBytes: 16 ---- !u!4 &1255556700 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1255556698} - 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 &1258596519 PrefabInstance: m_ObjectHideFlags: 0 @@ -27243,6 +27248,7 @@ MonoBehaviour: us: {fileID: 0} UseSkill: {fileID: 0} characterControl: {fileID: 0} + TimeText: {fileID: 0} --- !u!135 &1629676688 SphereCollider: m_ObjectHideFlags: 0 @@ -27275,6 +27281,7 @@ MonoBehaviour: spreadRadius: 3 windDirection: 0 SpreadFireNumber: 3 + time: {fileID: 1716067987} --- !u!1001 &1637601597 PrefabInstance: m_ObjectHideFlags: 0 @@ -28368,6 +28375,86 @@ Transform: m_CorrespondingSourceObject: {fileID: 409468, guid: d82036d69bdc3414694f36420570444f, type: 3} m_PrefabInstance: {fileID: 1713226868} m_PrefabAsset: {fileID: 0} +--- !u!1 &1716067985 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1716067986} + - component: {fileID: 1716067988} + - component: {fileID: 1716067987} + m_Layer: 5 + m_Name: Text (Legacy) (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1716067986 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1716067985} + 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: 2613237552313206660} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -0.00012207031, y: -165} + m_SizeDelta: {x: 488.78, y: 74} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1716067987 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1716067985} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0, b: 0.019583702, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 39 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: 00:02 +--- !u!222 &1716067988 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1716067985} + m_CullTransparentMesh: 1 --- !u!1001 &1717992086 PrefabInstance: m_ObjectHideFlags: 0 @@ -30202,7 +30289,7 @@ CapsuleCollider: m_Material: {fileID: 0} m_IsTrigger: 1 m_Enabled: 1 - m_Radius: 2 + m_Radius: 1 m_Height: 1.2332822 m_Direction: 1 m_Center: {x: -0.000000059604645, y: -0.00000005960466, z: 0} @@ -30242,7 +30329,7 @@ MonoBehaviour: Gun: {fileID: 1528375180} Hand: {fileID: 1036449735} XFsTransform: {fileID: 1604673292} - ShuiguanGameObject: {fileID: 2057924365745864530} + ShuiguanGameObject: {fileID: 1111533235} firewater: {fileID: 8607906409360804035, guid: b5be25eadef55294691fff85129cc656, type: 3} water: {fileID: 382802809} IShavewater: 0 @@ -38789,6 +38876,7 @@ RectTransform: m_Children: - {fileID: 2613237551480729981} - {fileID: 2613237552227620595} + - {fileID: 1716067986} m_Father: {fileID: 2613237552014132572} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/xiaofang/Assets/Script/Character/Skills/Skill_Pick.cs b/xiaofang/Assets/Script/Character/Skills/Skill_Pick.cs index 51bc2767..8cd6747e 100644 --- a/xiaofang/Assets/Script/Character/Skills/Skill_Pick.cs +++ b/xiaofang/Assets/Script/Character/Skills/Skill_Pick.cs @@ -65,7 +65,7 @@ public class Skill_Pick : MonoBehaviour item.transform.localPosition = relativePosition; // 假设玩家手中有一个默认的持物位置 item.transform.localRotation = Quaternion.Euler(relativeRotation); // 重置旋转 - + Destroy(item.GetComponent()); Debug.Log("^^^^^^^^^^^^^^^^^^^^^^^^^"); // 更新当前持有的物品 @@ -99,6 +99,7 @@ public class Skill_Pick : MonoBehaviour itemCollider.enabled = true; } + currentItem.AddComponent(); // 将物品放置在玩家当前位置的地面上 Vector3 dropPosition = new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z); diff --git a/xiaofang/Assets/Script/Character/Skills/UseSkill.cs b/xiaofang/Assets/Script/Character/Skills/UseSkill.cs index 7025f130..8389ed0a 100644 --- a/xiaofang/Assets/Script/Character/Skills/UseSkill.cs +++ b/xiaofang/Assets/Script/Character/Skills/UseSkill.cs @@ -91,6 +91,7 @@ public class UseSkill : MonoBehaviour public void Drop() { currentItem = _skill_Pick.Drop(currentItem); + } //拾取 void Skill_Pick() @@ -160,5 +161,9 @@ public class UseSkill : MonoBehaviour } } + public void FireOUt() + { + _skill_Watering.StopWatering(currentItem); + } } diff --git a/xiaofang/Assets/Script/Item/Fire.cs b/xiaofang/Assets/Script/Item/Fire.cs index 894eaaa9..aeea0fab 100644 --- a/xiaofang/Assets/Script/Item/Fire.cs +++ b/xiaofang/Assets/Script/Item/Fire.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; public enum Firestate { @@ -28,12 +29,14 @@ public class Fire : MonoBehaviour float timer = 0; //private Firestate firestate = Firestate.NotExtinguishFire; - public UseSkill UseSkill; + public UseSkill UseSkill; public CharacterControl characterControl;//玩家控制器 + public Text TimeText; void Start() { us = GameObject.Find("player").GetComponent(); ps = GameObject.Find("player").GetComponent(); + TimeText.gameObject.SetActive(false); } @@ -114,13 +117,14 @@ public class Fire : MonoBehaviour // 如果玩家距离火源足够近且按下鼠标左键才触发灭火 if (dis <= firedis) { + TimeText.gameObject.SetActive(true); // 禁用玩家控制器,防止玩家移动 if (!isExtinguishing) DisablePlayerControl(); - + holdTime += Time.deltaTime; Debug.Log("灭火计时:" + holdTime); - + TimeText.GetComponent().text = "灭火计时:" + holdTime; if (holdTime >= extinguishTime && !isExtinguishing) { // 如果玩家按住键达到指定时间,停止火焰 @@ -130,6 +134,7 @@ public class Fire : MonoBehaviour { XFS.instance.water.SetActive(false); } + TimeText.gameObject.SetActive(false); } } } @@ -163,8 +168,9 @@ public class Fire : MonoBehaviour UseSkill = null; isPlayerInRange = false; // 玩家离开范围 characterControl = null; + us.FireOUt(); } - + // 当玩家进入火焰范围时触发 private void OnTriggerEnter(Collider other) { diff --git a/xiaofang/Assets/Script/Item/Firelive.cs b/xiaofang/Assets/Script/Item/Firelive.cs index cf94d988..dd10b8aa 100644 --- a/xiaofang/Assets/Script/Item/Firelive.cs +++ b/xiaofang/Assets/Script/Item/Firelive.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; /* @@ -30,10 +31,13 @@ public class Firelive : MonoBehaviour public int SpreadFireNumber=1; private bool Canbig = true; + + public Text time; // Start is called before the first frame update void Start() { StartBurning(); + time.gameObject.SetActive(false); } @@ -74,7 +78,7 @@ public class Firelive : MonoBehaviour Destroy(currentFire); currentFire=Instantiate(bigfire, transform.position, Quaternion.identity); Canbig = false; - + currentFire.GetComponent().TimeText = time; StartCoroutine(DelayedSpread()); } diff --git a/xiaofang/Assets/Script/XFS.cs b/xiaofang/Assets/Script/XFS.cs index c7a1e555..5e2f1731 100644 --- a/xiaofang/Assets/Script/XFS.cs +++ b/xiaofang/Assets/Script/XFS.cs @@ -21,24 +21,35 @@ public class XFS : MonoBehaviour public UseSkill UseSkill; void Start() { - instance=this; + ShuiguanGameObject.SetActive(false); + instance =this; ConnectGun.onClick.AddListener((() => { + PLayerLook(); CharacterControl.enabled = false; Invoke("connectGun",6f);})); ConnectFa.onClick.AddListener(() => { + PLayerLook(); + ShuiguanGameObject.SetActive(true); CharacterControl.enabled = false; Invoke("connectFa", 6f); }); OpenFa.onClick.AddListener(() => { + PLayerLook(); CharacterControl.enabled = false; Invoke("openFa", 6f); }); } + public void PLayerLook() + { + GameObject.FindGameObjectWithTag("Player").transform.LookAt(new Vector3(this.transform.position.x, GameObject.FindGameObjectWithTag("Player").transform.position.y, this.transform.position.z)); + } + public void connectGun() { //UseSkill.Initgun(Gun); CharacterControl.enabled = true; + } public void connectFa() @@ -46,6 +57,7 @@ public class XFS : MonoBehaviour Solver solver = ShuiguanGameObject.GetComponent(); solver.INit(Gun.transform); CharacterControl.enabled = true; + } public void openFa() @@ -58,6 +70,7 @@ public class XFS : MonoBehaviour water.SetActive(false); IShavewater = true; UseSkill.Initgun(); + } // Update is called once per frame void Update() diff --git a/xiaofang/Assets/Script/hylScripts/JoystickController.cs b/xiaofang/Assets/Script/hylScripts/JoystickController.cs index e3182733..80f40541 100644 --- a/xiaofang/Assets/Script/hylScripts/JoystickController.cs +++ b/xiaofang/Assets/Script/hylScripts/JoystickController.cs @@ -47,15 +47,24 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler targetXRotation += joystickInput.x * rotationSpeed * Time.deltaTime; targetYRotation -= joystickInput.y * rotationSpeed * Time.deltaTime; - // 限制水平旋转范围,防止摄像机旋转过头 - targetXRotation = Mathf.Clamp(targetXRotation, horizontalMinRotation, horizontalMaxRotation); - - // 限制垂直旋转范围,防止摄像机翻转 - targetYRotation = Mathf.Clamp(targetYRotation, verticalMinRotation, verticalMaxRotation); + //// 限制水平旋转范围,防止摄像机旋转过头 + //targetXRotation = Mathf.Clamp(targetXRotation, horizontalMinRotation, horizontalMaxRotation); + //// 限制垂直旋转范围,防止摄像机翻转 + //targetYRotation = Mathf.Clamp(targetYRotation, verticalMinRotation, verticalMaxRotation); + playerCamera.transform.RotateAround(target.transform.position, playerCamera.transform.right, targetYRotation); + playerCamera.transform.RotateAround(target.transform.position, Vector3.up, targetXRotation); + targetXRotation = playerCamera.transform.eulerAngles.y; + targetYRotation = playerCamera.transform.eulerAngles.x; + //playerCamera.transform.LookAt(new Vector3(target.transform.position.x,playerCamera.transform.position.y,target.transform.position.z)); // 使用 Quaternion 来平滑过渡到目标旋转角度 - playerCamera.transform.localRotation = Quaternion.Euler(targetYRotation, targetXRotation, 0f); - + //playerCamera.transform.localRotation = Quaternion.Euler(targetYRotation, targetXRotation, 0f); + + } + else + { + targetXRotation = 0; + targetYRotation = 0; } }