ISAP/Assets/Scripts/UI/UIClickBody.cs

425 lines
14 KiB
C#
Raw Blame History

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;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using static UnityEditor.Progress;
public class UIClickBody : UIBase
{
public Button btn;
public Transform currentModel;
public Transform morePanel;
public Button moreBtn;
public Transform morePanel2;
<<<<<<< HEAD
=======
BodyInfoDataItem currentData;
//Dictionary<int,>
List<GameObject> moreBtns;
List<GameObject> moreBtns2;
List<GameObject> posBtns;
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
BodyInfoDataItem currentData;
//Dictionary<int,>
List<GameObject> moreBtns;
List<GameObject> moreBtns2;
List<GameObject> posBtns;
public Transform posParent;
private void Awake()
{
var allModel = DataManager.Instance.GetGameData().allModel;
for (int i = 0; i < allModel.Length; i++)
{
if (allModel[i].gameObject.activeSelf)
{
currentModel = allModel[i].transform;
}
}
moreBtns = new List<GameObject>();
moreBtns2 = new List<GameObject>();
posBtns = new List<GameObject>();
moreBtns.Clear();
moreBtns2.Clear();
posBtns.Clear();
EventCenter.dispatcher.AddListener(MsgType.OnGetBodyInfo, OnGetBodyInfo);
<<<<<<< HEAD
EventCenter.dispatcher.AddListener(MsgType.OnGetBodyPosInfo, OnGetBodyPosInfo);
=======
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
Refrush();
}
public void Refrush()
{
int checkType = (int)DataManager.Instance.currentCheckTool;
int styleType = (int)DataManager.Instance.currentPeopleStyle;
int diagnosisID = DataManager.Instance.currentData.id;
string url = string.Format("http://122.112.171.137:85/api/diagnosis/clinical/getClinicalCheckResult?checkType={0}&diagnosisId={1}&postureId={2}", checkType, diagnosisID, styleType);
morePanel.gameObject.SetActive(false);
StartCoroutine(GetBodyPos(url));
}
private void OnDestroy()
{
EventCenter.dispatcher.RemoveListener(MsgType.OnGetBodyInfo, OnGetBodyInfo);
<<<<<<< HEAD
EventCenter.dispatcher.RemoveListener(MsgType.OnGetBodyPosInfo, OnGetBodyPosInfo);
}
private void OnGetBodyPosInfo(Message evt)
{
var list = DataManager.Instance.bodyPosInfos;
List<FileInfoData> listData = new List<FileInfoData>();
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
FileInfoData data = new FileInfoData();
data.type = (FileType)item.type;
data.content = item.content;
data.url = item.fileUrl;
data.question = item.problemInfoResp;
listData.Add(data);
}
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
UIFile fileui = (UIFile)ui;
fileui.Init(listData);
//switch (item.type)
//{
// case 1:
// //<2F>ı<EFBFBD>
// //fileui.Init(FileType.text,FileFather.BodyInfo);
// break;
// case 2:
// //ͼƬ
// //fileui.Init(FileType.image, FileFather.BodyInfo);
// break;
// case 3:
// //<2F><>Ƶ
// //fileui.Init(FileType.video, FileFather.BodyInfo);
// break;
// case 4:
// //<2F><><EFBFBD><EFBFBD>
// //fileui.Init(FileType.music, FileFather.BodyInfo);
// break;
// case 5:
// //<2F><><EFBFBD><EFBFBD>
// //fileui.Init(FileType.URL, FileFather.BodyInfo);
// break;
//}
}
//չʾ<D5B9><CABE>λ<EFBFBD><CEBB>ť
private void OnGetBodyInfo(Message evt)
{
for (int i = 0; i < posBtns.Count; i++)
{
=======
}
private void OnGetBodyInfo(Message evt)
{
for (int i = 0; i < posBtns.Count; i++)
{
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
GameObject.Destroy(posBtns[i].gameObject);
}
var data = DataManager.Instance.bodyInfoData;
foreach (var item in data)
{
GameObject root = GetCurrentPos(item.positionId);
<<<<<<< HEAD
var newUI = GameObject.Instantiate(btn, posParent);
=======
var newUI = GameObject.Instantiate(btn, this.transform);
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
posBtns.Add(newUI.gameObject);
if (root != null)
{
Vector2 player2DPosition = Camera.main.WorldToScreenPoint(root.transform.position);
newUI.transform.position = player2DPosition;
newUI.gameObject.SetActive(true);
newUI.onClick.AddListener(() =>
{
<<<<<<< HEAD
ClearBtnsList();
morePanel.transform.position = newUI.transform.position + new Vector3(170f, 0f);
=======
morePanel.transform.position = newUI.transform.position + new Vector3(105f, -40f);
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
morePanel.gameObject.SetActive(true);
//int x = i;
//currentData = data[x];
ShowMorePanel(data.IndexOf(item));
});
}
}
}
void ClearBtnsList()
{
for (int i = 0; i < moreBtns.Count; i++)
{
GameObject.Destroy(moreBtns[i].gameObject);
}
for (int i = 0; i < moreBtns2.Count; i++)
{
GameObject.Destroy(moreBtns2[i].gameObject);
}
}
<<<<<<< HEAD
//һ<><D2BB><EFBFBD>˵<EFBFBD>
void ShowMorePanel(int index)
{
=======
void ShowMorePanel(int index)
{
ClearBtnsList();
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
var data = DataManager.Instance.bodyInfoData;
var list = data[index].clinicalProjectPositionRespList;
foreach (var item in list)
{
Button newUI = GameObject.Instantiate(moreBtn, morePanel);
newUI.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = item.toolName;
newUI.gameObject.SetActive(true);
newUI.onClick.AddListener(() =>
{
<<<<<<< HEAD
for (int i = 0; i < moreBtns2.Count; i++)
{
GameObject.Destroy(moreBtns2[i].gameObject);
}
morePanel2.transform.position = newUI.transform.position + new Vector3(320f, -20f);
if (!morePanel2.gameObject.activeSelf)
{
morePanel2.gameObject.SetActive(true);
ShowMorePane2(index, list.IndexOf(item));
=======
morePanel2.transform.position = newUI.transform.position + new Vector3(-160f, 0f);
if (!morePanel2.gameObject.activeSelf)
{
morePanel2.gameObject.SetActive(true);
//morePanel.gameObject.SetActive(false);
ShowMorePane2(index, list.IndexOf(item));
moreBtns.Add(newUI.gameObject);
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
}
});
moreBtns.Add(newUI.gameObject);
}
<<<<<<< HEAD
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
void ShowMorePane2(int index, int index2)
{
var data = DataManager.Instance.bodyInfoData;
var list = data[index].clinicalProjectPositionRespList[index2].clinicalProjectCheckRespList;
foreach (var item in list)
{
Button newUI = GameObject.Instantiate(moreBtn, morePanel2);
newUI.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = item.checkName;
=======
//for (int i = 0; i < list.Count; i++)
//{
// Button newUI = GameObject.Instantiate(moreBtn, morePanel);
// newUI.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = list[i].toolName;
// newUI.gameObject.SetActive(true);
// newUI.onClick.AddListener(() =>
// {
// morePanel2.transform.position = newUI.transform.position + new Vector3(-160f, 0f);
// morePanel2.gameObject.SetActive(true);
// //morePanel.gameObject.SetActive(false);
// ShowMorePane2(data.IndexOf(item));
// });
// moreBtns.Add(newUI.gameObject);
//}
}
void ShowMorePane2(int index, int index2)
{
var data = DataManager.Instance.bodyInfoData;
var list = data[index].clinicalProjectPositionRespList[0].clinicalProjectCheckRespList;
for (int i = 0; i < list.Count; i++)
{
Button newUI = GameObject.Instantiate(moreBtn, morePanel2);
newUI.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = list[i].checkName;
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
newUI.gameObject.SetActive(true);
newUI.onClick.AddListener(() =>
{
morePanel2.transform.position = newUI.transform.position + new Vector3(50f, 0f);
morePanel.gameObject.SetActive(false);
morePanel2.gameObject.SetActive(false);
<<<<<<< HEAD
ShowTwiceMenuInfo(item);
=======
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
//ShowMorePanel(data.IndexOf(item));
});
moreBtns2.Add(newUI.gameObject);
}
<<<<<<< HEAD
//for (int i = 0; i < list.Count; i++)
//{
// Button newUI = GameObject.Instantiate(moreBtn, morePanel2);
// newUI.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = list[i].checkName;
// newUI.gameObject.SetActive(true);
// newUI.onClick.AddListener(() =>
// {
// morePanel2.transform.position = newUI.transform.position + new Vector3(50f, 0f);
=======
}
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
// morePanel.gameObject.SetActive(false);
// morePanel2.gameObject.SetActive(false);
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>" + list[i].projectId);
<<<<<<< HEAD
// //ShowMorePanel(data.IndexOf(item));
// });
// moreBtns2.Add(newUI.gameObject);
//}
}
void ShowTwiceMenuInfo(ClinicalProjectCheckRespListItem data)
{
//http://122.112.171.137:85/api/diagnosis/clinical/getClinicalInfo/{projectId}
Debug.Log("http://122.112.171.137:85/api/diagnosis/clinical/getClinicalInfo/" + data.projectId);
string url = "http://122.112.171.137:85/api/diagnosis/clinical/getClinicalInfo/" + data.projectId;
StartCoroutine(ShowPosInfo(url));
}
IEnumerator ShowPosInfo(string url)
{
UnityWebRequest request = UnityWebRequest.Get(url);
yield return request.SendWebRequest();
if (request.isHttpError || request.isNetworkError)
{
Debug.LogError(request.error);
}
else
{
string receiveContent = request.downloadHandler.text;
byte[] datas = Encoding.UTF8.GetBytes(receiveContent);
receiveContent = Encoding.UTF8.GetString(datas, 0, datas.Length);
//JsonInfo jsonInfo = JsonMapper.ToObject<JsonInfo>(receiveContent);
DataParse.Instance.ParseBodyPosInfo(receiveContent);
}
=======
void MoreBtnInit()
{
var data = DataManager.Instance.bodyInfoData;
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
}
GameObject GetCurrentPos(int id)
{
//currentModel
string name = "";
if (id == 1001 || id == 3001)
{
name = "<22><>״<EFBFBD><D7B4>";
}
else if (id == 1002 || id == 2002 || id == 3002 || id == 4001)
{
name = "<22>ز<EFBFBD>";
}
else if (id == 1003 || id == 2003 || id == 3003 || id == 4002)
{
name = "<22><>֫";
}
else if (id == 1004 || id == 2004 || id == 3004 || id == 4003)
{
name = "<22><><EFBFBD><EFBFBD>";
}
else if (id == 1005 || id == 3005 || id == 4004)
{
name = "<22>鷿";
}
else if (id == 1006 || id == 3006)
{
name = "<22><>֫";
}
else if (id == 1007 || id == 3007 || id == 4006)
{
name = "<22><><EFBFBD><EFBFBD>";
}
else if (id == 1008 || id == 2005 || id == 3008 || id == 4007)
{
name = <><CDB7>";
}
else if (id == 2001)
{
name = "<22><><EFBFBD><EFBFBD>";
}
else if (id == 4005)
{
name = "<22>貿";
}
if (currentModel != null)
{
<<<<<<< HEAD
if (currentModel.Find(name).gameObject != null)
{
return currentModel.Find(name).gameObject;
}
return null;
=======
return currentModel.Find(name).gameObject;
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
}
else
{
return null;
}
}
<<<<<<< HEAD
=======
>>>>>>> f7d047a43985d8f30df80a230201c233e8660fd1
IEnumerator GetBodyPos(string url)
{
UnityWebRequest request = UnityWebRequest.Get(url);
yield return request.SendWebRequest();
if (request.isHttpError || request.isNetworkError)
{
Debug.LogError(request.error);
}
else
{
string receiveContent = request.downloadHandler.text;
byte[] datas = Encoding.UTF8.GetBytes(receiveContent);
receiveContent = Encoding.UTF8.GetString(datas, 0, datas.Length);
//JsonInfo jsonInfo = JsonMapper.ToObject<JsonInfo>(receiveContent);
DataParse.Instance.ParseBodyInfo(receiveContent);
}
}
}