_xiaofang/xiaofang/Assets/Script/UI/SceneItem.cs
2024-12-12 15:21:07 +08:00

63 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SceneItem : MonoBehaviour
{
public string sceneId;
public int sceneType;
public Text sceneName;
public Image sceneImage;
public Image maskImage;
public string roleLimit;//场景限制条件
public int limitNum;//限制人数
public string dutyId;
public JSONReader jsonReader;
public bool IsOpen { get; set; } = true;
// Start is called before the first frame update
void Start()
{
jsonReader = GameObject.Find("JsonObj").GetComponent<JSONReader>();
}
// Update is called once per frame
void Update()
{
}
//分隔数据
public void SetData()
{
foreach (var npc in jsonReader.locationDictionary)
{
Debug.Log("111111111111" + npc.Value.RoleLimit);
// 通过逗号分隔 RoleLimit 字段
string roleLimit = npc.Value.RoleLimit;
// 如果 RoleLimit 不是空字符串,按照逗号分隔
if (!string.IsNullOrEmpty(roleLimit))
{
string[] roleLimits = roleLimit.Split(',');
// 遍历分隔后的角色限制
foreach (string role in roleLimits)
{
Debug.Log("RoleLimit Item: " + role);
// 判断角色限制是否为 -1
if (role == "-1")
{
Debug.Log("角色限制为-1区域限制人数为无限");
}
}
}
else
{
Debug.Log("RoleLimit is empty for NPC ID: " + npc.Key);
}
}
}
}