89 lines
2.4 KiB
C#
89 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
using static MQTT;
|
|
using TMPro;
|
|
|
|
public class Panel_InjectionProduction : PanelBase
|
|
{
|
|
public SDictionary<string, UI_MachineStatus> machineStatuses = new SDictionary<string, UI_MachineStatus>();
|
|
private UI_MachineStatus prf_machineStatus;
|
|
public ScrollRect ScrollView_StatusItems;
|
|
public Button CloseButton;
|
|
public TextMeshProUGUI CurrentDate;
|
|
public TextMeshProUGUI CurrentTime;
|
|
|
|
public float fadeTime;
|
|
public override void AfterAwake()
|
|
{
|
|
prf_machineStatus = Resources.Load<UI_MachineStatus>("Prefabs/UI/UI_StatusItem");
|
|
CloseButton.onClick.AddListener(Close);
|
|
SetDate();
|
|
Close();
|
|
}
|
|
public void Update()
|
|
{
|
|
SetTime();
|
|
}
|
|
public void Open()
|
|
{
|
|
gameObject.SetActive(true);
|
|
|
|
StopAllCoroutines();
|
|
StartCoroutine(ScaleUp());
|
|
}
|
|
public void Close()
|
|
{
|
|
gameObject.SetActive(false);
|
|
gameObject.transform.localScale = Vector3.zero;
|
|
}
|
|
public void SetProductionStatus(List<CompleteInfo> machineInfos)
|
|
{
|
|
bool odd = true;
|
|
foreach (var machineInfo in machineInfos)
|
|
{
|
|
if (!machineStatuses.ContainsKey(machineInfo.worknm))
|
|
{
|
|
var machineStatus = Instantiate(prf_machineStatus, ScrollView_StatusItems.content);
|
|
machineStatuses.Add(machineInfo.worknm, machineStatus);
|
|
}
|
|
|
|
if (odd)
|
|
{
|
|
machineStatuses[machineInfo.worknm].SetStatusData(machineInfo, new Color(0.07058824f, 0.1294118f, 0.2941177f));
|
|
}
|
|
else
|
|
{
|
|
machineStatuses[machineInfo.worknm].SetStatusData(machineInfo, new Color(0.04313726f, 0.09019608f, 0.2235294f));
|
|
}
|
|
odd = !odd;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|