Files

100 lines
2.5 KiB
C#
Raw Permalink Normal View History

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
{
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;
public Animator[] animators;
2025-02-20 09:59:37 +09:00
2025-04-03 11:53:25 +09:00
public HighLighter highLighter;
public float animSpeed;
2025-02-20 09:59:37 +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();
animators = GetComponentsInChildren<Animator>();
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
}
public void SetAnimationSpeed()
{
if (animators.Length == 0)
return;
if (machineKPI != null)
{
if (machineKPI.data.machineInfo.statusnm == null)
{
animSpeed = 0f;
}
if (machineKPI.data.machineInfo.statusnm == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
animSpeed = UnityEngine.Random.Range(0.7f, 1.5f);
}
else
2025-04-28 15:59:32 +09:00
{
animSpeed = 0f;
}
foreach(var animator in animators)
{
animator.speed = animSpeed;
}
}
}
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-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
}
}