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

377 lines
10 KiB
C#
Raw Normal View History

2024-12-17 16:28:38 +08:00
using System.Collections;
using System.Collections.Generic;
2024-12-18 23:13:30 +08:00
using Newtonsoft.Json;
2024-12-17 16:28:38 +08:00
using TMPro;
2024-12-18 23:13:30 +08:00
using UnityEditor.Rendering.LookDev;
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>
public GameObject OpcTip1;
public GameObject OpcTip2;
public GameObject OpcTip3;
public GameObject OpcTip4;
public GameObject OpcTip5;
public GameObject OpcTip6;
public GameObject OpcTip7;
public GameObject OpcTip8;
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;
public Button OpcButton1;
public Button OpcButton2;
public Button OpcButton3;
public Button OpcButton4;
public Button OpcButton5;
public Button OpcButton6;
public Button OpcButton7;
public Button OpcButton8;
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-18 23:13:30 +08:00
//ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Text Ocp1;
public Text Ocp2;
public Text Ocp3;
public Text Ocp4;
public Text Ocp5;
public Text Ocp6;
public Text Ocp7;
public Text Ocp8;
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>
public GameObject content1; // Scroll View <20><> Content <20><><EFBFBD><EFBFBD>
public GameObject content2;
public GameObject content3;
public GameObject content4;
public GameObject content5;
public GameObject content6;
public GameObject content7;
public GameObject content8;
public List<string> OpcName = new List<string>(); //<2F><><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private int itemCount=1; // Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public GameObject itemPrefab; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD>Ƽ<EFBFBD>
public JSONReader JSONReader;
#endregion
public void Start()
{
2024-12-19 11:31:55 +08:00
OcpName(8001, 1);
OcpName(8002, 2);
2024-12-18 23:13:30 +08:00
OcpName(8004, 3);
OcpName(8006, 4);
2024-12-19 11:31:55 +08:00
OcpName(8007, 5);
OcpName(8008, 6);
OcpName(8010, 7);
OcpName(8011, 8);
2024-12-18 23:13:30 +08:00
//ְҵ<D6B0><D2B5><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>ť
OpcLeft.onClick.AddListener(() =>
{
LeftRight(1);
});
//ְҵ<D6B0><D2B5><EFBFBD>ܿ<EFBFBD><DCBF>Ұ<EFBFBD>ť
OpcRight.onClick.AddListener(() => {
LeftRight(2);
});
2024-12-19 11:31:55 +08:00
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
#region <EFBFBD><EFBFBD>ɢ˳<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
Evacuate1Button.onClick.AddListener(() => {
EvacuateSurePanel.SetActive(true);
});
Evacuate2Button.onClick.AddListener(() => {
EvacuateSurePanel.SetActive(true);
});
Evacuate3Button.onClick.AddListener(() => {
EvacuateSurePanel.SetActive(true);
});
Evacuate4Button.onClick.AddListener(() => {
EvacuateSurePanel.SetActive(true);
});
#endregion
//<2F><>ɢ˳<C9A2><CBB3><EFBFBD>ļ<EFBFBD>ͷ
EvacuateButton.onClick.AddListener(() => {
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>
OpcButton1.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton2.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton3.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton4.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton5.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton6.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton7.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
OpcButton8.onClick.AddListener(() =>
{
EvacuatePanel.SetActive(true);
});
#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;
}
}
/// <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>
public void OcpName(int ID, int index)
{
string str = JSONReader.GetOcpName(ID);
switch (index)
{
case 1:
CreateOcpText(ID.ToString(), content1);
Ocp1.text = str;
break;
case 2:
CreateOcpText(ID.ToString(), content2);
Ocp2.text = str;
break;
case 3:
CreateOcpText(ID.ToString(), content3);
Ocp3.text = str;
break;
case 4:
CreateOcpText(ID.ToString(), content4);
Ocp4.text = str;
break;
case 5:
CreateOcpText(ID.ToString(), content5);
Ocp5.text = str;
break;
case 6:
CreateOcpText(ID.ToString(), content6);
Ocp6.text = str;
break;
case 7:
CreateOcpText(ID.ToString(), content7);
Ocp7.text = str;
break;
case 8:
CreateOcpText(ID.ToString(), content8);
Ocp8.text = str;
break;
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>OcpName<6D><65><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>
/// </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>
public void CreateOcpText(string ID,GameObject content)
{
OpcName.Clear();
// <20><><EFBFBD><EFBFBD> SelectDictionaryctsDictionary.Count);
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);
}
}
// <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++)
{
GameObject newItem = Instantiate(itemPrefab, content.transform);
Text left = newItem.transform.Find("Text").GetComponent<Text>();
left.text = OpcName[i];
createdItems.Add(newItem); // <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
}
}
2024-12-19 11:31:55 +08:00
//ְҵ<D6B0><D2B5><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD>ť
private void LeftRight(int a)
2024-12-18 23:13:30 +08:00
{
if(a==1)
{
OpcTip1.SetActive(true);
OpcTip2.SetActive(true);
OpcTip3.SetActive(true);
OpcTip4.SetActive(true);
OpcTip5.SetActive(false);
OpcTip6.SetActive(false);
OpcTip7.SetActive(false);
OpcTip8.SetActive(false);
}
else
{
OpcTip1.SetActive(false);
OpcTip2.SetActive(false);
OpcTip3.SetActive(false);
OpcTip4.SetActive(false);
OpcTip5.SetActive(true);
OpcTip6.SetActive(true);
OpcTip7.SetActive(true);
OpcTip8.SetActive(true);
}
}
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-17 16:28:38 +08:00
}