_xiaofang/xiaofang/Assets/Script/Scheduled_03/Panel.cs

490 lines
19 KiB
C#
Raw Normal View History

using Newtonsoft.Json;
2024-12-02 10:50:31 +08:00
using System;
2024-11-25 16:33:54 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
2024-11-27 02:11:27 +08:00
using System.Runtime.InteropServices;
2024-11-27 23:59:00 +08:00
using Unity.VisualScripting;
2024-11-25 16:33:54 +08:00
using UnityEngine;
2024-12-02 10:50:31 +08:00
using UnityEngine.Events;
2024-11-25 17:16:41 +08:00
using UnityEngine.EventSystems;
2024-11-25 16:33:54 +08:00
using UnityEngine.SceneManagement;
using UnityEngine.UI;
2024-11-27 02:11:27 +08:00
public class SelectedInfo
{
2024-12-04 16:37:51 +08:00
public string name;//<2F><>ɫ<EFBFBD><C9AB>
public string duty;//ְ<><D6B0>
public string scene;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string leader;//<2F>Ƿ<EFBFBD><C7B7>
public int dutyId;//ְ<><D6B0><EFBFBD><EFBFBD>Id
2024-11-27 02:11:27 +08:00
}
2024-11-25 17:16:41 +08:00
2024-11-25 16:33:54 +08:00
public class Panel : MonoBehaviour
{
2024-11-27 02:11:27 +08:00
[Header("<22><><EFBFBD><EFBFBD>")]
2024-11-25 16:33:54 +08:00
public Button choseJuBenSettingBtn;
public Button emergencySettingBtn;
public Button peoplePublishBtn;
public Button materialReserveBtn;
public Button dateSelectionBtn;
2024-11-26 15:36:02 +08:00
public Button personnelmanagementBtn;
2024-11-25 17:16:41 +08:00
public Button setName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
public Button setDuty;//<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
public Button setScene;//<2F><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>
2024-11-26 15:36:02 +08:00
public Text arrangeText;//<2F><><EFBFBD><EFBFBD><E5B0B2>
2024-11-25 16:33:54 +08:00
public Button sureBtn;//ȷ<><C8B7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ť
2024-11-27 02:11:27 +08:00
public ToggleGroup scenetoggleGroup;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToggleGroup
public InputField shaixuaninputField;//ɸѡ<C9B8><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-25 17:16:41 +08:00
public GraphicRaycaster raycaster; // <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD>
public EventSystem eventSystem; // <20>¼<EFBFBD>ϵͳ
2024-11-27 02:11:27 +08:00
[Header("<22><><EFBFBD><EFBFBD>")]
public GameObject ManagerPanel;//<2F><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Transform peopleCountent;//<2F><>Ա<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
public GameObject peoplePrefab;//<2F><>Ա<EFBFBD><D4B1>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
2024-11-27 23:59:00 +08:00
public Transform panelContent;
2024-11-30 23:32:17 +08:00
public GameObject dutyPrefab;//ְ<><D6B0>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
public Transform dutyCount;//ְ<><D6B0><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
public GameObject scenePrefab;
public Transform sceneCount;
2024-11-27 23:59:00 +08:00
public GameObject ManagerPanelPrefab; // Ԥ<><D4A4><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-27 02:11:27 +08:00
[Header("<22><><EFBFBD><EFBFBD>")]
public string name, duty, scene;
2024-12-04 16:37:51 +08:00
public int dutyId;
2024-12-02 00:35:53 +08:00
public List<GameObject> peopleList = new List<GameObject>(); // <20><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC>ص<EFBFBD><D8B5><EFBFBD>ԱԤ<D4B1><D4A4><EFBFBD><EFBFBD>
2024-11-27 02:11:27 +08:00
private List<GameObject> filteredPeopleList = new List<GameObject>(); // <20>洢ɸѡ<C9B8><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>б<EFBFBD>
private GameObject selectedPerson = null; // <20><>ǰѡ<C7B0>еĽ<D0B5>ɫ
2024-12-02 19:40:49 +08:00
private GameObject selectedDuty = null;//<2F><>ǰѡ<C7B0><D1A1>ְ<EFBFBD><D6B0>
private GameObject selectedScene = null;//<2F><>ǰѡ<C7B0>г<EFBFBD><D0B3><EFBFBD>
2024-11-27 02:11:27 +08:00
public SelectedInfo selectedInfo;
2024-11-27 16:54:09 +08:00
public Dictionary<string, List<SelectedInfo>> sceneDataDictionary = new Dictionary<string, List<SelectedInfo>>();//<2F><>ͬ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
public ManagerPanel managerPanel1;
2024-11-30 23:32:17 +08:00
public JSONReader jsonReader1;
2024-12-01 22:36:41 +08:00
public SelectScenePanel selectScenePanel;
2024-12-02 00:35:53 +08:00
public DatePanel datePanel;
private bool isPersonSelected = false; // <20><>־<EFBFBD>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
private bool isDutySelected = false; // <20><>־<EFBFBD>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
private bool isSceneSelected = false; // <20><>־<EFBFBD>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>
2024-11-27 02:11:27 +08:00
2024-11-25 16:33:54 +08:00
// Start is called before the first frame update
void Start()
2024-12-04 16:37:51 +08:00
{
selectedInfo = new SelectedInfo();
DynamicLoadingPeople();
DynamicLoadingDuty();
DynamicLoadingScene();
}
2024-11-25 16:33:54 +08:00
// Update is called once per frame
void Update()
2024-12-04 16:37:51 +08:00
{
GetData();
SetText();
//SetInputFile();
}
2024-12-02 19:40:49 +08:00
//==================================================================<3D><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>=======================================================
2024-12-04 16:37:51 +08:00
//<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
2024-11-27 02:11:27 +08:00
public void DynamicLoadingPeople()
{
2024-12-04 16:37:51 +08:00
for (int i = 0; i < 20; i++)
{
GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent);
PeopleItem peopleItem = item.GetComponent<PeopleItem>();
Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>();
peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson));
peopleList.Add(item);// <20><>ÿ<EFBFBD><C3BF>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
2024-11-30 23:32:17 +08:00
2024-12-04 16:37:51 +08:00
}
2024-11-27 02:11:27 +08:00
}
2024-11-27 23:59:00 +08:00
//<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
public void DynamicLoadingDuty()
{
2024-11-30 23:32:17 +08:00
foreach (var npcData in jsonReader1.npcDictionary)
{
2024-12-01 22:36:41 +08:00
string[] nameSections = npcData.Value.Name.Split('|');
foreach (var section in nameSections)
{
string[] sectionParts = section.Split(',');
2024-12-04 16:37:51 +08:00
//<2F>ж<EFBFBD><D0B6>¼<EFBFBD>Ȼ<EFBFBD><C8BB>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щְ<D0A9><D6B0>
if (int.Parse(sectionParts[0]) == 2001)
2024-12-01 22:36:41 +08:00
{
int key = int.Parse(sectionParts[1]);
if (jsonReader1.npcDictionary.ContainsKey(key))
{
var npcInfo = jsonReader1.npcDictionary[key];
// <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>npcInfo<66><6F><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
Debug.Log("Found NPC: " + npcInfo.Name);
// <20><><EFBFBD><EFBFBD>DutyItemʵ<6D><CAB5>
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>();
2024-12-02 19:40:49 +08:00
Button dutuybutton = item.transform.Find("TextBtn").GetComponent<Button>();
2024-12-04 22:58:31 +08:00
dutuybutton.onClick.AddListener(() => OnDutyItemClicked(item, Color.red, selectedDuty));
2024-12-01 22:36:41 +08:00
dutyItem.dutyNameText.text = npcData.Value.Note;
dutyItem.leader = npcData.Value.GroupLeader;
2024-12-04 16:37:51 +08:00
dutyItem.dutyId = npcData.Value.ID;
2024-12-01 22:36:41 +08:00
peopleList.Add(item);
}
}
}
2024-12-04 16:37:51 +08:00
2024-11-30 23:32:17 +08:00
}
2024-11-27 23:59:00 +08:00
}
2024-11-27 23:59:00 +08:00
//<2F><>̬<EFBFBD><CCAC><EFBFBD>س<EFBFBD><D8B3><EFBFBD>
public void DynamicLoadingScene()
2024-11-30 23:32:17 +08:00
{
2024-12-04 16:37:51 +08:00
foreach (var npcData in jsonReader1.locationDictionary)
{
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
string roleLimit = npcData.Value.RoleLimit;
if (!string.IsNullOrEmpty(roleLimit))
{
2024-12-04 16:37:51 +08:00
// <20>Ȱ<EFBFBD><C8B0><EFBFBD>|<7C><><EFBFBD>ָ<EFBFBD>
string[] roleLimitSections = roleLimit.Split('|');
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD>|<7C><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool shouldInstantiate = true; // <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫʵ<D2AA><CAB5><EFBFBD><EFBFBD>
foreach (string section in roleLimitSections)
{
2024-12-04 16:37:51 +08:00
string[] roleLimits = section.Split(',');
// <20>жϵ<D0B6>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> "-1" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
if (section.Contains("-1"))
{
2024-12-04 16:37:51 +08:00
if (roleLimits[0] == "-1")
{
shouldInstantiate = false; // <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NPC
break; // <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>NPC
}
}
else
{
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>();
Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
2024-12-04 22:58:31 +08:00
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD>limitNum
sceneItem.dutyId = int.Parse(roleLimits[1]);
sceneItem.limitNum = int.Parse(roleLimits[2]);
sceneItem.sceneName.text = npcData.Value.Note;
// <20><>ÿ<EFBFBD><C3BF>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
peopleList.Add(item);
}
2024-12-02 00:35:53 +08:00
}
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰNPC<50><43>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
if (!shouldInstantiate)
2024-12-02 00:35:53 +08:00
{
2024-12-04 16:37:51 +08:00
continue;
}
2024-12-01 15:06:22 +08:00
}
}
2024-11-30 23:32:17 +08:00
}
2024-12-01 17:51:09 +08:00
//=============================================================<3D><>ť<EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>¼<EFBFBD>==================================================
2024-12-04 16:37:51 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
2024-11-26 15:36:02 +08:00
public void ClickPersonnelManagement()
2024-12-04 16:37:51 +08:00
{
foreach (Transform child in panelContent)
{
Destroy(child.gameObject);
}
2024-12-04 16:37:51 +08:00
foreach (var sceneEntry in sceneDataDictionary)
{
//Debug.Log($"<22><><EFBFBD><EFBFBD>: {sceneEntry.Key}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {sceneEntry.Value.Count}");
GameObject managerPanelInstance = Instantiate(ManagerPanelPrefab, panelContent);
Button button = managerPanelInstance.GetComponent<Button>();
button.onClick.AddListener(() => managerPanel1.OnItemClicked(managerPanelInstance));
Text sceneText = managerPanelInstance.transform.Find("top/sceneName").GetComponent<Text>();
sceneText.text = sceneEntry.Key;
managerPanel1.CreateScenePanel(sceneEntry.Key, sceneEntry.Value, managerPanelInstance);
//managerPanel1.SetPlate();
ManagerPanel.gameObject.SetActive(true);
}
2024-11-27 23:59:00 +08:00
}
2024-11-25 16:33:54 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD>ť
public void ClickSureBtn()
2024-11-27 02:11:27 +08:00
{
2024-12-04 16:37:51 +08:00
// ֻ<><D6BB><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ְ<EFBFBD><D6B0><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3>Ż<EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (isPersonSelected && isDutySelected && isSceneSelected)
{
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>
string sceneName = selectedInfo.scene;
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
if (!sceneDataDictionary.ContainsKey(sceneName))
{
sceneDataDictionary[sceneName] = new List<SelectedInfo>();
}
2024-12-04 16:37:51 +08:00
// <20><>Ҫ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFB5BD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
bool isLimitReached = false;
2024-12-04 16:37:51 +08:00
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
List<SelectedInfo> currentSceneInfo = sceneDataDictionary[sceneName];
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1
if (selectedInfo.duty == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" || selectedInfo.duty == "<22>鳤" || selectedInfo.duty == "<22><>ָ<EFBFBD><D6B8>")
{
2024-12-04 16:37:51 +08:00
int count = currentSceneInfo.Count(info => info.duty == selectedInfo.duty); // ͳ<>Ƶ<EFBFBD>ǰְ<C7B0><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (count >= 1) // <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ
{
Debug.LogError($"{selectedInfo.duty} <20>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
isLimitReached = true; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>
}
}
// <20><><EFBFBD><EFBFBD>û<EFBFBD>дﵽ<D0B4><EFB5BD><EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>Ϣ
if (!isLimitReached)
{
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD> SelectedInfo ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SelectedInfo newSelectedInfo = new SelectedInfo
{
name = selectedInfo.name,
duty = selectedInfo.duty,
2024-12-04 22:58:31 +08:00
scene = selectedInfo.scene,
dutyId= selectedInfo.dutyId
2024-12-04 16:37:51 +08:00
};
// <20><><EFBFBD><EFBFBD>ǰѡ<C7B0>е<EFBFBD><D0B5><EFBFBD>Ա<EFBFBD><D4B1>Ϣ<EFBFBD><CFA2><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>б<EFBFBD><D0B1><EFBFBD>
currentSceneInfo.Add(newSelectedInfo);
// <20><><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>־
sureBtn.interactable = false;
isPersonSelected = false;
isDutySelected = false;
isSceneSelected = false;
// <20>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ɫ
UpdatePeopleListVisual();
}
}
2024-12-04 16:37:51 +08:00
else
{
2024-12-04 16:37:51 +08:00
Debug.LogError("<22><>ȷ<EFBFBD><C8B7>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ְ<EFBFBD><D6B0><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD>");
}
2024-12-04 16:37:51 +08:00
datePanel.NumberText.text = "<22><>" + (sceneDataDictionary.Keys.Count * sceneDataDictionary.Values.Count).ToString() + "<22>˲<EFBFBD><CBB2><EFBFBD>";
}
2024-11-27 02:11:27 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رհ<D8B1>ť
2024-11-26 18:24:12 +08:00
public void ClickCloseBtn()
2024-12-04 16:37:51 +08:00
{
transform.gameObject.SetActive(false);
}
2024-11-25 16:33:54 +08:00
2024-11-25 17:58:45 +08:00
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ
public void GetData()
2024-11-25 17:16:41 +08:00
{
2024-12-04 16:37:51 +08:00
ManagerPanel managerPanel = new ManagerPanel();
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
if (Input.GetMouseButtonDown(0))
{
// ȷ<><C8B7> raycaster <20><> eventSystem <20><>Ϊ<EFBFBD><CEAA>
if (raycaster == null || eventSystem == null)
{
Debug.LogError("Raycaster <20><> EventSystem δ<><CEB4>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD> Inspector <20>н<EFBFBD><D0BD>з<EFBFBD><D0B7>䡣");
return;
}
2024-11-25 17:16:41 +08:00
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD> PointerEventData <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PointerEventData pointerData = new PointerEventData(eventSystem);
pointerData.position = Input.mousePosition; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
List<RaycastResult> results = new List<RaycastResult>();
2024-11-25 17:16:41 +08:00
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD>߼<EFBFBD><DFBC><EFBFBD> UI
raycaster.Raycast(pointerData, results);
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
foreach (RaycastResult result in results)
2024-11-25 17:16:41 +08:00
{
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD>ť
Button clickedButton = result.gameObject.GetComponent<Button>();
2024-12-04 22:58:31 +08:00
2024-12-04 16:37:51 +08:00
if (clickedButton != null)
{
2024-12-04 16:37:51 +08:00
Text buttonText = clickedButton.GetComponentInChildren<Text>();
if (buttonText != null && buttonText.tag == Tags.people) // <20><>ȡ<EFBFBD><C8A1>ǩΪ<C7A9><CEAA>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>Ϣ
{
name = buttonText.text;
Debug.Log(name);
selectedInfo.name = name;
isPersonSelected = true; // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
}
else if (buttonText != null && buttonText.tag == Tags.scene) // <20><>ȡ<EFBFBD><C8A1>ǩΪ<C7A9><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{
scene = buttonText.text;
Debug.Log(scene);
selectedInfo.scene = scene;
isSceneSelected = true; // ѡ<><D1A1><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>
}
else if (buttonText != null && buttonText.tag == Tags.duty) // <20><>ȡ<EFBFBD><C8A1>ǩΪְ<CEAA><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{
2024-12-04 22:58:31 +08:00
DutyItem item = clickedButton.GetComponentInParent<DutyItem>();
duty = buttonText.text;
2024-12-04 16:37:51 +08:00
dutyId = item.dutyId;
selectedInfo.duty = duty;
isDutySelected = true; // ѡ<><D1A1><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
}
2024-11-25 17:16:41 +08:00
}
}
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD>ť
UpdateConfirmButtonState();
}
2024-11-25 17:16:41 +08:00
}
2024-12-01 17:51:09 +08:00
//==========================================================<3D><><EFBFBD><EFBFBD>===========================================
2024-12-04 16:37:51 +08:00
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
private void UpdateConfirmButtonState()
2024-12-04 16:37:51 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ְ<EFBFBD><D6B0><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sureBtn.interactable = isPersonSelected && isDutySelected && isSceneSelected;
}
2024-11-26 15:36:02 +08:00
//<2F><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SetText()
2024-12-04 16:37:51 +08:00
{
arrangeText.text = "[" + name + "]<5D><><EFBFBD><EFBFBD>[" + duty + "],λ<><CEBB>[" + scene + "]";
}
2024-11-27 02:11:27 +08:00
//ɸѡ
public void SetInputFile()
{
2024-12-04 16:37:51 +08:00
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string filterText = shaixuaninputField.text.Trim();
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱԤ<D4B1><D4A4><EFBFBD><EFBFBD>
foreach (Transform child in peopleCountent)
2024-11-27 02:11:27 +08:00
{
2024-12-04 16:37:51 +08:00
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD> Text <20><><EFBFBD><EFBFBD>
Text personNameText = child.GetComponentInChildren<Text>();
if (personNameText != null)
2024-11-27 02:11:27 +08:00
{
2024-12-04 16:37:51 +08:00
// <20>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
if (personNameText.text.Contains(filterText))
{
// <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ա
child.gameObject.SetActive(true);
}
else
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>Ա
child.gameObject.SetActive(false);
}
2024-11-27 02:11:27 +08:00
}
}
}
2024-12-04 22:58:31 +08:00
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD><C4B1>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
2024-12-04 16:37:51 +08:00
public void OnPeopleItemClicked(GameObject clickedItem, Color color, GameObject select)
2024-11-27 02:11:27 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰѡ<C7B0>еĽ<D0B5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
2024-12-04 22:58:31 +08:00
if (selectedPerson != null && select != clickedItem)
{
Text prevText = selectedPerson.GetComponentInChildren<Text>();
if (prevText != null)
{
prevText.fontSize = 32; // <20>ָ<EFBFBD>ԭʼ<D4AD>ֺ<EFBFBD>
prevText.color = Color.white; // <20>ָ<EFBFBD>ԭʼ<D4AD><CABC>ɫ
}
}
// <20><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0>еĽ<D0B5>ɫΪѡ<CEAA><D1A1>״̬
selectedPerson = clickedItem; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Text personText = clickedItem.GetComponentInChildren<Text>();
if (personText != null)
{
// <20>ֺű<D6BA><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>״̬<D7B4><CCAC>
personText.fontSize = 36;
personText.color = color; // ѡ<><D1A1><EFBFBD><EFBFBD>ɫ
}
}
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ְ<EFBFBD>𣬸ı<F0A3ACB8><C4B1>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
public void OnDutyItemClicked(GameObject clickedItem, Color color, GameObject select)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰѡ<C7B0>еĽ<D0B5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
if (selectedDuty != null && select != clickedItem)
{
Text prevText = selectedDuty.GetComponentInChildren<Text>();
if (prevText != null)
{
prevText.fontSize = 32; // <20>ָ<EFBFBD>ԭʼ<D4AD>ֺ<EFBFBD>
prevText.color = Color.white; // <20>ָ<EFBFBD>ԭʼ<D4AD><CABC>ɫ
}
}
// <20><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0>еĽ<D0B5>ɫΪѡ<CEAA><D1A1>״̬
selectedDuty = clickedItem; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Text personText = clickedItem.GetComponentInChildren<Text>();
if (personText != null)
{
// <20>ֺű<D6BA><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>״̬<D7B4><CCAC>
personText.fontSize = 36;
personText.color = color; // ѡ<><D1A1><EFBFBD><EFBFBD>ɫ
}
}
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD><C4B1>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
public void OnSceneItemClicked(GameObject clickedItem, Color color, GameObject select)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰѡ<C7B0>еĽ<D0B5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD>Ч<EFBFBD><D0A7>
if (selectedScene != null && select != clickedItem)
2024-11-27 02:11:27 +08:00
{
2024-12-04 22:58:31 +08:00
Text prevText = selectedScene.GetComponentInChildren<Text>();
2024-11-27 02:11:27 +08:00
if (prevText != null)
{
prevText.fontSize = 32; // <20>ָ<EFBFBD>ԭʼ<D4AD>ֺ<EFBFBD>
prevText.color = Color.white; // <20>ָ<EFBFBD>ԭʼ<D4AD><CABC>ɫ
}
}
// <20><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0>еĽ<D0B5>ɫΪѡ<CEAA><D1A1>״̬
2024-12-04 22:58:31 +08:00
selectedScene = clickedItem; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-27 02:11:27 +08:00
Text personText = clickedItem.GetComponentInChildren<Text>();
if (personText != null)
{
// <20>ֺű<D6BA><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>״̬<D7B4><CCAC>
personText.fontSize = 36;
2024-12-02 19:40:49 +08:00
personText.color = color; // ѡ<><D1A1><EFBFBD><EFBFBD>ɫ
2024-11-27 02:11:27 +08:00
}
}
2024-11-30 16:19:19 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ɫ
private void UpdatePeopleListVisual()
{
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC>ص<EFBFBD><D8B5><EFBFBD>ԱԤ<D4B1><D4A4><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
foreach (GameObject personItem in peopleList)
2024-11-30 16:19:19 +08:00
{
2024-12-04 16:37:51 +08:00
// <20><>ȡ<EFBFBD><C8A1>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ֺ<EFBFBD><D6BA><EFBFBD>ʾ<EFBFBD>ı<EFBFBD>
Text personText = personItem.GetComponentInChildren<Text>();
2024-11-30 16:19:19 +08:00
2024-12-04 16:37:51 +08:00
if (personText != null)
2024-11-30 16:19:19 +08:00
{
2024-12-04 16:37:51 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
bool isPersonAdded = sceneDataDictionary[selectedInfo.scene].Any(info => info.name == personText.text);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫΪ<C9AB><CEAA>ɫ
if (isPersonAdded)
{
personText.color = Color.blue; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ɫ
}
else
{
personText.color = Color.white; // δ<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ɫ
}
2024-11-30 16:19:19 +08:00
}
}
}
}
2024-12-04 16:37:51 +08:00
2024-11-27 02:11:27 +08:00