_xiaofang/xiaofang/Assets/Script/UI/ZZZZZZ/ZZZPlayer.cs

129 lines
3.5 KiB
C#
Raw Normal View History

2024-12-27 12:01:08 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-12-27 21:10:27 +08:00
public class ZZZPlayer : MonoBehaviour
2024-12-27 12:01:08 +08:00
{
2024-12-27 21:10:27 +08:00
public static ZZZPlayer CSZS;
public JSONReader jSONReader;
public void Start()
{
SetPlayerID("11007");
////<2F><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>
//foreach (KeyValuePair<string, List<string>> kvp in PlayerID)
//{
// Debug.Log($"ְҵ: {kvp.Key}");
// // <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>List<string><3E><>
// foreach (string task in kvp.Value)
// {
// Debug.Log($"<22><><EFBFBD><EFBFBD>: {task}");
// }
//}
}
2024-12-27 12:01:08 +08:00
public Dictionary<string, List<string>> PlayerID = new Dictionary<string, List<string>>()
{
2024-12-27 17:45:19 +08:00
{ "8000", new List<string>() },
{ "8001", new List<string>() },
{ "8002", new List<string>() },
{ "8003", new List<string>() },
{ "8004", new List<string>() },
{ "8005", new List<string>() },
{ "8006", new List<string>() },
{ "8007", new List<string>() },
{ "8008", new List<string>() },
{ "8009", new List<string>() },
{ "8010", new List<string>() },
{ "8011", new List<string>() }
2024-12-27 12:01:08 +08:00
};
private void Awake()
{
CSZS = this;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
2024-12-27 17:45:19 +08:00
public void SetPlayerID(string TaskID)
2024-12-27 12:01:08 +08:00
{
2024-12-27 17:45:19 +08:00
var a=ParseString(jSONReader.GetOcpID(int.Parse(TaskID)));
for (int i=0;i<a.Count;i++)
2024-12-27 12:01:08 +08:00
{
2024-12-27 17:45:19 +08:00
PlayerID[a[i]].Add(TaskID);
2024-12-27 12:01:08 +08:00
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ְҵ<D6B0><D2B5>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public List<string> GetPlayerID(string ID)
{
if (PlayerID.TryGetValue(ID, out List<string> value))
{
return value; // <20><><EFBFBD>ض<EFBFBD>Ӧ<EFBFBD><D3A6> List<string>
}
else
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>");
return new List<string>(); // <20><><EFBFBD>ؿ<EFBFBD><D8BF>б<EFBFBD>
}
}
2024-12-27 17:45:19 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "|" <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> List
/// </summary>
/// <param name="input"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD></param>
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> List<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>򷵻ؿ<F2B7B5BB><D8BF>б<EFBFBD></returns>
public static List<string> ParseString(string input)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ջ<EFBFBD> null<6C><6C><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF>б<EFBFBD>
if (string.IsNullOrEmpty(input))
{
return new List<string>();
}
// <20><> "|" <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>б<EFBFBD>
return new List<string>(input.Split('|'));
}
2024-12-27 21:10:27 +08:00
/// <summary>
/// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="data">ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD></param>
/// <param name="number">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <returns><3E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD></returns>
public bool IsNumberInData(string data, int number)
2024-12-27 17:45:19 +08:00
{
2024-12-27 21:10:27 +08:00
// <20><> # <20>ָ<EFBFBD> OR <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string[] orGroups = data.Split('#');
2024-12-27 17:45:19 +08:00
2024-12-27 21:10:27 +08:00
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF> OR <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
foreach (string orGroup in orGroups)
{
// <20><> | <20>ָ<EFBFBD> AND <20><><EFBFBD><EFBFBD>
string[] andConditions = orGroup.Split('|');
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF> AND <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
foreach (string condition in andConditions)
{
// <20><> , <20>ָ<D6B8><EEB5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string[] numbers = condition.Split(',');
2024-12-27 17:45:19 +08:00
2024-12-27 21:10:27 +08:00
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (numbers.Length == 2 && int.TryParse(numbers[1], out int parsedNumber))
{
if (parsedNumber == number)
{
return true; // <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> true
}
}
}
}
return false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD> false
2024-12-27 17:45:19 +08:00
}
2024-12-27 21:10:27 +08:00
2024-12-27 12:01:08 +08:00
}