생산 진행, 조립 진행 현황판 기능 수정
This commit is contained in:
@@ -9,18 +9,22 @@ using TMPro;
|
||||
|
||||
public class Panel_InjectionProduction : PanelBase
|
||||
{
|
||||
public SDictionary<string, UI_MachineStatus> machineStatuses = new SDictionary<string, UI_MachineStatus>();
|
||||
public Dictionary<int, UI_StatusContent> statusContents = new Dictionary<int, UI_StatusContent>();
|
||||
private Panel_Effect effect;
|
||||
private UI_MachineStatus prf_machineStatus;
|
||||
public ScrollRect ScrollView_StatusItems;
|
||||
private UI_StatusContent prf_statusContent;
|
||||
public RectTransform Content;
|
||||
public Button CloseButton;
|
||||
public TextMeshProUGUI CurrentDate;
|
||||
public TextMeshProUGUI CurrentTime;
|
||||
|
||||
public int statusItemsCount;
|
||||
private int currentContentIndex;
|
||||
|
||||
public float changeDataTime;
|
||||
public float fadeTime;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
prf_machineStatus = Resources.Load<UI_MachineStatus>("Prefabs/UI/UI_StatusItem");
|
||||
prf_statusContent = Resources.Load<UI_StatusContent>("Prefabs/UI/UI_StatusContent");
|
||||
effect = FindSingle<Panel_Effect>();
|
||||
CloseButton.onClick.AddListener(Close);
|
||||
SetDate();
|
||||
@@ -38,35 +42,86 @@ public class Panel_InjectionProduction : PanelBase
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(ScaleUp());
|
||||
|
||||
StartCoroutine(ChageStatusContent());
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
effect.DeactivePanel(gameObject);
|
||||
gameObject.SetActive(false);
|
||||
gameObject.transform.localScale = Vector3.zero;
|
||||
ResetStatusContentOrder();
|
||||
}
|
||||
public void SetProductionStatus(List<CompleteInfo> machineInfos)
|
||||
private IEnumerator ChageStatusContent()
|
||||
{
|
||||
bool odd = true;
|
||||
foreach (var machineInfo in machineInfos)
|
||||
currentContentIndex = 0;
|
||||
|
||||
statusContents[currentContentIndex].gameObject.transform.SetAsFirstSibling();
|
||||
currentContentIndex++;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!machineStatuses.ContainsKey(machineInfo.worknm))
|
||||
yield return new WaitForSeconds(changeDataTime);
|
||||
|
||||
if (currentContentIndex >= statusContents.Values.Count)
|
||||
{
|
||||
var machineStatus = Instantiate(prf_machineStatus, ScrollView_StatusItems.content);
|
||||
machineStatuses.Add(machineInfo.worknm, machineStatus);
|
||||
currentContentIndex = 0;
|
||||
}
|
||||
|
||||
if (odd)
|
||||
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))
|
||||
{
|
||||
machineStatuses[machineInfo.worknm].SetStatusData(machineInfo, new Color(0.07058824f, 0.1294118f, 0.2941177f));
|
||||
var statusContent = Instantiate(prf_statusContent, Content);
|
||||
statusContent.SetProductionStatusItem(splitCompleteInfo[i]);
|
||||
statusContents.Add(i, statusContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
machineStatuses[machineInfo.worknm].SetStatusData(machineInfo, new Color(0.04313726f, 0.09019608f, 0.2235294f));
|
||||
statusContents[i].SetProductionStatusItem(splitCompleteInfo[i]);
|
||||
}
|
||||
odd = !odd;
|
||||
}
|
||||
}
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user