2024.12.27ZS,CS
This commit is contained in:
parent
1279f80eef
commit
98865a9ca3
@ -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<string, List<string>> kvp in PlayerID)
|
||||
//{
|
||||
// Debug.Log($"职业: {kvp.Key}");
|
||||
|
||||
// // 遍历值(List<string>)
|
||||
// foreach (string task in kvp.Value)
|
||||
// {
|
||||
// Debug.Log($"任务: {task}");
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<string, List<string>> PlayerID = new Dictionary<string, List<string>>()
|
||||
{
|
||||
@ -72,20 +89,40 @@ public class Player : MonoBehaviour
|
||||
return new List<string>(input.Split('|'));
|
||||
}
|
||||
|
||||
public void Start()
|
||||
/// <summary>
|
||||
/// 判断数字是否存在于字符串中
|
||||
/// </summary>
|
||||
/// <param name="data">原始字符串</param>
|
||||
/// <param name="number">要检查的数字</param>
|
||||
/// <returns>是否存在</returns>
|
||||
public bool IsNumberInData(string data, int number)
|
||||
{
|
||||
SetPlayerID("11007");
|
||||
////遍历字典
|
||||
//foreach (KeyValuePair<string, List<string>> kvp in PlayerID)
|
||||
//{
|
||||
// Debug.Log($"职业: {kvp.Key}");
|
||||
// 按 # 分割 OR 条件组
|
||||
string[] orGroups = data.Split('#');
|
||||
|
||||
// // 遍历值(List<string>)
|
||||
// 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
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user