From 144727feb3662560a93997ab04cc448ed7a25fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Mon, 16 Dec 2024 11:58:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Res/HYLUI/TaskPanel.cs | 15 +++++++++++++ xiaofang/Assets/Script/npc/RecuseNpc.cs | 29 +++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs index 785f185e..6da73538 100644 --- a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs +++ b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs @@ -22,14 +22,29 @@ public class TaskPanel : Base public float hidePositionX = 125f; public float showPositionX = -198f; + public List taskIDs = new List(); + private List taskItems = new List(); // 当前显示的任务列表 void Start() { instance = this; hideBtn.onClick.AddListener(OnClickHideButton); + InitList(); + //InitTask(taskIDs); } + public void InitList() + { + foreach (Task_ task in JSONReader.TaskDictionary.Values) + { + if (int.TryParse(task.ID, out int taskId)) + { + // 转换成功,添加到 taskIDs 列表 + taskIDs.Add(taskId); + } + } + } // 将任务栏收起或显示 public void OnClickHideButton() { diff --git a/xiaofang/Assets/Script/npc/RecuseNpc.cs b/xiaofang/Assets/Script/npc/RecuseNpc.cs index c12ad6aa..3c895936 100644 --- a/xiaofang/Assets/Script/npc/RecuseNpc.cs +++ b/xiaofang/Assets/Script/npc/RecuseNpc.cs @@ -86,21 +86,22 @@ public class RecuseNpc : MonoBehaviour //娣诲姞npc鐨勭洰鐨勫湴鍒發ist涓 public void SetNpcDes(Vector3 tar) { - Debug.Log(tar); + Debug.Log(tar+"鐩爣璺緞鐐"); - target.position = tar; - Debug.Log(target); - NavMeshHit hit; - if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas)) - { - Debug.LogError($"鐩爣鐐 {target} 涓嶅湪瀵艰埅缃戞牸涓"); - } - else - { - tar = hit.position; // 灏嗙洰鏍囩偣璋冩暣鍒版渶杩戠殑瀵艰埅缃戞牸浣嶇疆 - } - Debug.Log("杩涘叆濂旇窇++++++="); - targetPoints.Add(tar); + //target.position = tar; + //Debug.Log(target); + //NavMeshHit hit; + //if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas)) + //{ + // Debug.LogError($"鐩爣鐐 {target} 涓嶅湪瀵艰埅缃戞牸涓"); + //} + //else + //{ + // tar = hit.position; // 灏嗙洰鏍囩偣璋冩暣鍒版渶杩戠殑瀵艰埅缃戞牸浣嶇疆 + //} + //Debug.Log("杩涘叆濂旇窇++++++="); + //targetPoints.Add(tar); + navMeshAgent.SetDestination(tar); } From a3e794dd8289e031a163456c1b4df49700b66c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Mon, 16 Dec 2024 12:01:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=B5=8B=E8=AF=951?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Script/npc/RecuseNpc.cs | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xiaofang/Assets/Script/npc/RecuseNpc.cs b/xiaofang/Assets/Script/npc/RecuseNpc.cs index 3c895936..03220152 100644 --- a/xiaofang/Assets/Script/npc/RecuseNpc.cs +++ b/xiaofang/Assets/Script/npc/RecuseNpc.cs @@ -88,20 +88,21 @@ public class RecuseNpc : MonoBehaviour { Debug.Log(tar+"鐩爣璺緞鐐"); - //target.position = tar; - //Debug.Log(target); - //NavMeshHit hit; - //if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas)) - //{ - // Debug.LogError($"鐩爣鐐 {target} 涓嶅湪瀵艰埅缃戞牸涓"); - //} - //else - //{ - // tar = hit.position; // 灏嗙洰鏍囩偣璋冩暣鍒版渶杩戠殑瀵艰埅缃戞牸浣嶇疆 - //} - //Debug.Log("杩涘叆濂旇窇++++++="); - //targetPoints.Add(tar); - navMeshAgent.SetDestination(tar); + target.position = tar; + Debug.Log(target); + NavMeshHit hit; + if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas)) + { + Debug.LogError($"鐩爣鐐 {target} 涓嶅湪瀵艰埅缃戞牸涓"); + } + else + { + tar = hit.position; // 灏嗙洰鏍囩偣璋冩暣鍒版渶杩戠殑瀵艰埅缃戞牸浣嶇疆 + } + Debug.Log("杩涘叆濂旇窇++++++="); + targetPoints.Clear(); + targetPoints.Add(tar); + } From 7632a3f057ddc0cc7359bfd88ff07485f3751925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Mon, 16 Dec 2024 14:14:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=B5=8B=E8=AF=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Script/npc/RecuseNpc.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xiaofang/Assets/Script/npc/RecuseNpc.cs b/xiaofang/Assets/Script/npc/RecuseNpc.cs index 03220152..1b102ce7 100644 --- a/xiaofang/Assets/Script/npc/RecuseNpc.cs +++ b/xiaofang/Assets/Script/npc/RecuseNpc.cs @@ -100,7 +100,7 @@ public class RecuseNpc : MonoBehaviour tar = hit.position; // 灏嗙洰鏍囩偣璋冩暣鍒版渶杩戠殑瀵艰埅缃戞牸浣嶇疆 } Debug.Log("杩涘叆濂旇窇++++++="); - targetPoints.Clear(); + //targetPoints.Clear(); targetPoints.Add(tar); @@ -128,7 +128,7 @@ public class RecuseNpc : MonoBehaviour if (targetPoints.Count > 0 && currentTarget != null) { - currentTarget = targetPoints[0]; + currentTarget = targetPoints[targetPoints.Count-1]; nstate = Npcstate.run; movebool = true;