2025-02-20 09:59:37 +09:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
|
using UnityEngine;
|
2025-02-24 08:37:05 +09:00
|
|
|
|
using UnityEngine.UI;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
using WI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CHN
|
|
|
|
|
|
{
|
2025-04-01 13:47:45 +09:00
|
|
|
|
[Serializable]
|
2025-02-20 09:59:37 +09:00
|
|
|
|
public class Machine : MonoBehaviour
|
|
|
|
|
|
{
|
2025-07-02 08:32:33 +09:00
|
|
|
|
public string machineName;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
public string code;
|
|
|
|
|
|
public string[] typeOptions;
|
|
|
|
|
|
public UI_MachineKPI machineKPI;
|
2025-02-24 08:37:05 +09:00
|
|
|
|
public Sprite previewImage;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
public Vector3 centerPos;
|
2025-11-21 13:07:13 +09:00
|
|
|
|
public Vector3 originScale;
|
2025-06-19 17:59:06 +09:00
|
|
|
|
|
2025-08-26 09:40:05 +09:00
|
|
|
|
public Animator[] animators;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
|
2025-04-03 11:53:25 +09:00
|
|
|
|
public HighLighter highLighter;
|
2025-03-28 11:15:57 +09:00
|
|
|
|
public float animSpeed;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
|
2025-06-19 17:59:06 +09:00
|
|
|
|
public float focusDistance;
|
|
|
|
|
|
public float focusAzimuth;
|
|
|
|
|
|
public float focusElevation;
|
|
|
|
|
|
|
2025-02-20 09:59:37 +09:00
|
|
|
|
public override void AfterAwake()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!gameObject.activeSelf)
|
|
|
|
|
|
return;
|
|
|
|
|
|
GetComponentInParent<Floor>().machines.Add(this);
|
|
|
|
|
|
centerPos = transform.GetMeshGroupCenter();
|
2025-08-26 09:40:05 +09:00
|
|
|
|
animators = GetComponentsInChildren<Animator>();
|
2025-03-28 11:15:57 +09:00
|
|
|
|
|
2025-04-03 11:53:25 +09:00
|
|
|
|
highLighter = GetComponentInChildren<HighLighter>(true);
|
2025-11-21 13:07:13 +09:00
|
|
|
|
originScale = gameObject.transform.localScale;
|
2025-02-20 09:59:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-28 11:15:57 +09:00
|
|
|
|
public void SetAnimationSpeed()
|
|
|
|
|
|
{
|
2025-08-26 09:40:05 +09:00
|
|
|
|
if (animators.Length == 0)
|
2025-07-15 13:55:39 +09:00
|
|
|
|
return;
|
|
|
|
|
|
|
2025-03-28 11:15:57 +09:00
|
|
|
|
if (machineKPI != null)
|
|
|
|
|
|
{
|
2025-07-15 13:55:39 +09:00
|
|
|
|
if (machineKPI.data.machineInfo.statusnm == null)
|
2025-08-26 09:40:05 +09:00
|
|
|
|
{
|
|
|
|
|
|
animSpeed = 0f;
|
|
|
|
|
|
}
|
2025-04-24 08:36:29 +09:00
|
|
|
|
|
2025-07-15 13:55:39 +09:00
|
|
|
|
if (machineKPI.data.machineInfo.statusnm == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
|
|
|
|
|
|
{
|
2025-08-26 09:40:05 +09:00
|
|
|
|
animSpeed = UnityEngine.Random.Range(0.7f, 1.5f);
|
2025-07-15 13:55:39 +09:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2025-04-28 15:59:32 +09:00
|
|
|
|
{
|
|
|
|
|
|
animSpeed = 0f;
|
|
|
|
|
|
}
|
2025-08-26 09:40:05 +09:00
|
|
|
|
|
|
|
|
|
|
foreach(var animator in animators)
|
|
|
|
|
|
{
|
|
|
|
|
|
animator.speed = animSpeed;
|
|
|
|
|
|
}
|
2025-03-28 11:15:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-03 11:53:25 +09:00
|
|
|
|
|
|
|
|
|
|
public void ActiveHighLighter()
|
2025-02-25 11:27:20 +09:00
|
|
|
|
{
|
2025-04-03 11:53:25 +09:00
|
|
|
|
highLighter.gameObject.SetActive(true);
|
2025-02-25 11:27:20 +09:00
|
|
|
|
}
|
2025-04-03 11:53:25 +09:00
|
|
|
|
public void DeactiveHighLighter()
|
2025-02-25 11:27:20 +09:00
|
|
|
|
{
|
2025-04-03 11:53:25 +09:00
|
|
|
|
highLighter.gameObject.SetActive(false);
|
2025-03-28 08:40:40 +09:00
|
|
|
|
}
|
2025-04-03 11:53:25 +09:00
|
|
|
|
|
2025-02-20 09:59:37 +09:00
|
|
|
|
|
|
|
|
|
|
public int GetMachineFloorIndex()
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform currentParent = transform.parent;
|
|
|
|
|
|
|
|
|
|
|
|
while (currentParent != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Floor myFloor = currentParent.GetComponent<Floor>();
|
|
|
|
|
|
if (myFloor != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return myFloor.floorIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
currentParent = currentParent.parent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2025-02-25 11:27:20 +09:00
|
|
|
|
|
2025-04-03 11:53:25 +09:00
|
|
|
|
|
2025-02-20 09:59:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|