97 lines
3.5 KiB
C#
97 lines
3.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
public class ClampAmmetersInteractive : MonoBehaviour
|
|
{
|
|
public bool isInteractive;
|
|
public GameObject g1;
|
|
public string selChildName;
|
|
public float linearMeasure;//默认的大小
|
|
public List<float> floats;
|
|
public string Fuan;
|
|
public string unit;
|
|
private void Start()
|
|
{
|
|
if (!transform.GetComponent<MeshCollider>())
|
|
{
|
|
transform.AddComponent<MeshCollider>();
|
|
}
|
|
|
|
//Fuan = ClampAmmetersManager.Instance.Init(selChildName);
|
|
}
|
|
[ContextMenu("运行")]
|
|
public void Init()
|
|
{
|
|
//g1 = transform.GetChild(0).GetComponent<Transform>().gameObject;
|
|
//selChildName = g1.name;
|
|
Fuan = ClampAmmetersManager.Instance.Init(selChildName);
|
|
}
|
|
private void OnMouseDown()
|
|
{
|
|
//Debug.Log("ok");
|
|
if (GameManager.Instance.temp == null) return;
|
|
if (GameManager.Instance.temp.transform.name.Equals("钳形电流表(Clone)"))
|
|
{
|
|
if (g1)
|
|
{
|
|
GameManager.Instance.DianFuIm.gameObject.SetActive(true);
|
|
GameManager.Instance.temp.transform.parent = g1.transform;
|
|
GameManager.Instance.temp.transform.DOLocalRotate(new Vector3(47.52f, 0, 53.88f), 0.25f);
|
|
GameManager.Instance.temp.transform.DOScale(new Vector3(50, 50, 50), 0.25f);
|
|
GameManager.Instance.temp.transform.DOLocalMove(new Vector3(1.42f, -6.02f, 8.35f), 0.25f);
|
|
float abs = Mathf.Abs(GameManager.Instance.QianStopValve.currentValue);
|
|
if (abs >= 1 && abs <= 3)
|
|
{
|
|
float dianyliu = float.Parse(Fuan);
|
|
GameManager.Instance.DianFuTex.text = dianyliu + " " + unit;
|
|
}
|
|
else
|
|
{
|
|
GameManager.Instance.DianFuTex.text = "-" + unit;
|
|
}
|
|
for (int i = 0; i < floats.Count; i++)
|
|
{
|
|
if (floats[(int)(GameManager.Instance.QianStopValve.Sum / 10)] > linearMeasure)
|
|
{
|
|
GetComponent<Fraction>().CompletedorNot = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (GameManager.Instance.temp.transform.name.Equals("钳形电流表_大(Clone)"))
|
|
{
|
|
if (g1)
|
|
{
|
|
GameManager.Instance.DianFuIm.gameObject.SetActive(true);
|
|
GameManager.Instance.temp.transform.parent = g1.transform;
|
|
GameManager.Instance.temp.transform.DOLocalRotate(new Vector3(207.21f, -257.72f, -135.6f), 0.25f);
|
|
GameManager.Instance.temp.transform.DOScale(new Vector3(15, 15, 15), 0.25f);
|
|
GameManager.Instance.temp.transform.DOLocalMove(new Vector3(-0.2f, -2.8f, 1.02f), 0.25f);
|
|
float dianyliu = float.Parse(Fuan);
|
|
|
|
GameManager.Instance.DianFuTex.text = dianyliu + " " + unit;
|
|
for (int i = 0; i < floats.Count; i++)
|
|
{
|
|
if (floats[(int)(GameManager.Instance.QianStopValve.Sum / 10)] > linearMeasure)
|
|
{
|
|
GetComponent<Fraction>().CompletedorNot = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown("t"))
|
|
{
|
|
Debug.Log(GameManager.Instance.DianFuTex.text + "==== GameManager.Instance.DianFuTex.text");
|
|
}
|
|
}
|
|
}
|