123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using LitJson;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Events;
- using static LangChaoJiekou;
- public class XunJianInitialize :MonoSingleton<XunJianInitialize>
- {
- public XJTaskItem tastItem;
- public GameObject contentUI;
- public XunJianDetails xjDetails;
- public GameObject retractBtn;
- public GameObject expandBtn;
- public GameObject defaultUI;
- public GameObject endUI;
- public GameObject homeEndUI;
-
- public XJTaskItem checkTaskItem;
- private bool isScale;
- private bool isInit;
- private List<XJTaskItem> listItem;
- public UnityEvent OnReset = new UnityEvent(); // ÖØÖÃʼþ
- private void Start()
- {
- isInit = false;
- listItem = new List<XJTaskItem>();
- isScale = false;
- }
- private void OnEnable()
- {
- defaultUI.SetActive(false);
- endUI.SetActive(false);
- homeEndUI.SetActive(false);
- // Éϱ¨Ñ²¼ì¿ªÊ¼
- JsonData data = new JsonData();
- data["id"] = XunJianAllData.taskItem.distributeId;
- StartCoroutine(LangChaoJiekou.Instance.SendHttp(LangChaoJiekou.execute, data.ToJson(), (msg) =>
- {
- Debug.Log("DGJ ==> /record/execute " + msg);
-
- }, "application/json",false));
- }
- private void Update()
- {
- if(!isInit && XunJianAllData.listRoomItem!=null)
- {
- isInit = true;
- InitializeData();
- }
- #if UNITY_EDITOR
- //if (Test) return;
- return;
- #endif
- OnReset?.Invoke();
- }
- public void InitializeData( )
- {
-
- for (int i = 0; i < XunJianAllData.listRoomItem.Count; i++)
- {
- GameObject item = GameObject.Instantiate(tastItem.gameObject, tastItem.transform.parent);
- item.SetActive(true);
- item.GetComponent<XJTaskItem>().InitData(i+1, XunJianAllData.listRoomItem[i] ,xjDetails);
- listItem.Add(item.GetComponent<XJTaskItem>());
- }
- if (listItem!=null&&listItem.Count > 0)
- {
- SetCheckIte(listItem[0]);
- }
-
- }
- public void GoHome()
- {
-
- xjDetails.SubmitData();
- homeEndUI.SetActive(true);
-
- }
-
- public void Complete()
- {
- for (int i = 0; i < listItem.Count; i++)
- {
- if(listItem[i].itemData.recd==null)
- {
- defaultUI.SetActive(true);
- return;
- }
- }
- endUI.SetActive(true);
- }
- public void LastItem()
- {
- for (int i = 0; i < listItem.Count; i++)
- {
- if(checkTaskItem.itemData.inspItemId == listItem[i].itemData.inspItemId)
- {
- int num = i - 1;
-
- if (num>=0)
- {
- SetCheckIte(listItem[num]);
- }
- else
- {
- SetCheckIte(listItem[i]);
- }
-
- break;
- }
- }
- }
- public void NextItem()
- {
- for (int i = 0; i < listItem.Count; i++)
- {
- if (checkTaskItem.itemData.inspItemId == listItem[i].itemData.inspItemId)
- {
- int num = i + 1;
-
- if (num < listItem.Count)
- {
- SetCheckIte(listItem[num]);
- }
- else
- {
- SetCheckIte(listItem[i]);
- }
-
- break;
- }
- }
- }
- public int GetCheckItemNum()
- {
- if (checkTaskItem == null)
- return -1;
- for (int i = 0; i < listItem.Count; i++)
- {
- if (checkTaskItem.itemData.inspItemId == listItem[i].itemData.inspItemId)
- {
- return i+1;
-
- }
- }
- return -2;
- }
- public void SetCheckIte(XJTaskItem item)
- {
- if (checkTaskItem != null)
- {
- checkTaskItem.numText.color = Color.white;
- if(checkTaskItem.itemData.recd==null)
- {
- checkTaskItem.imageBG.SetActive(false);
- }
- }
- checkTaskItem = item;
- xjDetails.InitData(item.itemData);
- checkTaskItem.numText.color = Color.yellow;
- checkTaskItem.imageBG.SetActive(true);
- }
- public void SetScaleFunction()
- {
- contentUI.SetActive(isScale);
- xjDetails.gameObject.SetActive(isScale);
- retractBtn.SetActive(isScale);
- isScale = !isScale;
- expandBtn.SetActive(isScale);
- }
- public void back()
- {
- ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
- }
- }
|