using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class FlowManager : MonoBehaviour { public Flow_change flow_Change; public Text 总分text; public TMPro.TMP_Text 当前步骤; public int index; public float 总分; public GameObject 步骤合集; public 流程模式 流程模式 = 流程模式.练习模式; public List 流程分步; private List tipsbases; private int newindex; private int oldindex; private void Awake() { for (int i = 0; i < 流程分步.Count; i++) { 流程分步[i].enabled = false; for (int g = 0; g < 流程分步[i].流程物体.Count; g++) { if (流程分步[i].流程物体[g].物品分类 == 物品分类.交互区域) { 流程分步[i].流程物体[g].GetComponent().enabled = false; } } } } private void OnEnable() { if (flow_Change.是否练习 == true) { 流程模式 = 流程模式.练习模式; } else { 流程模式 = 流程模式.考核模式; } } // Start is called before the first frame update void Start() { 步骤切换(); } // Update is called once per frame void Update() { IndexCheck(); 总分text.text = "总分:" + 总分.ToString(); } /// /// 侦测步骤变化 /// public void IndexCheck() { oldindex = index; if (oldindex != newindex) { 步骤切换(); } newindex = index; } /// /// 切换步骤时只开启对应步骤的交互点和物体及提示,只有练习模式生效 /// public void 步骤切换() { if (流程模式 == 流程模式.练习模式) {//开启线性模式 for (int i = 0; i < 流程分步.Count; i++) { 流程分步[i].enabled = false; for (int g = 0; g < 流程分步[i].流程物体.Count; g++) { if (流程分步[i].流程物体[g].物品分类 == 物品分类.交互区域) { 流程分步[i].流程物体[g].GetComponent().enabled = false; } } } 流程分步[index].enabled = true; 流程分步[index].提示.SetActive(true); 当前步骤.text = 流程分步[index].流程名称; for (int i = 0; i < 流程分步[index].流程物体.Count; i++) { if (流程分步[index].流程物体[i].物品分类 == 物品分类.交互区域) { 流程分步[index].流程物体[i].GetComponent().enabled = true; } } //开启提示 tipsbases = new List(); foreach (tipsbase item in 步骤合集.GetComponentsInChildren()) { tipsbases.Add(item); } for (int i = 0; i < tipsbases.Count; i++) { tipsbases[i].gameObject.SetActive(false); } 流程分步[index].transform.GetChild(1).gameObject.SetActive(true); } else { for (int i = 0; i < 流程分步[index].流程物体.Count; i++) { if (流程分步[index].流程物体[i].物品分类 == 物品分类.交互区域) { 流程分步[index].流程物体[i].GetComponent().enabled = true; } } 流程分步[index].enabled = true; 流程分步[index].transform.GetChild(1).gameObject.SetActive(true); 当前步骤.text = 流程分步[index].流程名称; for (int i = 0; i < 流程分步.Count; i++) { 流程分步[i].enabled = false; for (int g = 0; g < 流程分步[i].流程物体.Count; g++) { if (流程分步[i].流程物体[g].物品分类 == 物品分类.交互区域) { 流程分步[i].流程物体[g].GetComponent().enabled = false; } } } } } }