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.

90 lines
2.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class GameManager : MonoSingleton<GameManager>
{
public GameObject greenPerson;
public GameObject person2;
public GameObject[] needRemoveObjs;
public GameObject[] needTransferObjs;
public GameObject errorTip;
bool safe;
public bool remove=false;
public int safeOperate;//玩家选择的对应操作0对应转移1对应清理
RaycastHit rh;
protected override void Awake()
{
base.Awake();
DontDestroyOnLoad(gameObject);
safe = Random.value > 0.5 ? true : false;
InitScene(safe);
}
private void Start()
{
}
private void Update()
{
if (remove) {
Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out rh)) {
if (rh.collider.tag == "ZAW" && Input.GetMouseButtonDown(0)) {
if (rh.collider.GetComponent<Animator>())
{
rh.collider.GetComponent<Animator>().SetTrigger("Sankai");
}
else {
rh.collider.gameObject.SetActive(false);
}
rh.collider.tag = "Untagged";
}
}
}
}
public void InitScene(bool safe) {
greenPerson.GetComponent<GreenMan>().SetPosBySafe(safe);
if (!safe)
{
foreach (GameObject obj in needRemoveObjs)
{
obj.SetActive(true);
}
greenPerson.tag = "ZAW";
}
}
public void PanDuanSafe(bool safe) {
EventManager.Instance.emit("PanDuanSafe", this.safe == safe,this.safe);
}
public void SetSafeOperate(int index) {
safeOperate = index;
if (index == 0) {
EventManager.Instance.emit("SafeOperate",0);
Invoke("TransferObjs", 1);
} else if (index==1) {
greenPerson.tag = "ZAW";
remove = true;
EventManager.Instance.emit("SafeOperate",1);
}
}
void TransferObjs() {
person2.SetActive(true);
FindObjectOfType<CinemachineFreeLook>().LookAt = needTransferObjs[0].transform;
FindObjectOfType<CinemachineFreeLook>().Follow = needTransferObjs[0].transform;
foreach (GameObject obj in needTransferObjs)
{
obj.transform.position += new Vector3(2, 0, -40);
}
GameObject obj2 = Instantiate(Resources.Load<GameObject>("operate"));
obj2.GetComponent<Operate>().str = "2-将被救者转移到安全位置";
errorTip.SetActive(true);
errorTip.GetComponentInChildren<ErrorTip>().InitThis("恭喜通关",60);
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
}
}