using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using Unity.VisualScripting; using UnityEngine; public class GameManager : MonoBehaviour { public static GameManager ins; public GameObject Player; public CameraManager CameraManager; List tools; [SerializeField] GameObject QianXing; [SerializeField] GameObject WanYon; [SerializeField] GameObject YanDianBi; char[] TempChar = new char[7] { '(', 'C', 'l', 'o', 'n', 'e', ')' }; public string dataStr; [SerializeField] List Datas = new List(); [SerializeField] List GFGame;//光伏板物体 [SerializeField] SceneData SceneData;//暂时数据 [SerializeField] List Inverter; [SerializeField] Transform trans; [SerializeField] StopValve WanStopValve; [SerializeField] StopValve QianStopValve; public GameObject temp; [SerializeField] List interactive; public GameObject RedWanYon; public GameObject BlackWanYon; public GameObject FuAnBiao; public Interactive interactiveEnum = Interactive.none; public Transform biaojiPos; public void Awake() { if (ins != null) { Destroy(ins); return; } ins = this; //Debug.Log(trans.GetComponent()!=null?true:false); } // Start is called before the first frame update private void Start() { int pvwCount = (GlobalFlag.pvw * 1000) / 295; for (int i = 0; i < pvwCount; i++) { GFGame[i].gameObject.SetActive(true); } //string sceneInfo = GlobalFlag.SceneInfo(); string sceneInfo = "单项_无互感器_有光伏"; Debug.Log(sceneInfo+ "2号逆变器_铭牌_正确======"); for (int i = 0; i < Inverter.Count; i++) { if (sceneInfo.Equals(Inverter[i].name)) { GameObject obj = Instantiate(Inverter[i]); obj.transform.localPosition = biaojiPos.localPosition; obj.transform.localEulerAngles = biaojiPos.localEulerAngles; } } //System.Diagnostics.Process.Start(Application.streamingAssetsPath+ "/ycxt2.0/index.html"); UIManager.Instance.ToolsItemManager.ItemClick.AddListener(ToolsShow); } private void Update() { switch (interactiveEnum) { case Interactive.none: for (int i = 0; i < interactive.Count; i++) { interactive[i].transform.GetComponent().启用交互 = true; } break; case Interactive.YanDian: for (int i = 0; i < interactive.Count; i++) { interactive[i].transform.GetComponent().启用交互 = false; } break; case Interactive.QianXing: for (int i = 0; i < interactive.Count; i++) { interactive[i].transform.GetComponent().启用交互 = true; } break; default: break; } } /// /// 工具生成方法 /// public void ToolsShow(GameObject tools) { if (temp != null) { Destroy(temp.gameObject); } temp = Instantiate(tools, Player.transform); temp.transform.localPosition = new Vector3(0.312f, 0.316f, 0.618f); UIManager.Instance.ToolsItemManager.currentTool = temp; string name = Filter(temp.name, TempChar); Debug.Log(name); switch (name) { case "万用表": WanStopValve.gameObject.SetActive(true); QianStopValve.gameObject.SetActive(false); GameObject t2 = GameObject.FindGameObjectWithTag("旋转"); WanStopValve.trans = t2.transform; temp.GetComponent(); temp.GetComponent().line.SetActive(true); break; case "钳形电流表": interactiveEnum = Interactive.QianXing; temp.transform.localRotation = Quaternion.Euler(new Vector3(90, 180, 0)); QianStopValve.trans = temp.transform.Find("旋转"); WanStopValve.gameObject.SetActive(false); QianStopValve.gameObject.SetActive(true); break; case "验电笔": interactiveEnum = Interactive.YanDian; temp.transform.localPosition = new Vector3(0.307f, 0.504f, 0.654f); temp.AddComponent(); break; case "相位伏安表": temp.transform.localEulerAngles = new Vector3(0, 180, 0); temp.AddComponent(); break; default: Insta(temp); WanStopValve.gameObject.SetActive(false); QianStopValve.gameObject.SetActive(false); break; } } public string Filter(string str, char[] charsToRemove) { return String.Concat(str.Split(charsToRemove.ToArray())); } /// /// 克隆位置更改 /// public void Insta(GameObject GameObj) { GameObj.transform.localPosition = new Vector3(Player.transform.position.x + 0.43f, Player.transform.position.y + 0.66f, Player.transform.position.z + 1.5f); } } /// /// 后台读的数据 /// [Serializable] public class datas { public bool state; public string message; public data2s data; } [Serializable] public class data2s { public string isguangfu; public string jxfs; public string zhbl; } public enum Interactive { none, YanDian, QianXing }