351 lines
9.5 KiB
C#
351 lines
9.5 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 TextMeshProUGUI 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;
|
|
|
|
private void Awake()
|
|
{
|
|
RefreshLeftBtnState(false);
|
|
|
|
btn1.onClick.AddListener(OpenTalk);
|
|
btn2.onClick.AddListener(ShowCheckModel);
|
|
btn3.onClick.AddListener(OpenTalk2);
|
|
btn4.onClick.AddListener(OpenCheckTest1);
|
|
btn5.onClick.AddListener(OpenCheckTest2);
|
|
btn6.onClick.AddListener(OpenCheckTest3);
|
|
btn7.onClick.AddListener(OpenCheckTest4);
|
|
btn8.onClick.AddListener(OpenUIHistory);
|
|
|
|
btn10.onClick.AddListener(() =>
|
|
{
|
|
RefreshUI();
|
|
UIManager.Instance.DestoryUI(UIType.UITalkMain);
|
|
UIManager.Instance.ShowAllUI();
|
|
});
|
|
//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(ZhenDuan);
|
|
btn12.onClick.AddListener(ZhenDuan);
|
|
btn13.onClick.AddListener(ZhenDuan);
|
|
btn14.onClick.AddListener(ZhenDuan);
|
|
btn15.onClick.AddListener(ZhenDuan);
|
|
showLeftbtn.onClick.AddListener(ShowLeftUI);
|
|
GetPeopleQuestion();
|
|
DataManager.Instance.currentBGType = 1;
|
|
DataManager.Instance.currentAnswerQuestion.Clear();
|
|
UIManager.Instance.OpenUI(UIType.UITalk);
|
|
}
|
|
|
|
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); ;
|
|
}
|
|
}
|
|
|
|
void RefreshLeftBtnState(bool isAdd)
|
|
{
|
|
if (isAdd)
|
|
{
|
|
}
|
|
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()
|
|
{
|
|
allStyle.SetActive(false);
|
|
UIManager.Instance.DestoryUI(UIType.UIClickBody);
|
|
}
|
|
|
|
private void OpenUIHistory()
|
|
{
|
|
RefreshUI();
|
|
UIManager.Instance.OpenUI(UIType.UIHistory);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑模式下 下拉框使用
|
|
/// </summary>
|
|
public void ChangeStyle()
|
|
{
|
|
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
|
switch (styleChoose.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 ZhenDuan()
|
|
{
|
|
UIManager.Instance.DestoryUI(UIType.UIHistory);
|
|
UIManager.Instance.OpenUI(UIType.UIClickBody);
|
|
}
|
|
|
|
private void ShowCheckModel()
|
|
{
|
|
if (currentStep < 2)
|
|
currentStep++;
|
|
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
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()
|
|
{
|
|
if (currentStep < 3)
|
|
currentStep++;
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
DataManager.Instance.GetGameData().ShowTalkMan();
|
|
DataManager.Instance.currentBGType = 3;
|
|
DataManager.Instance.currentTalk.Clear();
|
|
UIManager.Instance.OpenUI(UIType.UITalk);
|
|
}
|
|
|
|
private void OpenTalk()
|
|
{
|
|
if (currentStep < 1)
|
|
currentStep++;
|
|
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 = "http://122.112.171.137:85/api/problem/answer/getProblemByBackgroundCode/1/1";
|
|
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()
|
|
{
|
|
if (currentStep < 4)
|
|
currentStep++;
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
|
|
DataManager.Instance.currentQuesitionType = QuestionType.CLINICAL_PROBLEM;
|
|
ShowCheckTest();
|
|
}
|
|
|
|
private void OpenCheckTest2()
|
|
{
|
|
if (currentStep < 5)
|
|
currentStep++;
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
|
|
DataManager.Instance.currentQuesitionType = QuestionType.DIAGNOSE_PROBLEM;
|
|
ShowCheckTest();
|
|
|
|
}
|
|
|
|
private void OpenCheckTest3()
|
|
{
|
|
if (currentStep < 6)
|
|
currentStep++;
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
|
|
DataManager.Instance.currentQuesitionType = QuestionType.SUGGEST_PROBLEM;
|
|
ShowCheckTest();
|
|
}
|
|
|
|
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()
|
|
{
|
|
if (currentStep < 7)
|
|
currentStep++;
|
|
RefreshLeftBtnState(true);
|
|
|
|
RefreshUI();
|
|
|
|
DataManager.Instance.currentQuesitionType = QuestionType.EXIT_PROBLEM;
|
|
//UIManager.Instance.DestoryUI(UIType.UITalkMain);
|
|
ShowCheckTest();
|
|
//UIManager.Instance.OpenUI(UIType.UIQuitAll);
|
|
}
|
|
}
|