173 lines
4.1 KiB
C#
173 lines
4.1 KiB
C#
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<FlowsBase> 流程分步;
|
|
private List<tipsbase> 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<Collider>().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();
|
|
}
|
|
/// <summary>
|
|
/// 侦测步骤变化
|
|
/// </summary>
|
|
public void IndexCheck()
|
|
{
|
|
|
|
|
|
oldindex = index;
|
|
if (oldindex != newindex)
|
|
{
|
|
|
|
步骤切换();
|
|
|
|
}
|
|
newindex = index;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
/// <summary>
|
|
/// 切换步骤时只开启对应步骤的交互点和物体及提示,只有练习模式生效
|
|
/// </summary>
|
|
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<Collider>().enabled = false;
|
|
}
|
|
}
|
|
}
|
|
流程分步[index].enabled = true;
|
|
流程分步[index].提示.SetActive(true);
|
|
当前步骤.text = 流程分步[index].流程名称;
|
|
for (int i = 0; i < 流程分步[index].流程物体.Count; i++)
|
|
{
|
|
|
|
if (流程分步[index].流程物体[i].物品分类 == 物品分类.交互区域)
|
|
{
|
|
|
|
流程分步[index].流程物体[i].GetComponent<BoxCollider>().enabled = true;
|
|
}
|
|
}
|
|
//开启提示
|
|
tipsbases = new List<tipsbase>();
|
|
foreach (tipsbase item in 步骤合集.GetComponentsInChildren<tipsbase>())
|
|
{
|
|
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<BoxCollider>().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<Collider>().enabled = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|