79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Data;
|
|
|
|
namespace UVC.Factory
|
|
{
|
|
public class AGV: FactoryObject
|
|
{
|
|
private void Start()
|
|
{
|
|
DataOrderedMask = new List<string>
|
|
{
|
|
"Name",
|
|
"Type",
|
|
"Status",
|
|
"BatteryLevel",
|
|
"Location",
|
|
"LastMaintenance"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 내부 상태를 업데이트하고 정렬된 마스크에 정의된 특정 키에 대한 작업을 수행하여 제공된 데이터 객체를 처리합니다.
|
|
// </summary>
|
|
/// <remarks>이 메서드는 초기화되지 않은 경우 내부 데이터 상태를 업데이트하고, 제공된
|
|
/// <see cref="DataOrderedMask"/>에 정의된 키를 반복하여 제공된
|
|
/// <paramref name="newData"/> 객체의 일치하는 항목에 대한 작업을 수행합니다. <paramref name="newData"/>에 처리에 필요한 키가 포함되어 있는지
|
|
/// 확인합니다.</remarks>
|
|
/// <param name="newData">처리할 데이터 객체입니다. null이 아니어야 하며 정렬된 마스크와 관련된 키-값 쌍을 포함해야 합니다.
|
|
protected override void ProcessData(DataObject newData)
|
|
{
|
|
if (data == null)
|
|
{
|
|
UpdatePositionAndRotation(newData);
|
|
data = newData;
|
|
}
|
|
else
|
|
{
|
|
UpdatePositionAndRotation(newData);
|
|
foreach (var keyValue in newData)
|
|
{
|
|
if (data.ContainsKey(keyValue.Key))
|
|
{
|
|
data[keyValue.Key] = keyValue.Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UpdatePositionAndRotation(DataObject newData)
|
|
{
|
|
if (data == null)
|
|
{
|
|
float x = newData.GetFloat("X") * .001f;
|
|
float y = newData.GetFloat("Y") * .001f;
|
|
Quaternion rotation = Quaternion.Euler(0, newData.GetFloat("DEGREE"), 0);
|
|
transform.position = new Vector3(x, 0, y);
|
|
transform.rotation = rotation;
|
|
}
|
|
else
|
|
{
|
|
float x = data.GetFloat("X") * .001f;
|
|
float y = data.GetFloat("Y") * .001f;
|
|
Quaternion rotation = Quaternion.Euler(0, data.GetFloat("DEGREE"), 0);
|
|
float x2 = newData.GetFloat("X") * .001f;
|
|
float y2 = newData.GetFloat("Y") * .001f;
|
|
Quaternion rotation2 = Quaternion.Euler(0, newData.GetFloat("DEGREE"), 0);
|
|
|
|
if (x != x2 || y != y2) transform.position = new Vector3(x, 0, y);
|
|
if (rotation != rotation2) transform.rotation = rotation;
|
|
}
|
|
}
|
|
}
|
|
}
|