CultivationOfBrewing/Assets/Scripts/UI/UIPanel/UI_StepsPanel.cs

169 lines
6.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 System.Collections;
using System.Collections.Generic;
using System.IO;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UI_StepsPanel : BasePanel
{
/// <summary>
/// 步骤预制体父物体
/// </summary>
public RectTransform StepsContent;
/// <summary>
/// 步骤滑动条
/// </summary>
public ScrollRect scrollRect;
public UI_StepsPanelItem StepsItem;
public UI_FineSoilPreparationPanel FineSoilPreparationPanel;
public PptFilesData data = new PptFilesData();
public string jsonFileName = "StepsConfig"; // JSON文件名
protected override void Awake()
{
data = JsonManager.LoadData<PptFilesData>(jsonFileName);
foreach (var pptFile in data.pptFiles)
{
if (StepsItem == null || StepsContent == null)
{
Debug.LogError("按钮预制体或父对象未设置");
return;
}
// 实例化按钮
var item = Instantiate(StepsItem, StepsContent);
item.Init(pptFile.fileName);
var buttonText = item.GetComponentInChildren<TextMeshProUGUI>();
Button button = item.GetComponentInChildren<Button>();
button.name = pptFile.fileName;
if (buttonText != null)
{
buttonText.text = $"{pptFile.fileName}";
}
//if (button == null)
//{
// Debug.LogError("预制体上没有Button组件");
// return;
//}
// 设置按钮文本
}
base.Awake();
}
public override void ShowMe()
{
base.ShowMe();
}
public override void HideMe()
{
base.HideMe();
}
protected override async void OnClick(string btnName)
{
Debug.Log(btnName);
await LoadPPTTest.RefreshScrollView(StepsContent, scrollRect);
switch (btnName)
{
case "retrun_Btn":
Bootstrap.Instance.scenesManager.LoadSceneAsyn(this, "MenuScene", () =>
{
Bootstrap.Instance.uiManager.ShowPanel<UI_SelectModePanel>(this, E_UI_Layer.Top, (panel) =>
{
Bootstrap.Instance.uiManager.ShowPanel<UI_BGPanel>(this, E_UI_Layer.Bot, (panel) =>
{
Debug.Log("加载场景成功");
Bootstrap.Instance.uiManager.HidePanel<UI_TipsForPracticePanel>();
Bootstrap.Instance.uiManager.HidePanel<UI_StepsPanel>();
Bootstrap.Instance.uiManager.HidePanel<UI_MainTitlePanel>();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
Bootstrap.Instance.uiManager.HidePanel<UI_ContentPanel>();
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.UpdateProgress, 0.9f);
Debug.Log("UI_StepsPanel已经显示在" + E_UI_Layer.System);
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType., false);
});
});
});
break;
case "育苗前种子处理":
Debug.Log("育苗前种子处理");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.ShowPanel<UI_ContentPanel>(this, E_UI_Layer.Mid, (panel) =>
{
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
CameraManager.instance.Camera.fieldOfView = 60;
CameraManager.instance.Camera.transform.SetPositionAndRotation
(CameraManager.instance.StepTrans[0].transform.position, CameraManager.instance.StepTrans[0].transform.rotation);
});
break;
case "播撒育苗技术流程":
Debug.Log("播撒育苗技术流程");
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
UI_TipPanel.Tips.Clear();
break;
case "精细整地要求":
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.ShowPanel<UI_FineSoilPreparationPanel>(this, E_UI_Layer.Mid, (panel) =>
{
Bootstrap.Instance.uiManager.ShowPanel<UI_ContentPanel>(this, E_UI_Layer.Mid, (panel) =>
{
UI_TipPanel.Tips.Add("在整地过程中,需彻底清除杂草,以减少杂草与高粱争夺养分。");
UI_TipPanel.Tips.Add("在播种前进行精细整地春季解冻后深翻至2030cm确保土壤疏松无硬结为播种和保苗创造良好条件。");
UI_TipPanel.Tips.Add("整地时需注意地表平整,无坷垃,以便于后续的播种和田间管理。");
Debug.Log("精细整地要求");
CameraManager.instance.Camera.fieldOfView = 60;
CameraManager.instance.Camera.transform.SetPositionAndRotation
(CameraManager.instance.StepTrans[1].transform.position, CameraManager.instance.StepTrans[1].transform.rotation);
});
});
//Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.拖车, true);
break;
case "苗龄与叶龄标准":
Debug.Log("育苗前种子处理");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
case "移栽时机和方式管理":
Debug.Log("移栽时机和方式管理");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
case "移栽后管理":
Debug.Log("移栽后管理");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
case "田间管理":
Debug.Log("田间管理");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
case "病虫害防治":
Debug.Log("病虫害防治");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
case "种子收货与储藏":
Debug.Log("种子收货与储藏");
UI_TipPanel.Tips.Clear();
Bootstrap.Instance.uiManager.HidePanel<UI_FineSoilPreparationPanel>();
break;
default:
break;
}
}
}