You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
7.2 KiB
204 lines
7.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class PassPart : MonoBehaviour
|
|
{
|
|
|
|
public PassInfo passInfo;
|
|
|
|
public Text passIndex;
|
|
public Text scoreTxt;
|
|
public Text timeTxt;
|
|
public Text titleTxt;
|
|
public Button EnterBtn;
|
|
|
|
public int _passIndex;
|
|
|
|
public GameObject overTip;
|
|
public List<int> BTPassArr = new List<int>();
|
|
|
|
public void Init()
|
|
{
|
|
//控件查找
|
|
passIndex = transform.Find("PassIndex").gameObject.GetComponent<Text>();
|
|
titleTxt = transform.Find("info").gameObject.GetComponent<Text>();
|
|
timeTxt = transform.Find("time").Find("timeTxt").gameObject.GetComponent<Text>();
|
|
scoreTxt = transform.Find("score").Find("scoreTxt").gameObject.GetComponent<Text>();
|
|
EnterBtn = transform.Find("Button").gameObject.GetComponent<Button>();
|
|
overTip = transform.Find("overTip").gameObject;
|
|
EnterBtn.onClick.AddListener(LoadScene);
|
|
|
|
|
|
if (passInfo != null)
|
|
{
|
|
//SetPassIndex(passInfo.PassIndex);
|
|
passIndex.text = _passIndex.ToString() + "、";
|
|
scoreTxt.text = passInfo.score.ToString("0.0") + "分";
|
|
|
|
timeTxt.text = passInfo.time.ToString() + "分钟";
|
|
titleTxt.text = passInfo.info;
|
|
}
|
|
|
|
BTPassArr.Add(1);
|
|
BTPassArr.Add(3);
|
|
BTPassArr.Add(6);
|
|
BTPassArr.Add(7);
|
|
}
|
|
|
|
public void LoadScene()
|
|
{
|
|
if (GameRoot.Instance.isRndom)//考试模式下抽小题
|
|
{
|
|
if (BTPassArr.Contains(passInfo.PassIndex))
|
|
{
|
|
if (passInfo.PassIndex < 10)
|
|
{
|
|
string SceneName = "";
|
|
//int index = 0;
|
|
////TODO Switch选择关卡
|
|
//switch (passInfo.PassIndex)
|
|
//{
|
|
// case 1:
|
|
// index = Random.Range(1, 3);
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex.ToString() + "_" + index;
|
|
// break;
|
|
// case 3:
|
|
// index = Random.Range(1, 2);
|
|
// if (index == 0)
|
|
// {
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex;
|
|
// break;
|
|
// }
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex.ToString() + "_" + index;
|
|
// break;
|
|
// case 6:
|
|
// index = Random.Range(1, 2);
|
|
// if (index == 0)
|
|
// {
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex;
|
|
// break;
|
|
// }
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex.ToString() + "_" + index;
|
|
// break;
|
|
// case 7:
|
|
// index = Random.Range(1, 2);
|
|
// if (index == 0)
|
|
// {
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex;
|
|
// break;
|
|
// }
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex.ToString() + "_" + index;
|
|
// break;
|
|
//}
|
|
switch (GameRoot.Instance.ABType)
|
|
{
|
|
case 0:
|
|
SceneName = "Level" + "0" + passInfo.PassIndex;
|
|
break;
|
|
case 1:
|
|
SceneName = "Level" + "0" + passInfo.PassIndex+"_B";
|
|
break;
|
|
}
|
|
// SceneName = "Level" + "0" + passInfo.PassIndex;
|
|
if (!Application.CanStreamedLevelBeLoaded(SceneName)) return;
|
|
SceneManager.LoadScene(SceneName);
|
|
Debug.Log("加载场景:" + "Level" + "0" + passInfo.PassIndex);
|
|
}
|
|
else
|
|
{
|
|
//TODO Switch选择关卡
|
|
|
|
if (!Application.CanStreamedLevelBeLoaded("Level" + passInfo.PassIndex)) return;
|
|
SceneManager.LoadScene("Level" + passInfo.PassIndex);
|
|
Debug.Log("加载场景:" + "Level" + passInfo.PassIndex);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (passInfo.PassIndex < 10)
|
|
{
|
|
if (!Application.CanStreamedLevelBeLoaded("Level" + "0" + passInfo.PassIndex)) return;
|
|
SceneManager.LoadScene("Level" + "0" + passInfo.PassIndex);
|
|
Debug.Log("加载场景:" + "Level" + "0" + passInfo.PassIndex);
|
|
}
|
|
else
|
|
{
|
|
if (!Application.CanStreamedLevelBeLoaded("Level" + passInfo.PassIndex)) return;
|
|
SceneManager.LoadScene("Level" + passInfo.PassIndex);
|
|
Debug.Log("加载场景:" + "Level" + passInfo.PassIndex);
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (passInfo.PassIndex < 10)
|
|
{
|
|
if (!Application.CanStreamedLevelBeLoaded("Level" + "0" + passInfo.PassIndex)) return;
|
|
switch (GameRoot.Instance.ABType)
|
|
{
|
|
case 0:
|
|
SceneManager.LoadScene("Level" + "0" + passInfo.PassIndex);
|
|
break;
|
|
case 1:
|
|
SceneManager.LoadScene("Level" + "0" + passInfo.PassIndex + "_B");
|
|
//SceneName = "Level" + "0" + passInfo.PassIndex+"_B";
|
|
break;
|
|
}
|
|
|
|
Debug.Log("加载场景:" + "Level" + "0" + passInfo.PassIndex);
|
|
}
|
|
else
|
|
{
|
|
if (!Application.CanStreamedLevelBeLoaded("Level" + passInfo.PassIndex)) return;
|
|
switch (GameRoot.Instance.ABType)
|
|
{
|
|
case 0:
|
|
SceneManager.LoadScene("Level" + passInfo.PassIndex);
|
|
break;
|
|
case 1:
|
|
SceneManager.LoadScene("Level" + passInfo.PassIndex + "_B");
|
|
//SceneName = "Level" + "0" + passInfo.PassIndex+"_B";
|
|
break;
|
|
}
|
|
Debug.Log("加载场景:" + "Level" + passInfo.PassIndex);
|
|
}
|
|
}
|
|
|
|
|
|
GameRoot.Instance.SetActiveMenuCanvans(false);
|
|
GameRoot.Instance.CurrentPass = this;
|
|
//如果考试模式显示倒计时
|
|
//if (GameRoot.Instance.isRndom)
|
|
//{
|
|
// //开始计时
|
|
// GameRoot.Instance.StartCountDownTime();
|
|
|
|
//}
|
|
|
|
GameRoot.Instance.StartCountDownTime();
|
|
}
|
|
|
|
public void passOver()
|
|
{
|
|
EnterBtn.interactable = false;
|
|
overTip.gameObject.SetActive(true);
|
|
}
|
|
|
|
|
|
public void SetPassIndex(int index)
|
|
{
|
|
_passIndex = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|