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.
169 lines
5.3 KiB
169 lines
5.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Level27
|
|
{
|
|
public class Level27Quesition : MonoBehaviour
|
|
{
|
|
public static Level27Quesition Instance = null;
|
|
|
|
public int currentQuestionIndex;
|
|
|
|
public Sprite HuoJingImg;
|
|
public Sprite GuZhangImg;
|
|
|
|
public Image BoxImage1, BoxImage2, BoxImage3, BoxImage4;
|
|
public GameObject OKItem1, OKItem2, OKItem3, OKItem4;
|
|
private bool question1OK = false, question2OK = false, question3OK = false, question4OK = false;
|
|
public GameObject OKInfo1, OKInfo2, OKInfo3, OKInfo4;
|
|
|
|
public bool tanceOpen=false, baojingOpen=false, kongzhiboxOpen=false;
|
|
|
|
public Level09.Level09Manager Level09Manager;
|
|
|
|
public bool isDarg = false;
|
|
|
|
public Animator BaoJingQi;
|
|
|
|
public GameObject[] quesition1LED, quesition4LED;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
currentQuestionIndex = Level09Manager.GetCurrentQuesitionIndex();
|
|
}
|
|
|
|
public void OpenTanCe()
|
|
{
|
|
tanceOpen = true;
|
|
}
|
|
public void OpenBaojing()
|
|
{
|
|
baojingOpen = true;
|
|
}
|
|
public void OpenkongZhiHe()
|
|
{
|
|
kongzhiboxOpen = true;
|
|
}
|
|
public void ResetItemState()
|
|
{
|
|
tanceOpen = false; baojingOpen = false; kongzhiboxOpen = false;
|
|
}
|
|
|
|
public void PassAction()
|
|
{
|
|
switch (currentQuestionIndex)
|
|
{
|
|
case 1:
|
|
if (!question1OK) return;
|
|
OKInfo1.SetActive(true);
|
|
BoxImage1.sprite = HuoJingImg;
|
|
|
|
break;
|
|
case 2:
|
|
if (!question2OK) return;
|
|
OKInfo2.SetActive(true);
|
|
BoxImage2.sprite = GuZhangImg;
|
|
break;
|
|
case 3:
|
|
if (!question3OK) return;
|
|
OKInfo3.SetActive(true);
|
|
BoxImage3.sprite = GuZhangImg;
|
|
break;
|
|
case 4:
|
|
if (!question4OK) return;
|
|
OKInfo4.SetActive(true);
|
|
BoxImage4.sprite = HuoJingImg;
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void BaoJing(bool b)
|
|
{
|
|
if (b)
|
|
{
|
|
BaoJingQi.CrossFade("jingbaodeng", 0.1f);
|
|
Camera.main.GetComponent<AudioSource>().Play();
|
|
|
|
}
|
|
else
|
|
{
|
|
BaoJingQi.CrossFade("New State", 0.1f);
|
|
Camera.main.GetComponent<AudioSource>().Stop();
|
|
}
|
|
|
|
}
|
|
|
|
public void PassCheck(DragItemH item)
|
|
{
|
|
switch (currentQuestionIndex)
|
|
{
|
|
case 1:
|
|
if (item.ItemName != "wenqiang") return;
|
|
float distance1 = Vector2.Distance(item.transform.position, OKItem1.transform.position);
|
|
if (distance1 <= 200f&&tanceOpen)
|
|
{
|
|
question1OK = true;
|
|
Debug.Log("正确");
|
|
ResetItemState();
|
|
BaoJing(true);
|
|
for (int i = 0; i < quesition1LED.Length; i++)
|
|
{
|
|
quesition1LED[i].SetActive(true);
|
|
}
|
|
}
|
|
|
|
break;
|
|
case 2:
|
|
if (item.ItemName != "hand") return;
|
|
float distance2 = Vector2.Distance(item.transform.position, OKItem2.transform.position);
|
|
if (distance2 <= 200f && tanceOpen)
|
|
{
|
|
question2OK = true;
|
|
Debug.Log("正确");
|
|
ResetItemState();
|
|
BaoJing(true);
|
|
}
|
|
break;
|
|
case 3:
|
|
if (item.ItemName != "luosidao") return;
|
|
float distance3 = Vector2.Distance(item.transform.position, OKItem3.transform.position);
|
|
if (distance3 <= 200f &&baojingOpen)
|
|
{
|
|
question3OK = true;
|
|
Debug.Log("正确");
|
|
ResetItemState();
|
|
BaoJing(true);
|
|
}
|
|
break;
|
|
case 4:
|
|
if (item.ItemName != "hand") return;
|
|
float distance4 = Vector2.Distance(item.transform.position, OKItem4.transform.position);
|
|
if (distance4 <= 200f && baojingOpen)
|
|
{
|
|
question4OK = true;
|
|
Debug.Log("正确");
|
|
ResetItemState();
|
|
BaoJing(true);
|
|
for (int i = 0; i < quesition4LED.Length; i++)
|
|
{
|
|
quesition4LED[i].SetActive(true);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|