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

612 lines
18 KiB
C#
Raw Normal View History

2024-12-20 18:50:23 +08:00
using System;
2024-12-17 16:28:38 +08:00
using System.Collections;
using System.Collections.Generic;
2024-12-20 18:50:23 +08:00
using System.Numerics;
using JetBrains.Annotations;
2024-12-18 23:13:30 +08:00
using Newtonsoft.Json;
2024-12-17 16:28:38 +08:00
using TMPro;
2024-12-20 18:50:23 +08:00
using Unity.VisualScripting;
2024-12-17 16:28:38 +08:00
using UnityEngine;
using UnityEngine.UI;
public class FreePanelManager : MonoBehaviour
{
[Header("<22><><EFBFBD><EFBFBD>")]
public Sprite TestImage;
[Header("<22><><EFBFBD><EFBFBD>")]
2024-12-18 23:13:30 +08:00
//ְҵѡ<D2B5><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject OccupationPanel;
2024-12-17 16:28:38 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject TipPanel;
public GameObject AccidentIPanel;
2024-12-18 23:13:30 +08:00
//ְҵ<D6B0><D2B5><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>
2024-12-20 18:50:23 +08:00
public List<GameObject> OpcList;
2024-12-19 11:31:55 +08:00
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ť
public GameObject EvacuateSurePanel;
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject EvacuatePanel;
2024-12-17 16:28:38 +08:00
[Header("ͼ<><CDBC>")]
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ
public Image TipBg;
//<2F>¹ʵ<C2B9><CAB5><EFBFBD>ͼ
public Image AccidentImage;
2024-12-18 23:13:30 +08:00
[Header("<22><>ť")]
public Button AccidentButton;
public Button OpcLeft;
public Button OpcRight;
2024-12-19 11:31:55 +08:00
public Button EvacuateButton;
public Button EvacuateSure;
public Button Evacuate1Button;
public Button Evacuate2Button;
public Button Evacuate3Button;
public Button Evacuate4Button;
2024-12-17 16:28:38 +08:00
[Header("<22>ı<EFBFBD>")]
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
public Text TipText;
2024-12-19 11:31:55 +08:00
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Text EvacuateText1;
public Text EvacuateText2;
public Text EvacuateText3;
public Text EvacuateText4;
2024-12-17 16:28:38 +08:00
[Header("һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD>ֵֹĶ<D6B5><C4B6><EFBFBD>")]
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
public float fadeInDuration = 1f; // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public float fadeOutDuration = 1f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public float displayDuration = 2f; // 2<><32><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>
private bool isFadingIn = true;
private bool isFadingOut = false;
// ָʾ<D6B8>ı<EFBFBD><C4B1><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>򵭳<EFBFBD>
private bool isFading = false;
private bool isFadeEnd = false;
// <20><><EFBFBD><EFBFBD><EFBFBD>еĵ<D0B5><C4B5><EFBFBD><EBB5AD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private Coroutine fadeCoroutine;
#endregion
2024-12-18 23:13:30 +08:00
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public List<GameObject> createdItems = new List<GameObject>();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>б<EFBFBD>
2024-12-20 18:50:23 +08:00
public List<string> Order = new List<string>();//<2F><><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ֶ<EFBFBD>
2024-12-18 23:13:30 +08:00
public GameObject content1; // Scroll View <20><> Content <20><><EFBFBD><EFBFBD>
public List<string> OpcName = new List<string>(); //<2F><><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-20 18:50:23 +08:00
public Sprite InfoBg;//<2F><><EFBFBD>ܵĵװ<C4B5>
private int itemCount = 1; // Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-18 23:13:30 +08:00
public GameObject itemPrefab; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD>Ƽ<EFBFBD>
2024-12-23 19:12:48 +08:00
public GameObject Order2Prefab;//<2F><><EFBFBD>дμ<D0B4><CEBC><EFBFBD><EFBFBD><EFBFBD>
2024-12-25 12:02:42 +08:00
//public List<>
2024-12-18 23:13:30 +08:00
public JSONReader JSONReader;
#endregion
2024-12-20 18:50:23 +08:00
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public List<string> OpcItems = new List<string>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ
public List<Transform> DirectChildren = new List<Transform>();//<2F><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>Item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public List<GameObject> TagChildren = new List<GameObject>();//<2F><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>Item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ǩ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD>
public GameObject Item;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˭<EFBFBD><CBAD>jio<69><6F>
public List<string> TaskId = new List<string>();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject OpcPrefab;//ְҵԤ<D2B5><D4A4><EFBFBD><EFBFBD>
public Image OpcImage;//Ԥ<><D4A4><EFBFBD><EFBFBD>ͼƬ
2024-12-25 12:02:42 +08:00
public List<Text> OpcNameList=new List<Text>();
2024-12-20 18:50:23 +08:00
#endregion
private static int a = 0;
private static int bb = 5;
2024-12-23 19:12:48 +08:00
public static FreePanelManager Z;
2024-12-18 23:13:30 +08:00
public void Start()
{
2024-12-23 19:12:48 +08:00
Z = this;
2024-12-20 18:50:23 +08:00
ContainsValue(11002);
if (DirectChildren.Count>=5)
{
OpcRight.gameObject.SetActive(true);
}
2024-12-20 18:50:23 +08:00
#region <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
InitializeChild();
#endregion
2024-12-18 23:13:30 +08:00
//ְҵ<D6B0><D2B5><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>ť
OpcLeft.onClick.AddListener(() =>
{
2024-12-20 18:50:23 +08:00
LeftRight(a, -1);
2024-12-18 23:13:30 +08:00
});
//ְҵ<D6B0><D2B5><EFBFBD>ܿ<EFBFBD><DCBF>Ұ<EFBFBD>ť
2024-12-20 18:50:23 +08:00
OpcRight.onClick.AddListener(() =>
{
LeftRight(a, 1);
2024-12-18 23:13:30 +08:00
});
2024-12-19 11:31:55 +08:00
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
#region <EFBFBD><EFBFBD>ɢ˳<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
2024-12-20 18:50:23 +08:00
Evacuate1Button.onClick.AddListener(() =>
{
2024-12-19 11:31:55 +08:00
EvacuateSurePanel.SetActive(true);
});
2024-12-20 18:50:23 +08:00
Evacuate2Button.onClick.AddListener(() =>
{
2024-12-19 11:31:55 +08:00
EvacuateSurePanel.SetActive(true);
});
2024-12-20 18:50:23 +08:00
Evacuate3Button.onClick.AddListener(() =>
{
2024-12-19 11:31:55 +08:00
EvacuateSurePanel.SetActive(true);
});
2024-12-20 18:50:23 +08:00
Evacuate4Button.onClick.AddListener(() =>
{
2024-12-19 11:31:55 +08:00
EvacuateSurePanel.SetActive(true);
});
#endregion
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD>ļ<EFBFBD>ͷ
2024-12-20 18:50:23 +08:00
EvacuateButton.onClick.AddListener(() =>
{
2024-12-19 11:31:55 +08:00
EvacuatePanel.SetActive(false);
EvacuateSurePanel.SetActive(false);
});
//ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
2024-12-18 23:13:30 +08:00
}
2024-12-17 16:28:38 +08:00
public void Update()
{
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (Input.GetKeyDown("j"))
{
2024-12-18 23:13:30 +08:00
// PopAccident(TestImage);
2024-12-17 16:28:38 +08:00
}
#endregion
if (isFadeEnd)
{
StopCoroutine(FadeInOutRoutine());
isFadeEnd = false;
}
}
public void FixedUpdate()
{
if (bb == DirectChildren.Count)
{
OpcRight.gameObject.SetActive(false);
}
2024-12-17 16:28:38 +08:00
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public void PopTipPanel()
{
TipPanel.SetActive(true);
StopCoroutine(FadeInOutRoutine());
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>¹ʿ<C2B9><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>ͼƬ
/// </summary>
/// <param name="image"><3E><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¹<EFBFBD>ͼƬ<CDBC><C6AC>Spite<74><65></param>
public void PopAccident(Sprite image)
{
2024-12-18 23:13:30 +08:00
AccidentImage.sprite = image;
2024-12-17 16:28:38 +08:00
AccidentIPanel.SetActive(true);
}
/// <summary>
/// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EBB5AD><EFBFBD><EFBFBD>Я<EFBFBD><D0AF>
/// </summary>
/// <returns></returns>
IEnumerator FadeInOutRoutine()
{
isFading = true; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EBB5AD><EFBFBD><EFBFBD>־
//// <20><><EFBFBD><EFBFBD>
float elapsedTime = 0f;
while (elapsedTime < fadeInDuration)
{
elapsedTime += Time.deltaTime;
//Color textColor = TipText.color;
//textColor.a = elapsedTime / fadeInDuration; // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>alphaֵ
//TipText.color = textColor;
//TipBg.color = textColor;
yield return null; // <20>ȴ<EFBFBD><C8B4><EFBFBD>һ֡
}
// <20><>ʾ<EFBFBD>ı<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1>
yield return new WaitForSeconds(displayDuration);
// <20><><EFBFBD><EFBFBD>
elapsedTime = 0f;
while (elapsedTime < fadeOutDuration)
{
elapsedTime += Time.deltaTime;
Color textColor = TipText.color;
textColor.a = 1f - (elapsedTime / fadeOutDuration); // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>alphaֵ
TipText.color = textColor;
TipBg.color = textColor;
yield return null; // <20>ȴ<EFBFBD><C8B4><EFBFBD>һ֡
}
isFading = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EBB5AD><EFBFBD><EFBFBD>־
isFadeEnd = true;//<2F><><EFBFBD><EFBFBD>Я<EFBFBD>̽<EFBFBD><CCBD><EFBFBD><EFBFBD>ı<EFBFBD>־
TipPanel.SetActive(false);
}
2024-12-18 23:13:30 +08:00
/// <summary>
/// <20>򿪹ر<F2BFAAB9>ְҵѡ<D2B5><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public void OpenOccupation()
{
bool isActive = OccupationPanel.activeSelf;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EEA3AC><EFBFBD>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OccupationPanel.SetActive(!isActive);
}
/// <summary>
/// <20><>ȡְҵ<D6B0><D2B5><EFBFBD>ֲ<EFBFBD><D6B2>Ҹ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="ID">ְҵ<D6B0><D2B5>ID</param>
/// <param name="a"><3E>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>1<EFBFBD><31>ʼ)</param>
2024-12-25 12:02:42 +08:00
public void OcpNameChoose(int ID,GameObject item)
2024-12-18 23:13:30 +08:00
{
string str = JSONReader.GetOcpName(ID);
2024-12-25 12:02:42 +08:00
item.transform.Find("occuname").GetComponent<Text>().text = str;
2024-12-20 18:50:23 +08:00
2024-12-18 23:13:30 +08:00
}
/// <summary>
2024-12-20 18:50:23 +08:00
/// <20><><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>OcpNameChoose<73><65><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>
2024-12-18 23:13:30 +08:00
/// </summary>
/// <param name="ID">ְҵ<D6B0><D2B5>ID</param>
/// <param name="content"><3E><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
2024-12-20 18:50:23 +08:00
public void CreateOcpText(string ID, GameObject content)
2024-12-18 23:13:30 +08:00
{
OpcName.Clear();
2024-12-23 19:12:48 +08:00
Order.Clear();
2024-12-20 18:50:23 +08:00
createdItems.Clear(); // ȷ<><C8B7> createdItems <20><><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> SelectDictionary
2024-12-18 23:13:30 +08:00
foreach (var kvp in JSONReader.ZZSelectsDictionary)
{
// <20><><EFBFBD><EFBFBD> kvp.Key <20><><EFBFBD>ֵ<EFBFBD><D6B5>ļ<EFBFBD><C4BC><EFBFBD>kvp.Value <20><> Select <20><><EFBFBD><EFBFBD>
Select select = kvp.Value;
// <20>ж<EFBFBD> UIDetails <20>Ƿ<EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (select.UIDetails == ID.ToString())
{
// <20><> Note <20><><EFBFBD>ӵ<EFBFBD> OpcName <20>б<EFBFBD>
OpcName.Add(select.Note);
2024-12-20 18:50:23 +08:00
Order.Add(select.AppliedUI);
2024-12-18 23:13:30 +08:00
}
}
2024-12-20 18:50:23 +08:00
2024-12-18 23:13:30 +08:00
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B2A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < OpcName.Count; i++)
{
2024-12-23 19:12:48 +08:00
GameObject newItem;
2024-12-20 18:50:23 +08:00
2024-12-23 19:12:48 +08:00
// <20><><EFBFBD><EFBFBD> Order[i] <20><> "order2"<22><>ʹ<EFBFBD><CAB9> Order2Prefab <20><><EFBFBD><EFBFBD>
if (i < Order.Count && Order[i] == "order2")
2024-12-20 18:50:23 +08:00
{
2024-12-23 19:12:48 +08:00
newItem = Instantiate(Order2Prefab, content.transform);
2024-12-20 18:50:23 +08:00
Image image = newItem.GetComponent<Image>();
2024-12-23 19:12:48 +08:00
if (image != null)
2024-12-20 18:50:23 +08:00
{
2024-12-23 19:12:48 +08:00
image.sprite = InfoBg; // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ͼƬ
}
else
{
Debug.LogWarning($"δ<>ҵ<EFBFBD> Image <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {i}");
2024-12-20 18:50:23 +08:00
}
2024-12-18 23:13:30 +08:00
2024-12-23 19:12:48 +08:00
#region <EFBFBD>ϰ<EFBFBD>
//// <20>ҵ<EFBFBD><D2B5>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> Toggle
//Toggle toggle = newItem.transform.Find("Item")?.GetComponent<Toggle>();
//if (toggle != null)
//{
// int index = i; // <20>þֲ<C3BE><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浱ǰ<E6B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lambda <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Debug.Log($"<22><><EFBFBD><EFBFBD> Toggle <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {index}<7D><><EFBFBD>ı<EFBFBD>: {OpcName[index]}");
// toggle.onValueChanged.AddListener((isOn) =>
// {
// if (isOn)
// {
// HandleToggleClick(index, newItem); // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// }
// });
//}
//else
//{
// Debug.LogWarning($"δ<>ҵ<EFBFBD> Toggle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD>: {i}");
//}
#endregion
}
else
{
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD>ϵ<EFBFBD> itemPrefab <20><><EFBFBD><EFBFBD>
newItem = Instantiate(itemPrefab, content.transform);
}
2024-12-20 18:50:23 +08:00
2024-12-23 19:12:48 +08:00
// <20>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Text left = newItem.transform.Find("Text")?.GetComponent<Text>();
if (left != null)
{
left.text = OpcName[i]; // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
}
else
{
Debug.LogWarning($"δ<>ҵ<EFBFBD> Text <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {i}");
}
2024-12-20 18:50:23 +08:00
2024-12-23 19:12:48 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
createdItems.Add(newItem);
2024-12-20 18:50:23 +08:00
}
}
2024-12-23 19:12:48 +08:00
#region <EFBFBD>ϰ<EFBFBD>
//public void ToggleManger()
//{
// for (int i = 0; i < Order.Count; i++)
// {
// // <20>ҵ<EFBFBD><D2B5>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> Toggle
// Toggle toggle= FindToggleInChildren();
// if (toggle != null)
// {
// int index = i; // <20>þֲ<C3BE><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浱ǰ<E6B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lambda <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// toggle.onValueChanged.AddListener((isOn) =>
// {
// if (isOn)
// {
// HandleToggleClick(index, toggle.gameObject); // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// }
// });
// }
// else
// {
// Debug.LogWarning($"δ<>ҵ<EFBFBD> Toggle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD>: {i}");
// }
// }
//}
//// <20><><EFBFBD><EFBFBD> Toggle <20><><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD>
//private void HandleToggleClick(int index, GameObject toggleObject)
//{
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
// if (index == 0 || index == 1) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
// {
// Debug.Log($"<22><><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EEB1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE> Toggle {index}, <20>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>: {OpcName[index]}");
// DeleteToggle(toggleObject); // ɾ<><C9BE> Toggle
// }
// else if (index == 2) // <20><>ȷѡ<C8B7><D1A1>
// {
// Debug.Log($"<22><>ȷѡ<C8B7><EFBFBD><EEB1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ȷ<EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>: {OpcName[index]}");
// HandleCorrectOption(); // ִ<><D6B4><EFBFBD><EFBFBD>ȷѡ<C8B7><D1A1><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
// }
//}
//// ɾ<><C9BE> Toggle <20>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD>
//private void DeleteToggle(GameObject toggleObject)
//{
// if (toggleObject != null)
// {
// Debug.Log($"ɾ<><C9BE> Toggle: {toggleObject.name}");
// // <20>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
// Destroy(toggleObject);
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> createdItems <20>б<EFBFBD><D0B1>У<EFBFBD><D0A3>Ƴ<EFBFBD><C6B3><EFBFBD>
// if (createdItems.Contains(toggleObject))
// {
// createdItems.Remove(toggleObject);
// }
// }
//}
// <20><>ȷѡ<C8B7><D1A1><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD>
//private void HandleCorrectOption()
//{
// Debug.Log("<22><>ȷ<EFBFBD>𰸱<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD>");
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷѡ<C8B7><D1A1><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
//}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD> newItem <20>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> Toggle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//public Toggle FindToggleInChildren()
//{
// // <20><><EFBFBD><EFBFBD> createdItems <20>б<EFBFBD><D0B1>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// foreach (GameObject parent in createdItems)
// {
// // ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>岻Ϊ<E5B2BB><CEAA>
// if (parent == null) continue;
// // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ڷǵݹ<C7B5><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> Toggle
// Queue<Transform> queue = new Queue<Transform>();
// queue.Enqueue(parent.transform);
// while (queue.Count > 0)
// {
// Transform current = queue.Dequeue();
// // <20><><EFBFBD>鵱ǰ<E9B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD> Toggle <20><><EFBFBD><EFBFBD>
// Toggle toggle = current.GetComponent<Toggle>();
// if (toggle != null)
// {
// return toggle; // <20>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB> Toggle <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// }
// // <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// foreach (Transform child in current)
// {
// queue.Enqueue(child);
// }
// }
// }
// // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD> Toggle<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD> null
// return null;
//}
#endregion
2024-12-20 18:50:23 +08:00
//ְҵ<D6B0><D2B5><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD>ť
private void LeftRight(int a, int b)
{
if (b > 0)
{
DirectChildren[a].gameObject.SetActive(false);
a += 1;
bb += 1;
2024-12-20 18:50:23 +08:00
}
if (b < 0)
{
DirectChildren[a].gameObject.SetActive(true);
2024-12-20 18:50:23 +08:00
a -= 1;
bb-=1;
}
//<2F>жϰ<D0B6>ť<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ
if (DirectChildren[0].gameObject.activeSelf)
{
OpcRight.gameObject.SetActive(true);
}
if (DirectChildren[0].gameObject.activeSelf)
{
OpcLeft.gameObject.SetActive(false);
}
else
{
OpcLeft.gameObject.SetActive(true);
2024-12-20 18:50:23 +08:00
}
2024-12-18 23:13:30 +08:00
}
2024-12-20 18:50:23 +08:00
//<2F><>ʼ<EFBFBD><CABC>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>
private void InitializeChild()
2024-12-18 23:13:30 +08:00
{
2024-12-20 18:50:23 +08:00
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
DirectChildren.Clear();
TagChildren.Clear();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Transform parent = Item.transform;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < parent.childCount; i++)
2024-12-18 23:13:30 +08:00
{
2024-12-20 18:50:23 +08:00
Transform child = parent.GetChild(i);
2024-12-18 23:13:30 +08:00
2024-12-20 18:50:23 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD> DirectChildren <20>б<EFBFBD>
DirectChildren.Add(child);
2024-12-18 23:13:30 +08:00
}
2024-12-20 18:50:23 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
for (int i = 0; i < DirectChildren.Count; i++)
{
Transform child = DirectChildren[i];
// <20>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FindChildrenWithTag(child, "Content");
}
}
//Ѱ<><D1B0>Tap<61><70>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private void FindChildrenWithTag(Transform parent, string tag)
{
foreach (Transform child in parent)
2024-12-18 23:13:30 +08:00
{
2024-12-20 18:50:23 +08:00
if (child.CompareTag(tag))
{
TagChildren.Add(child.gameObject);
}
// <20>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FindChildrenWithTag(child, tag);
2024-12-18 23:13:30 +08:00
}
}
2024-12-19 11:31:55 +08:00
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1>ɢ·<C9A2><C2B7>
/// </summary>
/// <param name="ID"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID</param>
public void ReadEvacuateInfo(int ID)
{
}
2024-12-20 18:50:23 +08:00
/// <summary>
/// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ְҵ<D6B0>ذ<EFBFBD><D8B0><EFBFBD>ɫ
/// </summary>
/// <param name="ID"></param>
public void LoadAndSetImage(int ID)
{
// <20><> Resources <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>ͼƬ
Sprite sprite = Resources.Load<Sprite>("ZZZOpcImage/" + ID.ToString());
2024-12-19 11:31:55 +08:00
2024-12-20 18:50:23 +08:00
if (sprite != null)
{
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> A <20>ϵ<EFBFBD> Image <20><><EFBFBD><EFBFBD>
Image imageComponent = OpcImage;
if (imageComponent != null)
{
imageComponent.sprite = sprite;
}
}
else
{
Debug.LogError("Image not found in Resources at: " + "<22><><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
/// <summary>
/// <20>жϴ<D0B6><CFB4><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD>ְҵ
/// </summary>
/// <param name="target"><3E><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID</param>
public void ContainsValue(int target)
{
foreach (var kvp in JSONReader.ZZFindTaskID)
{
// <20><>ȡ Select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
List<Select> selectList = kvp.Value;
foreach (var select in selectList)
{
// ȷ<><C8B7> Precondition <20><>Ϊ<EFBFBD><CEAA>
if (string.IsNullOrEmpty(select.Precondition))
continue;
// <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
var groups = select.Precondition.Split(new char[] { '#', '|' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var group in groups)
{
if (string.IsNullOrWhiteSpace(group)) // <20><><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD>
continue;
// <20><><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ `,` <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>
var items = group.Split(',');
foreach (var item in items)
{
if (string.IsNullOrWhiteSpace(item)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
continue;
string trimmedItem = item.Trim(); // ȥ<><C8A5><EFBFBD>ո<EFBFBD>
if (int.TryParse(trimmedItem, out int value) && value == target)
{
if (!OpcItems.Contains(select.UIDetails))
{
OpcItems.Add(select.UIDetails); // <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
}
}
}
}
CreatOpc();
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ְҵ<D6B0>װ<EFBFBD>
/// </summary>
public void CreatOpc()
{
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5B2A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < OpcItems.Count; i++)
{
GameObject newItem = Instantiate(OpcPrefab, Item.transform);
2024-12-25 12:02:42 +08:00
OcpNameChoose(int.Parse(OpcItems[i]),newItem);
2024-12-20 18:50:23 +08:00
newItem.SetActive(true);
LoadAndSetImage(int.Parse(OpcItems[i]));
OpcList.Add(newItem); // <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
}
InitializeChild();
for (int i = 1; i < OpcItems.Count + 1; i++)
{
CreateOcpText("8006", TagChildren[i]);
}
2024-12-23 19:12:48 +08:00
2024-12-20 18:50:23 +08:00
}
2024-12-17 16:28:38 +08:00
}