57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Samkwang
|
|
{
|
|
public class Machine : MonoBehaviour
|
|
{
|
|
private Dictionary<Component, MeshRenderer[]> meshGroupCache = new();
|
|
|
|
public UI_MachineStatusIcon machineStatusIcon;
|
|
public string machineName;
|
|
//public string code;
|
|
public string[] typeOptions;
|
|
public Sprite previewImage;
|
|
public Vector3 centerPos;
|
|
|
|
public float focusDistance;
|
|
public float focusAzimuth;
|
|
public float focusElevation;
|
|
|
|
public void Awake()
|
|
{
|
|
GetComponentInParent<Floor>().machines.Add(this);
|
|
centerPos = GetMeshGroupCenter(this);
|
|
}
|
|
|
|
public Vector3 GetMeshGroupCenter(Component root)
|
|
{
|
|
if (!meshGroupCache.TryGetValue(root, out _))
|
|
{
|
|
meshGroupCache.Add(root, root.GetComponentsInChildren<MeshRenderer>());
|
|
}
|
|
var meshs = meshGroupCache[root];
|
|
Vector3 total = Vector3.zero;
|
|
foreach (var m in meshs)
|
|
{
|
|
total += m.bounds.center;
|
|
}
|
|
return total / meshs.Length;
|
|
}
|
|
public void SetAnimation(string status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case "가동중":
|
|
//애니메이션 플레이
|
|
//애니메이션이 동작하지 않은 경우
|
|
break;
|
|
default:
|
|
//애니메이션 정지
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|