_xiaofang/xiaofang/Assets/Script/UI/PanelUI/DistributionPanel.cs

98 lines
3.0 KiB
C#

using Newtonsoft.Json.Schema;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Search.Providers;
using UnityEngine;
using UnityEngine.UI;
public class DistributionPanel : MonoBehaviour
{
public GameObject personnelLable;
public Transform personnelContent;
public Panel panel;
public SelectScenePanel selectScenePanel;
public JSONReader jsonReader;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnClickPeopleWindows()
{
foreach(Transform child in personnelContent)
{
Destroy(child.gameObject);
}
}
public void CreateAllLable()
{
foreach (Transform child in personnelContent)
{
Destroy(child.gameObject);
}
//CreateFirstLable();
foreach (var sceneEntry in panel.sceneDataDictionary)
{
Debug.Log("sceneEntry" +sceneEntry.Key);
GameObject managerPanelInstance = Instantiate(personnelLable, personnelContent);
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
scenetext.personelPanelText.text = sceneEntry.Key;
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
scenetext.CreatePeopleItem(sceneEntry.Value);
foreach(var scene in sceneEntry.Value)
{
IsMeet(scene.sceneId);
}
}
}
public void CreateFirstLable()
{
GameObject fistLable = Instantiate<GameObject>(personnelLable, personnelContent);
PersonnelInfo personnelItem = fistLable.GetComponent<PersonnelInfo>();
}
//判断人员是否满足
public void IsMeet(string sceneID)
{
List<SelectedInfo> info = null;
panel.sceneDataDictionary.TryGetValue(sceneID, out info);
// 尝试从字典中获取sceneID对应的列表
if (panel.sceneDataDictionary.TryGetValue(sceneID, out info))
{Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
string roleLimit = jsonReader.GetAreaDateById(int.Parse(sceneID)).RoleLimit;
string[] sceneLimit = roleLimit.Split('|');
foreach (string limitStr in sceneLimit)
{
string[] limit = limitStr.Split(",");
if (limit.Length == 4)
{
if (limit[0] == selectScenePanel.idcidentId.ToString() &&limit[1] == selectScenePanel.difficultyId.ToString())
{
foreach (var selectedInfo in info)
{
if (limit[2] == selectedInfo.dutyId.ToString())
{
return;
}
}
}
}
}
}
else
{
Console.WriteLine("没有找到对应的场景数据!");
}
}
}