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.

150 lines
3.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DingShi : MonoBehaviour
{
public enum LeiXing {
ZF,
XZ,
KT
}
int time;
float useTime;
public int min_time;
public int max_time;
public Text time_text;
int one;
int two;
int three;
public Text one_text;
public Text two_text;
public Text three_text;
public GameObject page3;
public LeiXing lx;
public GameObject obj;
public GameObject schedudle;
public GameObject obj1;
public GameObject obj2;
private void Awake()
{
time = 1;
updateShow();
two = 0;
three = 0;
}
public void up() {
time++;
if (time > max_time) {
time = min_time;
}
updateShow();
}
public void down() {
time--;
if (time < min_time) {
time = max_time;
}
updateShow();
}
void updateShow() {
time_text.text = time.ToString();
one_text.text = one.ToString();
two_text.text = two.ToString();
three_text.text = three.ToString();
}
public void StartZF()
{
one = time;
GameManager.GetInstance().IsZhuFan = true;
page3.SetActive(true);
obj.GetComponent<AllDoor>().zf.SetActive(true);
schedudle.SetActive(true);
obj1.SetActive(true);
obj2.SetActive(true);
TaskCenter.GetInstance().FinishTask(4);
}
public void StartLY()
{
one = time;
GameManager.GetInstance().IsXiZao = true;
page3.SetActive(true);
schedudle.SetActive(true);
obj1.SetActive(true);
obj2.SetActive(true);
TaskCenter.GetInstance().FinishTask(8);
}
public void StartKT() {
one = time;
GameManager.GetInstance().IsKongTiao = true;
page3.SetActive(true);
schedudle.SetActive(true);
obj1.SetActive(true);
obj2.SetActive(true);
TaskCenter.GetInstance().FinishTask(9);
}
private void Update()
{
if (lx == LeiXing.ZF)
{
if (!GameManager.GetInstance().IsZhuFan) return;
}
else if(lx==LeiXing.XZ){
if (!GameManager.GetInstance().IsXiZao) return;
}
else if (lx==LeiXing.KT)
{
if (!GameManager.GetInstance().IsKongTiao) return;
}
useTime += Time.deltaTime;
if (useTime>=1) {
useTime = 0;
three--;
if (three<0) {
three = 9;
two--;
if (two<0) {
two = 5;
one--;
}
}
}
updateShow();
if (one==0&&two==0&&three==0) {
if (lx == LeiXing.ZF)
{
GameManager.GetInstance().IsZhuFan = false;
GameManager.GetInstance().IsFinishZF = true;
page3.SetActive(false);
obj.GetComponent<DSTask>().ZFfinish();
}
else if (lx == LeiXing.XZ)
{
GameManager.GetInstance().IsXiZao = false;
GameManager.GetInstance().IsFinishXZ=true;
page3.SetActive(false);
obj.GetComponent<DSTask>().RSfinish();
}
else if (lx == LeiXing.KT)
{
GameManager.GetInstance().IsKongTiao = false;
GameManager.GetInstance().IsFinishKT = true;
page3.SetActive(false);
obj.GetComponent<DSTask>().KTfinish();
}
}
}
public void fanhui(GameObject obj) {
obj.SetActive(false);
}
}