617 lines
18 KiB
C#
617 lines
18 KiB
C#
using DG.Tweening;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.Networking;
|
||
using UnityEngine.UI;
|
||
|
||
public class UITalkMain : UIBase
|
||
{
|
||
public Button btn1;//介绍性对话 暂时不做
|
||
public Button btn2;//临床检查 暂时不做
|
||
public Button btn3;//临床检查对话 暂时不做
|
||
public Button btn4;//诊断 测验
|
||
public Button btn5;//建议 测验
|
||
public Button btn6;//咨询结束
|
||
public Button btn7;//退出
|
||
|
||
public Button btn8;//右1 按钮
|
||
public Button btn9;//右2 按钮
|
||
public Button btn10;//右10 按钮
|
||
|
||
public Dropdown styleChoose;
|
||
public Button btn11;//视诊
|
||
public Button btn12;//触诊
|
||
public Button btn13;//叩诊
|
||
public Button btn14;//听诊器
|
||
public Button btn15;//神经系统
|
||
|
||
public GameObject buttom;
|
||
public Image bg;
|
||
|
||
public GameObject allStyle;
|
||
|
||
public Transform leftUI;
|
||
public Button showLeftbtn;
|
||
public int currentStep = 0;
|
||
|
||
public TextMeshProUGUI timeDown;
|
||
|
||
public TextMeshProUGUI bodyNum;
|
||
|
||
List<int> steps = new List<int>() { 7001, 7002, 7003, 7004, 7005, 7006, 7007 };
|
||
|
||
public Button sendDataBtn;
|
||
public TcpNet tcp;
|
||
|
||
private void Awake()
|
||
{
|
||
RefreshLeftBtnState(false);
|
||
sendDataBtn.onClick.AddListener(() =>
|
||
{
|
||
tcp = GameObject.Find("TCPPersonConnect").GetComponent<TcpNet>();
|
||
tcp.OnGetBodyNum(null);
|
||
});
|
||
btn1.onClick.AddListener(OpenTalk);
|
||
btn2.onClick.AddListener(ShowCheckModel);
|
||
btn3.onClick.AddListener(OpenTalk2);
|
||
btn4.onClick.AddListener(OpenCheckTest1);
|
||
btn5.onClick.AddListener(OpenCheckTest2);
|
||
btn6.onClick.AddListener(OpenCheckTest3);
|
||
|
||
btn1.gameObject.SetActive(isHaveThisStep(7001));
|
||
btn2.gameObject.SetActive(isHaveThisStep(7002));
|
||
btn3.gameObject.SetActive(isHaveThisStep(7003));
|
||
btn4.gameObject.SetActive(isHaveThisStep(7004));
|
||
btn5.gameObject.SetActive(isHaveThisStep(7005));
|
||
btn6.gameObject.SetActive(isHaveThisStep(7006));
|
||
|
||
btn7.onClick.AddListener(OpenCheckTest4);
|
||
btn8.onClick.AddListener(OpenUIHistory);
|
||
|
||
btn10.onClick.AddListener(() =>
|
||
{
|
||
RefreshUI();
|
||
UIManager.Instance.DestoryUI(UIType.UITalkMain);
|
||
UIManager.Instance.ShowAllUI();
|
||
TcpConnect.Instance.OnDisable();
|
||
});
|
||
//styleChoose.onValueChanged.AddListener(ChangeStyle);
|
||
//List<Dropdown.OptionData> listOptions = new List<Dropdown.OptionData>();
|
||
//listOptions.Add(new Dropdown.OptionData("站立正面"));
|
||
//listOptions.Add(new Dropdown.OptionData("站立背面"));
|
||
//listOptions.Add(new Dropdown.OptionData("坐正面"));
|
||
//listOptions.Add(new Dropdown.OptionData("坐背面"));
|
||
//listOptions.Add(new Dropdown.OptionData("躺"));
|
||
//listOptions.Add(new Dropdown.OptionData("趴"));
|
||
//styleChoose.AddOptions(listOptions);
|
||
|
||
btn11.onClick.AddListener(ZhenDuan1);
|
||
btn12.onClick.AddListener(ZhenDuan2);
|
||
btn13.onClick.AddListener(ZhenDuan3);
|
||
btn14.onClick.AddListener(ZhenDuan4);
|
||
btn15.onClick.AddListener(ZhenDuan5);
|
||
showLeftbtn.onClick.AddListener(ShowLeftUI);
|
||
DataManager.Instance.currentAnswerQuestion.Clear();
|
||
GetAllStyle();
|
||
GetBodyNum();
|
||
//介绍性对话
|
||
//DataManager.Instance.currentBGType = 1;
|
||
//UIManager.Instance.OpenUI(UIType.UITalk);
|
||
styleChoose.onValueChanged.AddListener(ChangeStyle2);
|
||
EventCenter.dispatcher.AddListener(MsgType.OnGetBodyNum, OnGetBodyNum);
|
||
EventCenter.dispatcher.AddListener(MsgType.OnGetAllStyle, OnGetAllStyle);
|
||
var temp = DataManager.Instance.currentDisDistance;
|
||
for (int i = 0; i < steps.Count; i++)
|
||
{
|
||
if (temp.ContainsKey(steps[i]))
|
||
{
|
||
if (temp[steps[i]])
|
||
currentStep = steps[i];
|
||
}
|
||
}
|
||
if (DataManager.Instance.RoomPersonsItem == null)
|
||
{
|
||
Debug.LogError("未配置模拟人IP端口数据 连接失败 请重启");
|
||
return;
|
||
}
|
||
if (string.IsNullOrEmpty(DataManager.Instance.RoomPersonsItem.ip) ||
|
||
string.IsNullOrEmpty(DataManager.Instance.RoomPersonsItem.port))
|
||
{
|
||
Debug.Log("未配置模拟人IP端口数据 连接失败 请重启");
|
||
}
|
||
else
|
||
{
|
||
string ip = DataManager.Instance.RoomPersonsItem.ip;
|
||
int port = int.Parse(DataManager.Instance.RoomPersonsItem.port);
|
||
TcpConnect.Instance.InitConnect(ip, port);
|
||
}
|
||
}
|
||
|
||
private void OnGetAllStyle(Message evt)
|
||
{
|
||
InitStyleDropDown();
|
||
}
|
||
|
||
public bool isOpenThisStep(int num)
|
||
{
|
||
var temp = DataManager.Instance.currentDisDistance;
|
||
if (temp.ContainsKey(num)) return temp[num];
|
||
return false;
|
||
}
|
||
|
||
public bool isHaveThisStep(int num)
|
||
{
|
||
var temp = DataManager.Instance.currentDisDistance;
|
||
if (temp.ContainsKey(num)) return true;
|
||
return false;
|
||
}
|
||
|
||
private void GetBodyNum()
|
||
{
|
||
var data = DataManager.Instance.currentSelectPeople;
|
||
string url = "http://122.112.171.137:85/api/cases/vital/signs/list?relationId=" + data.id;
|
||
StartCoroutine(GetBodyN(url));
|
||
}
|
||
|
||
IEnumerator GetBodyN(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.ParseBodyNum(receiveContent);
|
||
|
||
}
|
||
}
|
||
|
||
private void OnGetBodyNum(Message evt)
|
||
{
|
||
if (DataManager.Instance.bodyNum.Count > 0)
|
||
{
|
||
var data = DataManager.Instance.bodyNum[0];
|
||
bodyNum.text = "体温:" + data.bodyTemperature + "\n血压:" + data.bloodPressure;
|
||
}
|
||
}
|
||
|
||
private void ChangeStyle2(int arg0)
|
||
{
|
||
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
||
switch (arg0)
|
||
{
|
||
case 0:
|
||
//坐正面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.sit_front);
|
||
break;
|
||
case 1:
|
||
//坐背面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.sit_back);
|
||
break;
|
||
case 2:
|
||
//站正面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.stand_front);
|
||
break;
|
||
case 3:
|
||
//躺
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.lie_front);
|
||
break;
|
||
}
|
||
}
|
||
|
||
void GetAllStyle()
|
||
{
|
||
var data = DataManager.Instance.currentData;
|
||
string url = "http://122.112.171.137:85/api/diagnosis/clinical/getPostureByDiagnosisId/" + data.id;
|
||
StartCoroutine(GetStyle(url));
|
||
}
|
||
|
||
IEnumerator GetStyle(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.ParseAllStyle(receiveContent);
|
||
|
||
}
|
||
}
|
||
|
||
private float totalTime;
|
||
private int currentRunTime = 0;
|
||
int hour = 0;
|
||
int minute = 0;
|
||
int seconds = 0;
|
||
private void Update()
|
||
{
|
||
totalTime += Time.deltaTime;
|
||
if (totalTime >= 1)
|
||
{
|
||
totalTime = 0;
|
||
currentRunTime++;
|
||
hour = currentRunTime / 3600;
|
||
minute = currentRunTime % 3600 / 60;
|
||
seconds = currentRunTime % 3600 % 60;
|
||
timeDown.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hour, minute, seconds); ;
|
||
}
|
||
}
|
||
|
||
public void RefreshLeftBtnState(bool isAdd)
|
||
{
|
||
if (isAdd)
|
||
{
|
||
}
|
||
btn1.interactable = isOpenThisStep(7001);
|
||
btn2.interactable = isOpenThisStep(7002);
|
||
btn3.interactable = isOpenThisStep(7003);
|
||
btn4.interactable = isOpenThisStep(7004);
|
||
btn5.interactable = isOpenThisStep(7005);
|
||
btn6.interactable = isOpenThisStep(7006);
|
||
btn7.interactable = isOpenThisStep(7007);
|
||
//btn1.interactable = true;
|
||
//btn2.interactable = false;
|
||
//btn3.interactable = false;
|
||
//btn4.interactable = false;
|
||
//btn5.interactable = false;
|
||
//btn6.interactable = false;
|
||
//btn7.interactable = false;
|
||
//if (currentStep >= 6)
|
||
//{
|
||
// btn7.interactable = true;
|
||
//}
|
||
//if (currentStep >= 5)
|
||
//{
|
||
// btn6.interactable = true;
|
||
//}
|
||
//if (currentStep >= 4)
|
||
//{
|
||
// btn5.interactable = true;
|
||
//}
|
||
//if (currentStep >= 3)
|
||
//{
|
||
// btn4.interactable = true;
|
||
//}
|
||
//if (currentStep >= 2)
|
||
//{
|
||
// btn3.interactable = true;
|
||
//}
|
||
//if (currentStep >= 1)
|
||
//{
|
||
// btn2.interactable = true;
|
||
//}
|
||
}
|
||
|
||
void ShowLeftUI()
|
||
{
|
||
if (leftUI.localPosition.x >= 0)
|
||
{
|
||
|
||
leftUI.DOLocalMoveX(-300f, 1f);
|
||
}
|
||
else
|
||
{
|
||
leftUI.DOLocalMoveX(0f, 1f);
|
||
}
|
||
}
|
||
|
||
void RefreshUI()
|
||
{
|
||
styleChoose.gameObject.SetActive(false);
|
||
allStyle.SetActive(false);
|
||
UIManager.Instance.DestoryUI(UIType.UIClickBody);
|
||
}
|
||
|
||
private void OpenUIHistory()
|
||
{
|
||
RefreshUI();
|
||
UIManager.Instance.OpenUI(UIType.UIHistory);
|
||
}
|
||
|
||
void InitStyleDropDown()
|
||
{
|
||
var data = DataManager.Instance.currentStyleItem;
|
||
List<Dropdown.OptionData> listOptions = new List<Dropdown.OptionData>();
|
||
for (int i = 0; i < data.Count; i++)
|
||
{
|
||
var item = data[i];
|
||
switch (item.postureId)
|
||
{
|
||
case 1:
|
||
//坐 正面
|
||
listOptions.Add(new Dropdown.OptionData("坐"));
|
||
break;
|
||
case 2:
|
||
//坐背面
|
||
listOptions.Add(new Dropdown.OptionData("坐-背面"));
|
||
break;
|
||
case 3:
|
||
//站立 正面
|
||
listOptions.Add(new Dropdown.OptionData("站立-正面"));
|
||
break;
|
||
case 4:
|
||
//躺
|
||
listOptions.Add(new Dropdown.OptionData("平躺"));
|
||
break;
|
||
|
||
}
|
||
}
|
||
styleChoose.AddOptions(listOptions);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 编辑模式下 下拉框使用
|
||
/// </summary>
|
||
public void ChangeStyle()
|
||
{
|
||
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
||
switch (styleChoose.itemText.text)
|
||
{
|
||
case "站立正面":
|
||
//站立正面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.stand_front);
|
||
break;
|
||
case "站立背面":
|
||
//站立背面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.stand_back);
|
||
break;
|
||
case "坐正面":
|
||
//坐正面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.sit_front);
|
||
break;
|
||
case "坐背面":
|
||
//坐背面
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.sit_back);
|
||
break;
|
||
case "躺":
|
||
//躺
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.lie_front);
|
||
break;
|
||
case "趴":
|
||
//趴
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.lie_back);
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void ZhenDuan1()
|
||
{
|
||
DataManager.Instance.currentCheckTool = CheckToolType.Look;
|
||
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
||
UIManager.Instance.OpenUI(UIType.UIClickBody);
|
||
}
|
||
|
||
private void ZhenDuan2()
|
||
{
|
||
DataManager.Instance.currentCheckTool = CheckToolType.Touch;
|
||
|
||
ShowZhenDuan();
|
||
}
|
||
private void ZhenDuan3()
|
||
{
|
||
DataManager.Instance.currentCheckTool = CheckToolType.Per;
|
||
|
||
ShowZhenDuan();
|
||
}
|
||
private void ZhenDuan4()
|
||
{
|
||
DataManager.Instance.currentCheckTool = CheckToolType.Listen;
|
||
ShowZhenDuan();
|
||
|
||
}
|
||
private void ZhenDuan5()
|
||
{
|
||
DataManager.Instance.currentCheckTool = CheckToolType.Nerve;
|
||
ShowZhenDuan();
|
||
}
|
||
|
||
void ShowZhenDuan()
|
||
{
|
||
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
||
UIBase uIBase = UIManager.Instance.GetUIBase(UIType.UIClickBody);
|
||
if (uIBase != null)
|
||
{
|
||
UIClickBody uIClickBody = (UIClickBody)uIBase;
|
||
uIClickBody.Refrush();
|
||
}
|
||
else
|
||
{
|
||
UIManager.Instance.OpenUI(UIType.UIClickBody);
|
||
|
||
}
|
||
}
|
||
|
||
void AddStep()
|
||
{
|
||
var temp = DataManager.Instance.currentDisDistance;
|
||
int tempNum = currentStep + 1;
|
||
if (temp.ContainsKey(tempNum))
|
||
{
|
||
if (!temp[currentStep]) return;
|
||
if (!temp[tempNum])
|
||
{
|
||
currentStep = tempNum;
|
||
temp[tempNum] = true;
|
||
RefreshLeftBtnState(true);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private void ShowCheckModel()
|
||
{
|
||
AddStep();
|
||
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
styleChoose.gameObject.SetActive(true);
|
||
|
||
allStyle.SetActive(true);
|
||
DataManager.Instance.GetGameData().ShowCheckMan(PeopleStyle.sit_front);
|
||
|
||
StartCoroutine(OpenClickBody());
|
||
}
|
||
|
||
IEnumerator OpenClickBody()
|
||
{
|
||
yield return new WaitForSeconds(1f);
|
||
UIManager.Instance.OpenUI(UIType.UIClickBody);
|
||
|
||
}
|
||
|
||
|
||
private void OpenTalk2()
|
||
{
|
||
AddStep();
|
||
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
DataManager.Instance.GetGameData().ShowTalkMan();
|
||
DataManager.Instance.currentBGType = 3;
|
||
DataManager.Instance.currentTalk?.Clear();
|
||
UIManager.Instance.OpenUI(UIType.UITalk);
|
||
}
|
||
|
||
private void OpenTalk()
|
||
{
|
||
AddStep();
|
||
|
||
|
||
|
||
RefreshLeftBtnState(true);
|
||
RefreshUI();
|
||
|
||
DataManager.Instance.GetGameData().ShowTalkMan();
|
||
DataManager.Instance.currentBGType = 2;
|
||
DataManager.Instance.currentTalk?.Clear();
|
||
UIManager.Instance.OpenUI(UIType.UITalk);
|
||
|
||
|
||
|
||
}
|
||
|
||
private void GetPeopleQuestion()
|
||
{
|
||
//http://122.112.171.137:85/api/problem/answer/getProblemByBackgroundCode/{1}/{1}//诊断 建议 咨询结束
|
||
//http://122.112.171.137:85/api/problem/answer/getProblemByBackgroundCodeAll{diagnosisId}//所有问题
|
||
//临床检查问题
|
||
|
||
string url = string.Format("http://122.112.171.137:85/api/problem/answer/getProblemByBackgroundCode/{0}/{1}", DataManager.Instance.currentData.id,
|
||
(int)DataManager.Instance.currentQuesitionType);
|
||
StartCoroutine(Get(url));
|
||
}
|
||
|
||
IEnumerator Get(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.ParsePeopleQuestion(receiveContent);
|
||
|
||
}
|
||
}
|
||
|
||
|
||
private void OpenCheckTest1()
|
||
{
|
||
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
|
||
DataManager.Instance.currentQuesitionType = QuestionType.DIAGNOSE_PROBLEM;
|
||
ShowCheckTest();
|
||
GetPeopleQuestion();
|
||
|
||
}
|
||
|
||
private void OpenCheckTest2()
|
||
{
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
|
||
DataManager.Instance.currentQuesitionType = QuestionType.SUGGEST_PROBLEM;
|
||
ShowCheckTest();
|
||
GetPeopleQuestion();
|
||
|
||
}
|
||
|
||
private void OpenCheckTest3()
|
||
{
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
|
||
DataManager.Instance.currentQuesitionType = QuestionType.TALK_OVER;
|
||
ShowCheckTest();
|
||
GetPeopleQuestion();
|
||
|
||
}
|
||
|
||
void ShowCheckTest()
|
||
{
|
||
RefreshUI();
|
||
|
||
if (UIManager.Instance.isShow(UIType.UICheckTest))
|
||
{
|
||
UICheckTest ui = UIManager.Instance.GetUIBase(UIType.UICheckTest).GetComponent<UICheckTest>();
|
||
ui.RefreshData();
|
||
}
|
||
else
|
||
{
|
||
UIManager.Instance.OpenUI(UIType.UICheckTest);
|
||
}
|
||
}
|
||
|
||
private void OpenCheckTest4()
|
||
{
|
||
RefreshLeftBtnState(true);
|
||
|
||
RefreshUI();
|
||
|
||
DataManager.Instance.currentQuesitionType = QuestionType.EXIT_PROBLEM;
|
||
//UIManager.Instance.DestoryUI(UIType.UITalkMain);
|
||
ShowCheckTest();
|
||
//UIManager.Instance.OpenUI(UIType.UIQuitAll);
|
||
GetPeopleQuestion();
|
||
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
EventCenter.dispatcher.RemoveListener(MsgType.OnGetBodyNum, OnGetBodyNum);
|
||
|
||
}
|
||
}
|