using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public static Player CSZS; public JSONReader jSONReader; public Dictionary> PlayerID = new Dictionary>() { { "8000", new List() }, { "8001", new List() }, { "8002", new List() }, { "8003", new List() }, { "8004", new List() }, { "8005", new List() }, { "8006", new List() }, { "8007", new List() }, { "8008", new List() }, { "8009", new List() }, { "8010", new List() }, { "8011", new List() } }; private void Awake() { CSZS = this; } /// /// 接收玩家接受的任务 /// public void SetPlayerID(string TaskID) { var a=ParseString(jSONReader.GetOcpID(int.Parse(TaskID))); for (int i=0;i /// 返回一个职业接取的任务 /// public List GetPlayerID(string ID) { if (PlayerID.TryGetValue(ID, out List value)) { return value; // 返回对应的 List } else { Debug.Log("颠仔找不到"); return new List(); // 返回空列表 } } /// /// 解析以 "|" 分隔的字符串并返回一个 List /// /// 输入的字符串 /// 解析后的 List,如果输入为空则返回空列表 public static List ParseString(string input) { // 如果输入为空或 null,返回空列表 if (string.IsNullOrEmpty(input)) { return new List(); } // 按 "|" 分割字符串,并返回结果列表 return new List(input.Split('|')); } public void Start() { SetPlayerID("11007"); ////遍历字典 //foreach (KeyValuePair> kvp in PlayerID) //{ // Debug.Log($"职业: {kvp.Key}"); // // 遍历值(List) // foreach (string task in kvp.Value) // { // Debug.Log($"任务: {task}"); // } //} } }