using System; using System.Collections; using System.Collections.Generic; using Imagine.WebAR; using TriLibCore; using UnityEngine; using UnityEngine.UI; using static TaskConfig.windowItemGameObject; public class TaskManager : MonoBehaviour { public GameObject HtmlBG; public UserInfo myInfo; public ARCamera ar; public List tconfigs; public TaskConfig ntconfig; public RawImage bg; public RawImage imgbg; public RawImage centerbg; public RawImage centerbg2; public RawImage topbg; public GameObject prebg; public GameObject Closebt; public GameObject Closebt2; public Text dialogueText; public GameObject Main; public GameObject Sence; public GameObject daoju; public GameObject video; public GameObject allimg; public GameObject allimg2; public GameObject ar_1img; public GameObject ar_2img; public GameObject ar_1glb; public GameObject ar_2glb; public RawImage bigbg; public GameObject GamePIntu; public List daojulist; public ImageTracker itracker; public WorldTracker wtracker; public GameObject tuodongbg; public GameObject shibie; public GameObject Inputgo; public GameObject duihuakuang; TaskItem nowTaskItem; public GameObject xiansuo; public int nowTaskIndex; public int nowTaskCt; public GameObject main_click; private void Awake() { // PlayerPrefs.DeleteAll(); StartCoroutine(InitGame()); } public void saveindex(bool isFinish) { if (PlayerPrefs.GetInt("isend")!=1) { PlayerPrefs.SetInt("nowTaskCt", nowTaskCt); PlayerPrefs.SetInt("nowTaskIndex", nowTaskIndex); if (isFinish) { PlayerPrefs.SetInt("isend", 1); } } } private IEnumerator InitGame() { Main.SetActive(false); Sence.SetActive(false); // yield return new WaitForSeconds(1f); // ar.PauseCamera(); // yield return new WaitForSeconds(2f); yield return StartCoroutine(InitUser()); if (PlayerPrefs.GetInt("isend") != 1) { myInfo.taskIndex = PlayerPrefs.GetInt("nowTaskIndex"); myInfo.taskCt = PlayerPrefs.GetInt("nowTaskCt"); nowTaskIndex = myInfo.taskIndex; nowTaskCt = myInfo.taskCt; ntconfig = tconfigs[nowTaskCt]; nowTaskItem = ntconfig.TaskList[nowTaskIndex]; yield return StartCoroutine(checktaskSence(nowTaskItem)); } else { Main.SetActive(true); Sence.SetActive(false); } } bool isclickxumu; public void gotoxumu() { if (PlayerPrefs.GetInt("isend") == 1) { isclickxumu = true; nowTaskCt = 0; nowTaskIndex = -1; ntconfig = tconfigs[nowTaskCt]; nextTask(); Main.SetActive(false); Sence.SetActive(true); } } public void gotodadian() { isclickxumu = false; nowTaskCt = 1; nowTaskIndex = 8; ntconfig = tconfigs[nowTaskCt]; nextTask(); Main.SetActive(false); Sence.SetActive(true); } GameObject hc; public List items; private IEnumerator checktaskSence(TaskItem ti) { if(hc) { Destroy(hc); hc = null; } dialogueText.text = ti.info; if(iidex==1&& ti.info2!="") dialogueText.text = ti.info2; getTexture(ti.bgName, (tex) => { if (tex) { bg.texture = tex; bg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 1); } else { bg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 0); } }); getTexture(ti.imgName, (tex) => { if (tex) { imgbg.texture = tex; imgbg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 1); } else { imgbg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 0); } duihuakuang.SetActive(ti.centerName != "one_end"); }); getTexture(ti.centerName, (tex) => { if (tex) { centerbg.GetComponent().sizeDelta = new Vector2(tex.width, tex.height); centerbg.texture = tex; centerbg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 1); centerbg.gameObject.SetActive(true); centerbg.transform.localScale = new Vector3(0.95f, 0.95f, 0.95f); } else { centerbg.color = new Color(bg.color.r, bg.color.g, bg.color.b, 0); } }); GetBD(ti.perbName, (go) => { if(go) { go.SetActive(true); go.transform.parent = prebg.transform; go.transform.localPosition = Vector3.zero; go.transform.localEulerAngles = Vector3.zero; go.transform.localScale = Vector3.one; hc = go; } }); if(ti.type != TaskConfig.TaskType.ARTask) { bigbg.color = new Color(bigbg.color.r, bigbg.color.g, bigbg.color.b, 1); imgbg.color = new Color(imgbg.color.r, imgbg.color.g, imgbg.color.b, 1); } for (int i = 0; i < items.Count; i++) { if(ti.daojus.Count>i) { items[i].SetActive(ti.daojus[i].isshow); }else { items[i].SetActive(false); } } dialogueText.GetComponent