diff --git a/xiaofang/Assets/Script/UI/ZZZZZZ/Player.cs b/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs similarity index 64% rename from xiaofang/Assets/Script/UI/ZZZZZZ/Player.cs rename to xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs index fed15fc2..5acda0bf 100644 --- a/xiaofang/Assets/Script/UI/ZZZZZZ/Player.cs +++ b/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs @@ -2,11 +2,28 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class Player : MonoBehaviour +public class ZZZPlayer : MonoBehaviour { - public static Player CSZS; - public JSONReader jSONReader; + public static ZZZPlayer CSZS; + public JSONReader jSONReader; + + public void Start() + { + SetPlayerID("11007"); + ////遍历字典 + //foreach (KeyValuePair> kvp in PlayerID) + //{ + // Debug.Log($"职业: {kvp.Key}"); + + // // 遍历值(List) + // foreach (string task in kvp.Value) + // { + // Debug.Log($"任务: {task}"); + // } + //} + + } public Dictionary> PlayerID = new Dictionary>() { @@ -72,20 +89,40 @@ public class Player : MonoBehaviour return new List(input.Split('|')); } - public void Start() + /// + /// 判断数字是否存在于字符串中 + /// + /// 原始字符串 + /// 要检查的数字 + /// 是否存在 + public bool IsNumberInData(string data, int number) { - SetPlayerID("11007"); - ////遍历字典 - //foreach (KeyValuePair> kvp in PlayerID) - //{ - // Debug.Log($"职业: {kvp.Key}"); + // 按 # 分割 OR 条件组 + string[] orGroups = data.Split('#'); - // // 遍历值(List) - // foreach (string task in kvp.Value) - // { - // Debug.Log($"任务: {task}"); - // } - //} + // 遍历每个 OR 条件组 + foreach (string orGroup in orGroups) + { + // 按 | 分割 AND 条件 + string[] andConditions = orGroup.Split('|'); + // 遍历每个 AND 条件,检查是否包含数字 + foreach (string condition in andConditions) + { + // 按 , 分割单个条件 + string[] numbers = condition.Split(','); + + // 确保条件中有数字 + if (numbers.Length == 2 && int.TryParse(numbers[1], out int parsedNumber)) + { + if (parsedNumber == number) + { + return true; // 如果匹配,则立即返回 true + } + } + } + } + return false; // 如果所有条件都不匹配,返回 false } + } diff --git a/xiaofang/Assets/Script/UI/ZZZZZZ/Player.cs.meta b/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs.meta similarity index 100% rename from xiaofang/Assets/Script/UI/ZZZZZZ/Player.cs.meta rename to xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs.meta