72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using static MQTT;
|
|
|
|
public class UI_StatusContent : MonoBehaviour
|
|
{
|
|
public Dictionary<string, UI_MachineStatus> machineStatuses = new Dictionary<string, UI_MachineStatus>();
|
|
private UI_MachineStatus prf_machineStatus;
|
|
public Vector3 resetPosition;
|
|
|
|
private float moveSpeed;
|
|
private Vector3 centerPosition;
|
|
private Vector3 endContentPosition;
|
|
public override void AfterAwake()
|
|
{
|
|
prf_machineStatus = Resources.Load<UI_MachineStatus>("Prefabs/UI/UI_StatusItem");
|
|
}
|
|
public void SetEndPosition(Vector3 centerPos, Vector3 endPos, float speed)
|
|
{
|
|
centerPosition = centerPos;
|
|
endContentPosition = endPos;
|
|
moveSpeed = speed;
|
|
}
|
|
public void SetProductionStatusItem(List<CompleteInfo> machineInfos)
|
|
{
|
|
bool odd = true;
|
|
foreach (var machineInfo in machineInfos)
|
|
{
|
|
if (!machineStatuses.ContainsKey(machineInfo.worknm))
|
|
{
|
|
var machineStatus = Instantiate(prf_machineStatus, transform);
|
|
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 StartMoveAnimation()
|
|
{
|
|
StopAllCoroutines();
|
|
StartCoroutine(MoveAnimation());
|
|
}
|
|
private IEnumerator MoveAnimation()
|
|
{
|
|
while (transform.localPosition.x >= resetPosition.x)
|
|
{
|
|
transform.localPosition += Vector3.left * moveSpeed;
|
|
|
|
if (transform.localPosition.x == centerPosition.x)
|
|
{
|
|
yield return new WaitForSeconds(2f);
|
|
}
|
|
|
|
if (transform.localPosition.x == resetPosition.x)
|
|
{
|
|
yield return new WaitForSeconds(2f);
|
|
transform.localPosition = endContentPosition;
|
|
}
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|