diff --git a/xiaofang/Assets/ProtoBuf/test.cs b/xiaofang/Assets/ProtoBuf/test.cs index 4fa2e9a5..cce3ec84 100644 --- a/xiaofang/Assets/ProtoBuf/test.cs +++ b/xiaofang/Assets/ProtoBuf/test.cs @@ -759,6 +759,7 @@ public class test : MonoBehaviour MoveRequest taskUpdateRequest = ProtoBufffer.DeSerialize(bytes); Debug.Log(taskUpdateRequest); + break; //对象触发操作 diff --git a/xiaofang/Assets/Scenes/HylScene/Test.unity b/xiaofang/Assets/Scenes/HylScene/Test.unity index 78f4fa64..0d82c8b7 100644 --- a/xiaofang/Assets/Scenes/HylScene/Test.unity +++ b/xiaofang/Assets/Scenes/HylScene/Test.unity @@ -217,7 +217,7 @@ RectTransform: m_Children: - {fileID: 2059853628} m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -999,10 +999,11 @@ MonoBehaviour: m_GameObject: {fileID: 1416567123} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 9b2ff411b5e682c439d271893fe57cf2, type: 3} + m_Script: {fileID: 11500000, guid: c4ed3303e02a8594c8bac0747d38a1b9, type: 3} m_Name: m_EditorClassIdentifier: jSONReader: {fileID: 2009348684} + isYou: 1 --- !u!1 &1509783291 GameObject: m_ObjectHideFlags: 0 @@ -1177,6 +1178,203 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1617184227} m_CullTransparentMesh: 1 +--- !u!1001 &1750337032 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 919949400, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_Pivot.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1986279549173157415, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_Name + value: Command_End + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3} --- !u!1 &1946593407 GameObject: m_ObjectHideFlags: 0 @@ -1379,7 +1577,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &3077635299975306478 PrefabInstance: @@ -1412,6 +1610,14 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 1407198451437384586, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1407198451437384586, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 1407198451904434455, guid: 940be89243a038b4090a77556e45a06d, type: 3} propertyPath: m_SizeDelta.x value: 0 @@ -1452,6 +1658,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3032695104264456879, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3032695104264456879, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3032695104320383594, guid: 940be89243a038b4090a77556e45a06d, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -1484,6 +1698,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3032695105467395617, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3032695105467395617, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3077635299444999927, guid: 940be89243a038b4090a77556e45a06d, type: 3} propertyPath: m_Pivot.x value: 0 @@ -1572,6 +1794,10 @@ PrefabInstance: propertyPath: m_Name value: FreePanel_End objectReference: {fileID: 0} + - target: {fileID: 3077635299444999931, guid: 940be89243a038b4090a77556e45a06d, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 4030979446590429124, guid: 940be89243a038b4090a77556e45a06d, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/xiaofang/Assets/Script/JSONReader/JSONReader.cs b/xiaofang/Assets/Script/JSONReader/JSONReader.cs index d89194d9..0b70af7e 100644 --- a/xiaofang/Assets/Script/JSONReader/JSONReader.cs +++ b/xiaofang/Assets/Script/JSONReader/JSONReader.cs @@ -38,6 +38,7 @@ public class JSONReader : MonoBehaviour public Dictionary OpcNameDictionary=new Dictionary(); public Dictionary> ZZFindTaskID = new Dictionary>(); + void Awake() { // 解析 NPC 和 Location 数据 @@ -236,7 +237,6 @@ public class JSONReader : MonoBehaviour { OpcNameDictionary[npc.ID]= npc; } - return OpcNameDictionary; } //找到玩家接取的任务ID对应的 diff --git a/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs b/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs index 5acda0bf..7cf02757 100644 --- a/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs +++ b/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; public class ZZZPlayer : MonoBehaviour @@ -7,10 +8,13 @@ public class ZZZPlayer : MonoBehaviour public static ZZZPlayer CSZS; public JSONReader jSONReader; + public Dictionary CSB1 = new Dictionary(); //Key是判断是不是一组,string是ID tanchuang1用的 + public bool isYou=true; public void Start() { - SetPlayerID("11007"); + // SetPlayerID("11007"); + FindPlayerTaskID(10810, "tanchuang1"); ////遍历字典 //foreach (KeyValuePair> kvp in PlayerID) //{ @@ -73,7 +77,7 @@ public class ZZZPlayer : MonoBehaviour } } /// - /// 解析以 "|" 分隔的字符串并返回一个 List + /// 判断那些角色可以接取任务 /// /// 输入的字符串 /// 解析后的 List,如果输入为空则返回空列表 @@ -90,13 +94,69 @@ public class ZZZPlayer : MonoBehaviour } /// - /// 判断数字是否存在于字符串中 + /// 判断玩家是否接取这个任务或者(返回是bool) /// - /// 原始字符串 - /// 要检查的数字 + /// 要检查的数字 + /// 弹窗名 /// 是否存在 + public void FindPlayerTaskID(int number,string Type) + { + foreach (var item in jSONReader.ZZSelectsDictionary) + { + Select data = item.Value; + if (data.AppliedUI == "tanchuang1") + { + var a = GetNumberBeforeComma(data.Group); + Debug.Log("bbbb"); + //先用Grop分组 + if (!CSB1.ContainsKey(a)) + { + CSB1.Add(a, data.ID);// 更新值 + } + } + } + TwoFind(number); + } + public void TwoFind(int number) + { + //再一次来判断 + if (isYou) + { + Debug.Log("进来了脸脸了了了了了了脸脸了脸脸了了了脸脸了了"); + Debug.Log(CSB1.Count); + foreach (KeyValuePair kvp in CSB1) + { + Debug.Log("进不来了"); + int key = kvp.Key; + string value = kvp.Value; + + // 将字符串拆分为 List + List values = new List(value.Split(',')); + + // 对值列表进行对比 + for (int i = 0; i < values.Count; i++) + { + Debug.Log("进不来了11111"); + for (int j = i + 1; j < values.Count; j++) + { + Debug.Log("进不来了22222"); + isYou = IsNumberInData(values[j], number); + if (isYou) + { + break; + } + } + if (isYou) + { + break; + } + } + } + } + } public bool IsNumberInData(string data, int number) { + // 按 # 分割 OR 条件组 string[] orGroups = data.Split('#'); @@ -124,5 +184,36 @@ public class ZZZPlayer : MonoBehaviour } return false; // 如果所有条件都不匹配,返回 false } + /// + /// 解析并提取逗号(,)前的数字(判断分组) + /// + /// 输入字符串 + /// 返回一个包含数字的列表 + /// + /// 获取逗号(,或,)前的数字 + /// + /// 输入的字符串(例如 "123,15") + /// 逗号前的数字,如果解析失败返回 -1 + public int GetNumberBeforeComma(string data) + { + Debug.Log("aaaa"); + if (string.IsNullOrEmpty(data)) + { + Debug.LogWarning("输入为空或 null!"); + return -1; + } + + // 按逗号分割(支持中文 "," 和英文 ",") + string[] parts = data.Split(new char[] { ',', ',' }); + + // 检查分割结果并尝试解析 + if (parts.Length > 0 && int.TryParse(parts[0], out int number)) + { + return number; // 返回解析成功的数字 + } + + Debug.LogWarning($"无法解析逗号前的数字:{data}"); + return -1; // 解析失败返回 -1 + } }