104 lines
3.2 KiB
C#
104 lines
3.2 KiB
C#
using UnityEngine;
|
|
using AibisDream.UI;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
using UnityEngine.Events;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class BlockPuzzlePart : MonoBehaviour, IOperatorPanel
|
|
{
|
|
public UnityEvent OnSubmit => lockButton.onClick;
|
|
public UnityEvent OnPopUp => popUpButton.onClick;
|
|
|
|
private Animator _animator;
|
|
|
|
// ------------------------ 进度条 -------------------------
|
|
|
|
// [Header("进度条")]
|
|
// [SerializeField] private ProgressBar _powerProgressBar;
|
|
// [SerializeField] private ProgressBar _noiseProgressBar;
|
|
// [SerializeField] private ProgressBar _heatProgressBar;
|
|
|
|
public void OnProgressChanged(BlockPuzzleParamValue paramValue)
|
|
{
|
|
// 更新进度条
|
|
// _powerProgressBar.CurrentValue = paramValue.power;
|
|
// _noiseProgressBar.CurrentValue = paramValue.noise;
|
|
// _heatProgressBar.CurrentValue = paramValue.heat;
|
|
|
|
// TODO 更新通过情况
|
|
|
|
// TODO 更新提示文本
|
|
}
|
|
|
|
public void OnRangeChanged(BlockPuzzleParamValue paramValue)
|
|
{
|
|
// TODO 更新进度条范围
|
|
}
|
|
|
|
// ------------------------ 器件选择 -------------------------
|
|
[Header("器件选择")]
|
|
[SerializeField] private RectTransform _deviceButtonRoot;
|
|
[SerializeField] private GameObject _deviceItemPrefab;
|
|
|
|
public event Action<BlockShapeInfo> OnDeviceSelected;
|
|
|
|
private void InitDeviceList()
|
|
{
|
|
// TODO: 初始化器件列表
|
|
}
|
|
|
|
public void OnDeviceRecycle(BlockShape blockShape)
|
|
{
|
|
AddDeviceButton(blockShape.BlockShapeData.blockShapeInfo);
|
|
}
|
|
|
|
public void OnDeviceRemove(BlockShape blockShape)
|
|
{
|
|
// 从传送带获取器件时移除面板上的器件信息
|
|
Destroy(blockShape.gameObject);
|
|
RemoveDeviceButton(blockShape.BlockShapeData.shapeName);
|
|
}
|
|
|
|
private void AddDeviceButton(BlockShapeInfo blockShapeInfo)
|
|
{
|
|
var button = Instantiate(_deviceItemPrefab, _deviceButtonRoot).GetComponent<ShapeCreateButton>();
|
|
|
|
button.SetInfo(blockShapeInfo);
|
|
button.OnClicked.AddListener(() => OnDeviceSelected?.Invoke(blockShapeInfo));
|
|
}
|
|
|
|
public void RemoveDeviceButton(string shapeName)
|
|
{
|
|
var button = _deviceButtonRoot.Find(shapeName).gameObject;
|
|
Destroy(button);
|
|
}
|
|
|
|
// ------------------------ 按钮组 ---------------------------
|
|
|
|
[Header("提交按钮")]
|
|
[SerializeField] private Button lockButton;
|
|
[SerializeField] private Button popUpButton;
|
|
|
|
public Button LockButton => lockButton;
|
|
public Button PopUpButton => popUpButton;
|
|
|
|
// ------------------------ 面板收放 -------------------------
|
|
public void Init()
|
|
{
|
|
InitDeviceList();
|
|
// 初始化进度条部分
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
_animator?.Play("Open", 0, 0);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
_animator?.Play("Close", 0, 0);
|
|
}
|
|
}
|
|
} |