26.04.03 가상공장 화면 디자인 반영 • 좌측 도구 창, 상단 UI, 하단 UI • 생산 현황판, 알림 현황판 • 설비 라벨, 요약 팝업, 대시보드, 데이터 보드 • 설정창, 미니맵, AI 시뮬레이션 결과창, 나가기 팝업 가상 공장 화면 디자인 변경에 따른 기능 추가 • 미니맵 드래그 및 위치 조정 기능 추가 • UI 상호 작용(호버링, 선택, 위치 이동, 재설정) • UI 기능 추가(상태 표시, 색상)
180 lines
5.7 KiB
C#
180 lines
5.7 KiB
C#
using AZTECHWB.Core;
|
|
using AZTECHWB.Constants;
|
|
using AZTECHWB.Management;
|
|
using Cysharp.Threading.Tasks;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AZTECHWB.UI
|
|
{
|
|
public class ProductionProgressPanel : UIPanel
|
|
{
|
|
private Dictionary<int, ProgressContent> statusContents = new Dictionary<int, ProgressContent>();
|
|
private ProgressContent prf_statusContent;
|
|
private RectTransform Content;
|
|
private Button Button_Close;
|
|
private TextMeshProUGUI CurrentDate;
|
|
private TextMeshProUGUI CurrentTime;
|
|
|
|
public int statusItemsCount;
|
|
private int currentContentIndex;
|
|
private bool isChangedData;
|
|
|
|
public float changeDataTime;
|
|
public float fadeTime;
|
|
|
|
public override async UniTask Init()
|
|
{
|
|
CurrentDate = GetElement<TextMeshProUGUI>(nameof(CurrentDate));
|
|
CurrentTime = GetElement<TextMeshProUGUI>(nameof(CurrentTime));
|
|
Content = GetElement<RectTransform>(nameof(Content));
|
|
Button_Close = GetElement<Button>(nameof(Button_Close));
|
|
|
|
prf_statusContent = Resources.Load<ProgressContent>($"{ResourceURL.uiPrefabFolderPath}{nameof(ProgressContent)}");
|
|
Button_Close.onClick.AddListener(Close);
|
|
SetDate();
|
|
|
|
await UniTask.CompletedTask;
|
|
}
|
|
public void Update()
|
|
{
|
|
SetTime();
|
|
}
|
|
public override void Open()
|
|
{
|
|
gameObject.SetActive(true);
|
|
gameObject.transform.SetAsLastSibling();
|
|
|
|
StopAllCoroutines();
|
|
StartCoroutine(ScaleUp());
|
|
|
|
if (statusContents.Count <= 0)
|
|
{
|
|
isChangedData = false;
|
|
return;
|
|
}
|
|
|
|
StartCoroutine(ChageStatusContent());
|
|
}
|
|
public override void Close()
|
|
{
|
|
var uiManager = AZTECHSceneMain.Instance.GetManager<AZTECHUIManager>();
|
|
var topMenu = uiManager.GetCanvas<StaticCanvas>().GetPanel<TopMenuPanel>();
|
|
topMenu.SetMenuItemEnable("production_status", true);
|
|
|
|
gameObject.SetActive(false);
|
|
gameObject.transform.localScale = Vector3.zero;
|
|
ResetStatusContentOrder();
|
|
isChangedData = false;
|
|
|
|
}
|
|
private IEnumerator ChageStatusContent()
|
|
{
|
|
isChangedData = true;
|
|
|
|
currentContentIndex = 0;
|
|
|
|
statusContents[currentContentIndex].gameObject.transform.SetAsFirstSibling();
|
|
currentContentIndex++;
|
|
|
|
var wfs = new WaitForSeconds(changeDataTime);
|
|
while (true)
|
|
{
|
|
yield return wfs;
|
|
|
|
if (currentContentIndex >= statusContents.Values.Count)
|
|
{
|
|
currentContentIndex = 0;
|
|
}
|
|
|
|
statusContents[currentContentIndex].gameObject.transform.SetAsFirstSibling();
|
|
currentContentIndex++;
|
|
}
|
|
}
|
|
private void ResetStatusContentOrder()
|
|
{
|
|
foreach (var statusContent in statusContents.Values)
|
|
{
|
|
statusContent.gameObject.transform.SetAsFirstSibling();
|
|
}
|
|
}
|
|
|
|
public void SetProductionStatus(List<CompleteInfo> machineInfos)
|
|
{
|
|
var splitCompleteInfo = SplitArray(machineInfos, statusItemsCount);
|
|
SetProductionContent(splitCompleteInfo);
|
|
}
|
|
|
|
public void SetProductionContent(List<List<CompleteInfo>> splitCompleteInfo)
|
|
{
|
|
for (int i = 0; i < splitCompleteInfo.Count; i++)
|
|
{
|
|
if (!statusContents.ContainsKey(i))
|
|
{
|
|
var statusContent = Instantiate(prf_statusContent, Content);
|
|
statusContent.Init();
|
|
statusContent.SetProductionStatusItem(splitCompleteInfo[i]);
|
|
statusContents.Add(i, statusContent);
|
|
}
|
|
else
|
|
{
|
|
statusContents[i].SetProductionStatusItem(splitCompleteInfo[i]);
|
|
}
|
|
}
|
|
|
|
if (!isChangedData && gameObject.activeSelf)
|
|
{
|
|
StopAllCoroutines();
|
|
StartCoroutine(ChageStatusContent());
|
|
}
|
|
}
|
|
private List<List<CompleteInfo>> SplitArray(List<CompleteInfo> machineInfos, int groupSize)
|
|
{
|
|
List<List<CompleteInfo>> result = new List<List<CompleteInfo>>();
|
|
int totalGroups = Mathf.CeilToInt(machineInfos.Count / (float)groupSize);
|
|
|
|
for (int i = 0; i < totalGroups; i++)
|
|
{
|
|
int startIndex = i * groupSize;
|
|
int endIndex = Mathf.Min(startIndex + groupSize, machineInfos.Count);
|
|
|
|
List<CompleteInfo> group = new List<CompleteInfo>();
|
|
for (int j = startIndex; j < endIndex; j++)
|
|
{
|
|
group.Add(machineInfos[j]);
|
|
}
|
|
|
|
result.Add(group);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
public void SetDate()
|
|
{
|
|
CurrentDate.text = DateTime.Now.ToString("yyyy.MM.dd");
|
|
}
|
|
public void SetTime()
|
|
{
|
|
CurrentTime.text = DateTime.Now.ToString("HH:mm");
|
|
}
|
|
IEnumerator ScaleUp()
|
|
{
|
|
float timer = 0f;
|
|
float percent = 0f;
|
|
|
|
while (percent < 1)
|
|
{
|
|
timer += Time.deltaTime;
|
|
percent = timer / fadeTime;
|
|
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, percent);
|
|
|
|
yield return null;
|
|
}
|
|
|
|
}
|
|
}
|
|
} |