scenes and scripts
parent
5e253df7f6
commit
a98d9c3f90
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,53 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AllType : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public enum UIType
|
||||||
|
{
|
||||||
|
MainUI,
|
||||||
|
UIPeopleProgress,
|
||||||
|
UITalkMain,
|
||||||
|
UICheckTest,
|
||||||
|
UIQuitAll,
|
||||||
|
UIAnswer,
|
||||||
|
UIRightAnswer,
|
||||||
|
UITalk,
|
||||||
|
UIHistory,
|
||||||
|
UIClickBody,
|
||||||
|
UIHistoryInfo,
|
||||||
|
UIFile
|
||||||
|
|
||||||
|
}
|
||||||
|
public enum PeopleStyle
|
||||||
|
{
|
||||||
|
sit_front,
|
||||||
|
sit_back,
|
||||||
|
lie_front,
|
||||||
|
lie_back,
|
||||||
|
stand_front,
|
||||||
|
stand_back,
|
||||||
|
}
|
||||||
|
public enum HistoryType
|
||||||
|
{
|
||||||
|
peopleInfo,
|
||||||
|
askReason,
|
||||||
|
historyInfo,
|
||||||
|
lifeType,
|
||||||
|
healing,
|
||||||
|
finishCheck,
|
||||||
|
otherInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FileType
|
||||||
|
{
|
||||||
|
video,
|
||||||
|
music,
|
||||||
|
image,
|
||||||
|
URL,
|
||||||
|
text,
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DataManager : SingleTon<DataManager>
|
||||||
|
{
|
||||||
|
public List<RowsItem> peoples = new List<RowsItem>();
|
||||||
|
public RowsItem currentSelectPeople = null;
|
||||||
|
|
||||||
|
public List<DataItem> currentPeoplesProgress = new List<DataItem>();
|
||||||
|
|
||||||
|
public List<DataItem2> currentPeoplesQuestion = new List<DataItem2>();
|
||||||
|
public QuestionType currentQuesitionType;
|
||||||
|
|
||||||
|
private GameData gameData = null;
|
||||||
|
|
||||||
|
public DataItem2 currentQuitQuestion = null;
|
||||||
|
|
||||||
|
public Dictionary<int, List<QuestionItem>> currentAllQuestion = new Dictionary<int, List<QuestionItem>>();
|
||||||
|
|
||||||
|
public List<DataItem3> currentTalk = null;
|
||||||
|
public DataItem currentData = null;
|
||||||
|
public int currentBGType = 1;
|
||||||
|
public List<DataItem2> currentAnswerQuestion = new List<DataItem2>();
|
||||||
|
|
||||||
|
public string currentHistoryChoose = "";
|
||||||
|
|
||||||
|
public HistoryType currentHistoryType;
|
||||||
|
|
||||||
|
public bool isAddEventRTVoice = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 病人的个人资料
|
||||||
|
/// </summary>
|
||||||
|
public List<RowsItem2> rowitems2 = new List<RowsItem2>();
|
||||||
|
|
||||||
|
public GameData GetGameData()
|
||||||
|
{
|
||||||
|
if (gameData == null)
|
||||||
|
{
|
||||||
|
gameData = GameObject.Find("GameData").GetComponent<GameData>();
|
||||||
|
}
|
||||||
|
return gameData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public enum QuestionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 临床检查问题 code=1
|
||||||
|
/// </summary>
|
||||||
|
CLINICAL_PROBLEM,
|
||||||
|
/// <summary>
|
||||||
|
/// 诊断问题 code =2
|
||||||
|
/// </summary>
|
||||||
|
DIAGNOSE_PROBLEM,
|
||||||
|
/// <summary>
|
||||||
|
/// 建议问题 code=3
|
||||||
|
/// </summary>
|
||||||
|
SUGGEST_PROBLEM,
|
||||||
|
/// <summary>
|
||||||
|
/// 退出检查问题 code=4
|
||||||
|
/// </summary>
|
||||||
|
EXIT_PROBLEM
|
||||||
|
}
|
|
@ -0,0 +1,642 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
public class DataParse : SingleTon<DataParse>
|
||||||
|
{
|
||||||
|
|
||||||
|
public void ParsePeopleInfo(string str)
|
||||||
|
{
|
||||||
|
Root6 root = JsonUtility.FromJson<Root6>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
DataManager.Instance.rowitems2 = root.data.rows;
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnGetPeopleInfo2, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ParsePeopleHistory(string str)
|
||||||
|
{
|
||||||
|
Root5 root = JsonUtility.FromJson<Root5>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
//DataManager.Instance.currentTalk = root.data;
|
||||||
|
//EventCenter.dispatcher.SendMessage(MsgType.OnGetTalkMsg, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ParsePeopleTalk(string str)
|
||||||
|
{
|
||||||
|
Root4 root = JsonUtility.FromJson<Root4>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentTalk = root.data;
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnGetTalkMsg, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ParsePeopleQuestion(string str)
|
||||||
|
{
|
||||||
|
Root3 root = JsonUtility.FromJson<Root3>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentPeoplesQuestion = root.data;
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnGetPeopleQuetionList, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ParsePeopleList(string str)
|
||||||
|
{
|
||||||
|
Root2 root = JsonUtility.FromJson<Root2>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentPeoplesProgress = root.data;
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnGetCurrentPeopleProgress, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ParsePeople(string str)
|
||||||
|
{
|
||||||
|
Root root = JsonUtility.FromJson<Root>(str);
|
||||||
|
if (root != null)
|
||||||
|
{
|
||||||
|
if (root.code == 200)
|
||||||
|
{
|
||||||
|
DataManager.Instance.peoples = root.data.rows;
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnGetPeopleInfo, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("root.code = " + root.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 病人的个人资料
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class RowsItem2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int createBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int updateBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int sex;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int age;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int weight;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int height;
|
||||||
|
/// <summary>
|
||||||
|
/// 李
|
||||||
|
/// </summary>
|
||||||
|
public string familyName;
|
||||||
|
/// <summary>
|
||||||
|
/// 工
|
||||||
|
/// </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int matrimony;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int childrenNum;
|
||||||
|
/// <summary>
|
||||||
|
/// java工程师
|
||||||
|
/// </summary>
|
||||||
|
public string occupation;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int weightExponent;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string type;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string abdominalCircumference;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string diagnosisId;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 病人的个人资料
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class Data2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int total;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<RowsItem2> rows;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 病人的个人资料
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class Root6
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code;
|
||||||
|
/// <summary>
|
||||||
|
/// 查询成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Data2 data;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class DataItem4
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int createBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
/// {"drugAllergy":null,"allergens":"阿莫西林"}
|
||||||
|
/// </summary>
|
||||||
|
public string detailInfo;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string type;
|
||||||
|
/// <summary>
|
||||||
|
/// 消炎时,过敏
|
||||||
|
/// </summary>
|
||||||
|
public string peculiarity;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int diagnosisId;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class Root5
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 操作成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<DataItem4> data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class DataItem3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int senderCode;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int backgroundType;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int relationId;
|
||||||
|
/// <summary>
|
||||||
|
/// 请问有什么可以帮助您的?
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class Root4
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code;
|
||||||
|
/// <summary>
|
||||||
|
/// 操作成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<DataItem3> data;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ProblemAnswerRespListItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int problemId;
|
||||||
|
/// <summary>
|
||||||
|
/// 没有问题不需要进行治疗。
|
||||||
|
/// </summary>
|
||||||
|
public string replyText;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int replyEvaluate;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class DataItem2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int diagnosisId;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int backgroundType;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int type;
|
||||||
|
/// <summary>
|
||||||
|
/// 其他问题
|
||||||
|
/// </summary>
|
||||||
|
public string introduce;
|
||||||
|
/// <summary>
|
||||||
|
/// 没啥大问题
|
||||||
|
/// </summary>
|
||||||
|
public string title;
|
||||||
|
/// <summary>
|
||||||
|
/// 问题不大
|
||||||
|
/// </summary>
|
||||||
|
public string feedback;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string titleFileIds;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string feedbackFileIds;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<ProblemAnswerRespListItem> problemAnswerRespList;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string linkRedirectRespList;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class Root3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code;
|
||||||
|
/// <summary>
|
||||||
|
/// 操作成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<DataItem2> data;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class DataItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int createBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int updateBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string bodyTemperature;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string pulse;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string respiratoryRate;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int bloodPressure;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int casesId;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string diagnosisBackgroundId;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string reason;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string illustrate;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int sort;
|
||||||
|
/// <summary>
|
||||||
|
/// 初次诊断
|
||||||
|
/// </summary>
|
||||||
|
public string title;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string dateTime;
|
||||||
|
/// <summary>
|
||||||
|
/// 诊断背景
|
||||||
|
/// </summary>
|
||||||
|
public string background;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int patientDiagnosis;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string haveProjectId;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class Root2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code;
|
||||||
|
/// <summary>
|
||||||
|
/// 操作成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<DataItem> data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 诊断数据
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class RowsItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int createBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string createTime;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int updateBy;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string updateTime;
|
||||||
|
/// <summary>
|
||||||
|
/// 诊断ID
|
||||||
|
/// </summary>
|
||||||
|
public int id;
|
||||||
|
/// <summary>
|
||||||
|
/// 测试病例
|
||||||
|
/// </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary>
|
||||||
|
/// 汉语
|
||||||
|
/// </summary>
|
||||||
|
public string languageType;
|
||||||
|
/// <summary>
|
||||||
|
/// 解刨
|
||||||
|
/// </summary>
|
||||||
|
public string specialty;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<string> assessmentPoints;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<string> field;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<string> difficulty;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string patientId;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string image;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string sex;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string age;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string weight;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string feature;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int haveClothing;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string order;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int total;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<RowsItem> rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class Root
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int code;
|
||||||
|
/// <summary>
|
||||||
|
/// 查询成功
|
||||||
|
/// </summary>
|
||||||
|
public string msg;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Data data;
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using static EventCenter;
|
||||||
|
|
||||||
|
public class EventCenter : SingleTon<EventCenter>
|
||||||
|
{
|
||||||
|
public delegate void EventListenerDelegate(Message evt);
|
||||||
|
public static Dispatcher dispatcher;
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
dispatcher = new Dispatcher();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Dispatcher
|
||||||
|
{
|
||||||
|
private Dictionary<MsgType, EventListenerDelegate> events = new Dictionary<MsgType, EventListenerDelegate>();
|
||||||
|
|
||||||
|
public void AddListener(MsgType type, EventListenerDelegate listener)
|
||||||
|
{
|
||||||
|
if (listener == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("AddListener: listener²»ÄÜΪ¿Õ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventListenerDelegate myListener = null;
|
||||||
|
events.TryGetValue(type, out myListener);
|
||||||
|
events[type] = (EventListenerDelegate)Delegate.Combine(myListener, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveListener(MsgType type, EventListenerDelegate listener)
|
||||||
|
{
|
||||||
|
if (listener == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("RemoveListener: listener²»ÄÜΪ¿Õ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
events[type] = (EventListenerDelegate)Delegate.Remove(events[type], listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendMessage(MsgType type, object param)
|
||||||
|
{
|
||||||
|
EventListenerDelegate listenerDelegate;
|
||||||
|
if (events.TryGetValue(type, out listenerDelegate))
|
||||||
|
{
|
||||||
|
Message evt = new Message(type, param);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (listenerDelegate != null)
|
||||||
|
{
|
||||||
|
listenerDelegate(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.Log("SendMessage:" + evt.msgType.ToString() + " " + e.Message + " " + e.StackTrace + " " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
events.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Message
|
||||||
|
{
|
||||||
|
public MsgType msgType;
|
||||||
|
public object MsgParams;
|
||||||
|
public Message(MsgType _msgType, object _MsgParams)
|
||||||
|
{
|
||||||
|
msgType = _msgType;
|
||||||
|
MsgParams = _MsgParams;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public enum MsgType
|
||||||
|
{
|
||||||
|
OnGetPeopleInfo,
|
||||||
|
OnGetCurrentPeopleProgress,
|
||||||
|
OnGetPeopleQuetionList,
|
||||||
|
OnSubmitQuestion,
|
||||||
|
OnGetTalkMsg,
|
||||||
|
OnGetPeopleInfo2
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GameData : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject mainCanvas;
|
||||||
|
|
||||||
|
public MainUI mainUI;
|
||||||
|
|
||||||
|
public Animator talkMan;
|
||||||
|
|
||||||
|
public Animator LieMan;
|
||||||
|
public GameObject talkModel;
|
||||||
|
public GameObject lieModel;
|
||||||
|
public GameObject lyingModel;
|
||||||
|
public GameObject sitModel;
|
||||||
|
public GameObject sitModel2;
|
||||||
|
public GameObject upModel;
|
||||||
|
public GameObject upModel2;
|
||||||
|
|
||||||
|
public GameObject[] allModel;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
talkMan.SetBool("idle1", true);
|
||||||
|
|
||||||
|
LieMan.speed = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowTalkMan()
|
||||||
|
{
|
||||||
|
CloseAllMan();
|
||||||
|
talkModel.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseAllMan()
|
||||||
|
{
|
||||||
|
UIManager.Instance.DestoryUI(UIType.UIClickBody);
|
||||||
|
for (int i = 0; i < allModel.Length; i++)
|
||||||
|
{
|
||||||
|
allModel[i].SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowCheckMan(PeopleStyle type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PeopleStyle.lie_front://ÌÉ
|
||||||
|
CloseAllMan();
|
||||||
|
lieModel.SetActive(true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PeopleStyle.lie_back://Å¿
|
||||||
|
CloseAllMan();
|
||||||
|
lyingModel.SetActive(true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PeopleStyle.stand_back://Õ¾Á¢¡ª±³Ãæ
|
||||||
|
CloseAllMan();
|
||||||
|
upModel2.SetActive(true);
|
||||||
|
break;
|
||||||
|
case PeopleStyle.stand_front://Õ¾Á¢ ÕýÃæ
|
||||||
|
CloseAllMan();
|
||||||
|
upModel.SetActive(true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PeopleStyle.sit_front://×ø ÕýÃæ
|
||||||
|
CloseAllMan();
|
||||||
|
sitModel.SetActive(true);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PeopleStyle.sit_back://×ø ±³Ãæ
|
||||||
|
CloseAllMan();
|
||||||
|
sitModel2.SetActive(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class People
|
||||||
|
{
|
||||||
|
//@ApiModelProperty(name = "主键", value = "主键")
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "病例名称", value = "病例名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "病例语言", value = "病例语言")
|
||||||
|
private String languageType;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "专业", value = "专业")
|
||||||
|
private String specialty;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "考核点;逗号分割的id字符串", value = "考核点;逗号分割的id字符串")
|
||||||
|
private List<String> assessmentPoints;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "领域;逗号分割的id字符串", value = "领域;逗号分割的id字符串")
|
||||||
|
private List<String> field;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "难度;逗号分割的id字符串", value = "难度;逗号分割的id字符串")
|
||||||
|
private List<String> difficulty;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "形象id", value = "形象id")
|
||||||
|
private long patientId;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "病例患者主图;可能会存", value = "病例患者主图;可能会存")
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "性别", value = "性别")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "年龄区间", value = "年龄区间")
|
||||||
|
private String age;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "体重;(cm),如果有小数的话 存储*10,展示直接/10", value = "体重;(cm),如果有小数的话 存储*10,展示直接/10")
|
||||||
|
private String weight;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "特征", value = "特征")
|
||||||
|
private String feature;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "是否穿衣", value = "是否穿衣")
|
||||||
|
private int haveClothing;
|
||||||
|
|
||||||
|
//@ApiModelProperty(name = "排序(1:修改时间,2:添加时间)", value = "排序")
|
||||||
|
private int order;
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class UIManager : SingleTon<UIManager>
|
||||||
|
{
|
||||||
|
private Dictionary<UIType, UIBase> uiDic = new Dictionary<UIType, UIBase>();
|
||||||
|
|
||||||
|
public GameData GameData { get; private set; }
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
GameData = DataManager.Instance.GetGameData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UIBase GetUIBase(UIType uIType)
|
||||||
|
{
|
||||||
|
if (uiDic.ContainsKey(uIType))
|
||||||
|
{
|
||||||
|
return uiDic[uIType].gameObject.GetComponent<UIBase>();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UIBase OpenUI(UIType uIType)
|
||||||
|
{
|
||||||
|
if (uiDic.ContainsKey(uIType))
|
||||||
|
{
|
||||||
|
uiDic[uIType]?.Open();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameObject Prefab = (GameObject)Resources.Load("UIPrefabs/" + uIType.ToString());
|
||||||
|
var newUI = GameObject.Instantiate(Prefab, GameData.mainCanvas.transform);
|
||||||
|
uiDic.Add(uIType, newUI.GetComponent<UIBase>());
|
||||||
|
}
|
||||||
|
return uiDic[uIType];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseUI(UIType uIType)
|
||||||
|
{
|
||||||
|
if (uiDic.ContainsKey(uIType))
|
||||||
|
{
|
||||||
|
uiDic[uIType]?.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool isShow(UIType uIType)
|
||||||
|
{
|
||||||
|
if (uiDic.ContainsKey(uIType))
|
||||||
|
{
|
||||||
|
return uiDic[uIType].gameObject.activeSelf;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowMainUI()
|
||||||
|
{
|
||||||
|
GameData.mainUI.Open();
|
||||||
|
}
|
||||||
|
public void CloseMainUI()
|
||||||
|
{
|
||||||
|
GameData.mainUI.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseAllUI()
|
||||||
|
{
|
||||||
|
foreach (var ui in uiDic.Values)
|
||||||
|
{
|
||||||
|
ui.Close();
|
||||||
|
}
|
||||||
|
CloseMainUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowAllUI()
|
||||||
|
{
|
||||||
|
foreach (var ui in uiDic.Values)
|
||||||
|
{
|
||||||
|
ui.Open();
|
||||||
|
}
|
||||||
|
ShowMainUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DestoryUI(UIType uIType)
|
||||||
|
{
|
||||||
|
if (uiDic.ContainsKey(uIType))
|
||||||
|
{
|
||||||
|
uiDic[uIType].Destroy();
|
||||||
|
uiDic.Remove(uIType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,271 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class NetMain : SingleTon<NetMain>
|
||||||
|
{
|
||||||
|
private Socket socket;
|
||||||
|
private IPEndPoint ipe;
|
||||||
|
|
||||||
|
private string ip;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
public Socket conn()
|
||||||
|
{
|
||||||
|
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
ip = "122.112.171.137";
|
||||||
|
port = 85;
|
||||||
|
ipe = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||||
|
socket.Connect(ipe);
|
||||||
|
if (socket.Connected)
|
||||||
|
{
|
||||||
|
Debug.Log("连接成功");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("连接失败");
|
||||||
|
}
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Socket Create(string serverAddress, int nPort)
|
||||||
|
{
|
||||||
|
string connectionHost = serverAddress;
|
||||||
|
string convertedHost = string.Empty;
|
||||||
|
AddressFamily convertFamily = AddressFamily.InterNetwork;
|
||||||
|
|
||||||
|
if (IsIPAddress(serverAddress))
|
||||||
|
{
|
||||||
|
GetIPType(serverAddress, out convertedHost, out convertFamily);
|
||||||
|
if (string.IsNullOrEmpty(convertedHost))
|
||||||
|
{
|
||||||
|
connectionHost = convertedHost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
convertedHost = GetIPAddress(serverAddress, EAddressFam.IPv6);
|
||||||
|
if (string.IsNullOrEmpty(convertedHost))
|
||||||
|
{
|
||||||
|
convertedHost = GetIPAddress(serverAddress, EAddressFam.IPv4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
convertFamily = AddressFamily.InterNetworkV6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(convertedHost))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connectionHost = convertedHost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress[] ipAddressArray = Dns.GetHostAddresses(connectionHost);
|
||||||
|
if (ipAddressArray.Length <= 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress ipAddress = ipAddressArray[0];
|
||||||
|
AddressFamily addressFamily = AddressFamily.InterNetwork;
|
||||||
|
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
addressFamily = AddressFamily.InterNetworkV6;
|
||||||
|
}
|
||||||
|
|
||||||
|
Socket socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp)
|
||||||
|
{
|
||||||
|
SendTimeout = 3000,
|
||||||
|
ReceiveTimeout = 3000,
|
||||||
|
SendBufferSize = 64 * 1024,
|
||||||
|
ReceiveBufferSize = 64 * 1024,
|
||||||
|
NoDelay = true
|
||||||
|
};
|
||||||
|
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPv6
|
||||||
|
|
||||||
|
#if (UNITY_IOS || UNITY_IPHONE) && !UNITY_EDITOR
|
||||||
|
private static extern string getIPv6(string host);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
string GetIPv6(string host)
|
||||||
|
{
|
||||||
|
#if (UNITY_IOS || UNITY_IPHONE) && !UNITY_EDITOR
|
||||||
|
return getIPv6(host);
|
||||||
|
#else
|
||||||
|
return host + "&&ipv4";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetIPType(string serverIp, out string newServerIp, out AddressFamily IPType)
|
||||||
|
{
|
||||||
|
IPType = AddressFamily.InterNetwork;
|
||||||
|
newServerIp = serverIp;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string ipv6 = GetIPv6(serverIp);
|
||||||
|
if (!string.IsNullOrEmpty(ipv6))
|
||||||
|
{
|
||||||
|
string[] tmp = System.Text.RegularExpressions.Regex.Split(ipv6, "&&");
|
||||||
|
if (null != tmp && tmp.Length >= 2)
|
||||||
|
{
|
||||||
|
string type = tmp[1];
|
||||||
|
if (type == "ipv6")
|
||||||
|
{
|
||||||
|
newServerIp = tmp[0];
|
||||||
|
IPType = AddressFamily.InterNetworkV6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetIPAddress(string hostName, EAddressFam af)
|
||||||
|
{
|
||||||
|
//基础操作系统和网络适配器是否支持 internet 协议的版本 6(ipv6)
|
||||||
|
if (af == EAddressFam.IPv6 && !Socket.OSSupportsIPv6)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(hostName))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string connetIP = string.Empty;
|
||||||
|
IPHostEntry host;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
host = Dns.GetHostEntry(hostName);
|
||||||
|
foreach (var ip in host.AddressList)
|
||||||
|
{
|
||||||
|
if (af == EAddressFam.IPv4)
|
||||||
|
{
|
||||||
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
{
|
||||||
|
connetIP = ip.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (af == EAddressFam.IPv6)
|
||||||
|
{
|
||||||
|
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
connetIP = ip.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError("GetIPAddress error : " + e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return connetIP;
|
||||||
|
}
|
||||||
|
//判断str是域名还是ip
|
||||||
|
bool IsIPAddress(string str)
|
||||||
|
{
|
||||||
|
Match match = Regex.Match(str, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
|
||||||
|
return match.Success;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
//NetMain net = new NetMain("122.112.171.137", 443);
|
||||||
|
//Socket _tcpClient = NetMain.Instance.conn();
|
||||||
|
|
||||||
|
//byte[] data = new byte[1024];
|
||||||
|
//int length = _tcpClient.Receive(data);
|
||||||
|
//var message = Encoding.UTF8.GetString(data, 0, length);
|
||||||
|
//Debug.Log("客户端收到来自服务器发来的信息" + message);
|
||||||
|
|
||||||
|
|
||||||
|
//IPAddress ip2 = IPAddress.Parse("122.112.171.137");//所用网卡
|
||||||
|
//int port2 = 443;//监听端口
|
||||||
|
//IPEndPoint ipe2 = new IPEndPoint(ip2, port2);
|
||||||
|
//EndPoint ep2 = (EndPoint)ipe2;
|
||||||
|
//_tcpClient.Bind(ep2);
|
||||||
|
|
||||||
|
//string msg = "/api/cases/base/list";
|
||||||
|
//byte[] buffer = Encoding.Unicode.GetBytes(msg);//将字符串转化为二进制
|
||||||
|
//_tcpClient.Send(buffer);
|
||||||
|
|
||||||
|
//TcpClient client = new TcpClient();//client是服务端的变量
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// //与服务端建立一个TCP连接,连接好以后,客户端就会等待服务端发来的数据
|
||||||
|
// client.Connect(IPAddress.Parse("122.112.171.137"), 443);
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// Debug.Log("客户端连接异常:" + ex.Message);
|
||||||
|
//}
|
||||||
|
////客户端接收服务端发送的数据部分
|
||||||
|
//var socket = NetMain.Instance;
|
||||||
|
//const int bufferSize = 8792;
|
||||||
|
//NetworkStream streamToClient = client.GetStream();//获得来自服务端的流
|
||||||
|
//byte[] buffer = new byte[bufferSize];//定义一个缓存buffer数组
|
||||||
|
//int byteRead = streamToClient.Read(buffer, 0, bufferSize);//将数据存入缓存中
|
||||||
|
|
||||||
|
//string msg = Encoding.Unicode.GetString(buffer, 0, byteRead);//从二进制转换为字符串对应的客户端会有从字符串转换为二进制的方法
|
||||||
|
//Debug.Log("接收消息:" + msg);
|
||||||
|
|
||||||
|
|
||||||
|
//Socket _tcpClient = NetMain.Instance.conn();
|
||||||
|
|
||||||
|
//string msg = "/api/cases/base/list";
|
||||||
|
//byte[] buffer = Encoding.Unicode.GetBytes(msg);//将字符串转化为二进制
|
||||||
|
//_tcpClient.Send(buffer);
|
||||||
|
//string url = "http://122.112.171.137:8080/api/cases/base/list";
|
||||||
|
//StartCoroutine(PostRequest(url));
|
||||||
|
|
||||||
|
//StartCoroutine(Get(url));
|
||||||
|
|
||||||
|
//streamToClient.Write(buffer, 0, buffer.Length);//将转换好的二进制数据写入客户端的流中并发送
|
||||||
|
|
||||||
|
|
||||||
|
//IEnumerator PostRequest(string url)
|
||||||
|
//{
|
||||||
|
// //所提交的表单
|
||||||
|
// WWWForm form = new WWWForm();
|
||||||
|
// //加上请求参数,如参数名“Content-Type",内容”application/json“
|
||||||
|
// //form.AddField("Content-Type", "application/json");
|
||||||
|
|
||||||
|
// //发送Post请求
|
||||||
|
// using (UnityWebRequest webRequest = UnityWebRequest.Post(url, form))
|
||||||
|
// {
|
||||||
|
// yield return webRequest.SendWebRequest();
|
||||||
|
// if (!string.IsNullOrEmpty(webRequest.error))
|
||||||
|
// {
|
||||||
|
// Debug.LogError(webRequest.error);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //获得返回数据
|
||||||
|
// Debug.Log(webRequest.downloadHandler.text);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
enum EAddressFam : byte
|
||||||
|
{
|
||||||
|
IPv4,
|
||||||
|
IPv6
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SingleTon<T> where T : new()
|
||||||
|
{
|
||||||
|
private static T _instance;
|
||||||
|
public static T Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(_instance == null)
|
||||||
|
{
|
||||||
|
_instance = new T();
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
using DG.Tweening;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class SlideScrollView : MonoBehaviour, IBeginDragHandler, IEndDragHandler
|
||||||
|
{
|
||||||
|
private RectTransform contentTrans;
|
||||||
|
private float beginMousePositionX;
|
||||||
|
private float endMousePositionX;
|
||||||
|
private ScrollRect scrollRect;
|
||||||
|
|
||||||
|
public int cellLength;
|
||||||
|
public int spaceing;
|
||||||
|
public int leftOffset;
|
||||||
|
|
||||||
|
private float moveOneItemLength;
|
||||||
|
private Vector3 currentContentLocalPos;//上一次的位置
|
||||||
|
|
||||||
|
public int totalItemNum;
|
||||||
|
private int currenIndex;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
scrollRect = GetComponent<ScrollRect>();
|
||||||
|
contentTrans = scrollRect.content;
|
||||||
|
moveOneItemLength = cellLength + spaceing;
|
||||||
|
currentContentLocalPos = contentTrans.localPosition;
|
||||||
|
currenIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnEndDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
endMousePositionX = Input.mousePosition.x;
|
||||||
|
float offSetX = 0;
|
||||||
|
float moveDistance = 0;//当次需要滑动的距离
|
||||||
|
offSetX = beginMousePositionX - endMousePositionX;
|
||||||
|
|
||||||
|
|
||||||
|
if (offSetX > 0)//右滑
|
||||||
|
{
|
||||||
|
if (currenIndex >= totalItemNum)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
moveDistance = -moveOneItemLength;
|
||||||
|
currenIndex++;
|
||||||
|
}
|
||||||
|
else//左滑
|
||||||
|
{
|
||||||
|
if (currenIndex <= 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
moveDistance = moveOneItemLength;
|
||||||
|
currenIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
DOTween.To(() => contentTrans.localPosition, lerpValue => contentTrans.localPosition = lerpValue, currentContentLocalPos + new Vector3(moveDistance, 0, 0), 0.5f).SetEase(Ease.InOutQuint);
|
||||||
|
currentContentLocalPos += new Vector3(moveDistance, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
beginMousePositionX = Input.mousePosition.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,216 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(ToggleGroup))]
|
||||||
|
public class ToggleTab : MonoBehaviour
|
||||||
|
{
|
||||||
|
private ToggleGroup toggleGroup;
|
||||||
|
private List<Toggle> toggles;
|
||||||
|
private Toggle currentSelectToggle;
|
||||||
|
private int currentSelectedIndex;
|
||||||
|
private List<Action<string, int>> selectedListener;
|
||||||
|
private List<Action<string, int>> unselectedListener;
|
||||||
|
private bool isInit = false;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
if (isInit)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isInit = true;
|
||||||
|
selectedListener = new List<Action<string, int>>(3);
|
||||||
|
unselectedListener = new List<Action<string, int>>(3);
|
||||||
|
toggles = new List<Toggle>();
|
||||||
|
toggleGroup = GetComponent<ToggleGroup>();
|
||||||
|
GetComponentsInChildren(true, toggles);
|
||||||
|
for (int i = 0; i < toggles.Count; i++)
|
||||||
|
{
|
||||||
|
Toggle toggle = toggles[i];
|
||||||
|
toggle.group = toggleGroup;
|
||||||
|
toggle.onValueChanged.AddListener(OnTabChange);
|
||||||
|
if (toggle.isOn)
|
||||||
|
{
|
||||||
|
if (currentSelectToggle == null)
|
||||||
|
{
|
||||||
|
currentSelectToggle = toggle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toggle.isOn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetSelectedName()
|
||||||
|
{
|
||||||
|
if(currentSelectToggle!= null)
|
||||||
|
{
|
||||||
|
return currentSelectToggle.name;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSelectedName(string toggleName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < toggles.Count; i++)
|
||||||
|
{
|
||||||
|
if (toggles[i].name == toggleName)
|
||||||
|
{
|
||||||
|
if (!toggles[i].isOn)
|
||||||
|
{
|
||||||
|
toggles[i].isOn = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int GetSelectedIndex()
|
||||||
|
{
|
||||||
|
if (currentSelectToggle != null)
|
||||||
|
{
|
||||||
|
return toggles.IndexOf(currentSelectToggle);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSelectedIndex(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < toggles.Count)
|
||||||
|
{
|
||||||
|
toggles[index].isOn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int AddToggle(Toggle toggle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (toggle != null)
|
||||||
|
{
|
||||||
|
bool isExist = toggles.Contains(toggle);
|
||||||
|
|
||||||
|
if (!isExist)
|
||||||
|
{
|
||||||
|
toggle.isOn = false;
|
||||||
|
toggle.group = toggleGroup;
|
||||||
|
toggles.Add(toggle);
|
||||||
|
return toggles.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
public void RemoveToggle(Toggle toggle)
|
||||||
|
{
|
||||||
|
if (toggle != null)
|
||||||
|
{
|
||||||
|
int index = toggles.IndexOf(toggle);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
toggles.RemoveAt(index);
|
||||||
|
if (currentSelectToggle == toggle)
|
||||||
|
{
|
||||||
|
currentSelectToggle = null;
|
||||||
|
currentSelectedIndex = -1;
|
||||||
|
if (toggles.Count > 0)
|
||||||
|
{
|
||||||
|
currentSelectToggle = toggles[0];
|
||||||
|
currentSelectToggle.isOn = true;
|
||||||
|
currentSelectedIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = index; i < toggles.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSelectToggle == toggles[i])
|
||||||
|
{
|
||||||
|
currentSelectedIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void AddSelectedListener(Action<string, int> listener)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
selectedListener.Add(listener);
|
||||||
|
}
|
||||||
|
public void AddUnselectedListener(Action<string, int> listener)
|
||||||
|
{
|
||||||
|
unselectedListener.Add(listener);
|
||||||
|
}
|
||||||
|
public void RemoveSelectedListener(Action<string, int> listener)
|
||||||
|
{
|
||||||
|
selectedListener.Remove(listener);
|
||||||
|
}
|
||||||
|
public void RemoveAllSelectedListeners()
|
||||||
|
{
|
||||||
|
selectedListener.Clear();
|
||||||
|
}
|
||||||
|
public void RemoveUnselectedListener(Action<string, int> listener)
|
||||||
|
{
|
||||||
|
unselectedListener.Remove(listener);
|
||||||
|
}
|
||||||
|
public void RemoveAllUnselectedListeners()
|
||||||
|
{
|
||||||
|
unselectedListener.Clear();
|
||||||
|
}
|
||||||
|
private void OnTabChange(bool isSelect)
|
||||||
|
{
|
||||||
|
if (isSelect)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < toggles.Count; i++)
|
||||||
|
{
|
||||||
|
Toggle toggle = toggles[i];
|
||||||
|
if (toggle.isOn)
|
||||||
|
{
|
||||||
|
if (toggle == currentSelectToggle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (currentSelectToggle != null)
|
||||||
|
{
|
||||||
|
CallUnselectedListener(currentSelectToggle, currentSelectedIndex + 1);
|
||||||
|
}
|
||||||
|
currentSelectToggle = toggle;
|
||||||
|
currentSelectedIndex = i;
|
||||||
|
CallSelectedListener(currentSelectToggle, currentSelectedIndex + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CallSelectedListener(Toggle toggle, int index)
|
||||||
|
{
|
||||||
|
for (int i = selectedListener.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
selectedListener[i]?.Invoke(toggle.name, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CallUnselectedListener(Toggle toggle, int index)
|
||||||
|
{
|
||||||
|
for (int i = unselectedListener.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
unselectedListener[i]?.Invoke(toggle.name, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
RemoveAllSelectedListeners();
|
||||||
|
RemoveAllUnselectedListeners();
|
||||||
|
toggles.Clear();
|
||||||
|
selectedListener = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class MainUI : UIBase
|
||||||
|
{
|
||||||
|
public Button quitBtn;
|
||||||
|
public Transform peopleContent;
|
||||||
|
List<UIPeopleInfoItem> peopleList;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
EventCenter.Instance.Init();
|
||||||
|
UIManager.Instance.Init();
|
||||||
|
NetMain.Instance.conn();
|
||||||
|
|
||||||
|
peopleList = new List<UIPeopleInfoItem>();
|
||||||
|
|
||||||
|
quitBtn.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
Application.Quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
EventCenter.dispatcher.AddListener(MsgType.OnGetPeopleInfo, ShowPeopleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowPeopleInfo(Message message)
|
||||||
|
{
|
||||||
|
var peoples = DataManager.Instance.peoples;
|
||||||
|
GameObject Prefab = (GameObject)Resources.Load("UIPrefabs/PeopleInfo");
|
||||||
|
for (int i = 0; i < peoples.Count; i++)
|
||||||
|
{
|
||||||
|
UIPeopleInfoItem item = Instantiate(Prefab, peopleContent).GetComponent<UIPeopleInfoItem>();
|
||||||
|
peopleList.Add(item);
|
||||||
|
item.Init(peoples[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
GetPeopleInfo();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.Q))
|
||||||
|
{
|
||||||
|
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
|
||||||
|
UIFile file = (UIFile)ui;
|
||||||
|
file.Init(FileType.URL);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.W))
|
||||||
|
{
|
||||||
|
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
|
||||||
|
UIFile file = (UIFile)ui;
|
||||||
|
file.Init(FileType.text);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.E))
|
||||||
|
{
|
||||||
|
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
|
||||||
|
UIFile file = (UIFile)ui;
|
||||||
|
file.Init(FileType.music);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.R))
|
||||||
|
{
|
||||||
|
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
|
||||||
|
UIFile file = (UIFile)ui;
|
||||||
|
file.Init(FileType.video);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.T))
|
||||||
|
{
|
||||||
|
UIBase ui = UIManager.Instance.OpenUI(UIType.UIFile);
|
||||||
|
UIFile file = (UIFile)ui;
|
||||||
|
file.Init(FileType.image, "https://s-sh-7897-jiayi-test.oss.dogecdn.com/physique/05329a95469146ca85c01cea53babc8a-girl.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
EventCenter.dispatcher.RemoveListener(MsgType.OnGetPeopleInfo, ShowPeopleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetPeopleInfo()
|
||||||
|
{
|
||||||
|
string url = "http://122.112.171.137:85/api/cases/base/list";
|
||||||
|
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.ParsePeople(receiveContent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class QuestionItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject topHint;
|
||||||
|
public TextMeshProUGUI hintTxt;
|
||||||
|
|
||||||
|
public TextMeshProUGUI questionText;
|
||||||
|
|
||||||
|
public Button submitBtn;
|
||||||
|
|
||||||
|
public Toggle togPrefab;
|
||||||
|
public ToggleGroup togPrefabGroup;
|
||||||
|
|
||||||
|
public DataItem2 currentData;
|
||||||
|
|
||||||
|
int currentSelectIndex = -1;
|
||||||
|
public RectTransform bg;
|
||||||
|
public void Init(DataItem2 data, bool isEnd)
|
||||||
|
{
|
||||||
|
currentData = data;
|
||||||
|
if (currentData != null)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(currentData.introduce))
|
||||||
|
{
|
||||||
|
topHint.SetActive(true);
|
||||||
|
hintTxt.text = currentData.introduce;
|
||||||
|
}
|
||||||
|
if (isEnd)
|
||||||
|
{
|
||||||
|
submitBtn.gameObject.SetActive(true);
|
||||||
|
submitBtn.onClick.AddListener(OnClickSubmit);
|
||||||
|
}
|
||||||
|
questionText.text = currentData.title;
|
||||||
|
}
|
||||||
|
var replyList = currentData.problemAnswerRespList;
|
||||||
|
for (int i = 0; i < replyList.Count; i++)
|
||||||
|
{
|
||||||
|
Toggle newUI = GameObject.Instantiate(togPrefab, togPrefabGroup.transform);
|
||||||
|
newUI.transform.Find("Label").GetComponent<Text>().text = replyList[i].replyText;
|
||||||
|
newUI.gameObject.SetActive(true);
|
||||||
|
newUI.isOn = false;
|
||||||
|
newUI.transform.SetSiblingIndex(i);
|
||||||
|
newUI.onValueChanged.AddListener((bool value) => OnSelect(newUI));
|
||||||
|
newUI.name = i.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickSubmit()
|
||||||
|
{
|
||||||
|
EventCenter.dispatcher.SendMessage(MsgType.OnSubmitQuestion, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSelect(Toggle t)
|
||||||
|
{
|
||||||
|
if (t.isOn)
|
||||||
|
{
|
||||||
|
currentSelectIndex = int.Parse(t.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetTogSelect()
|
||||||
|
{
|
||||||
|
return currentSelectIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIAnswer : UIBase
|
||||||
|
{
|
||||||
|
public Button closeBtn;
|
||||||
|
|
||||||
|
DataItem2 data;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
closeBtn.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIAnswer); });
|
||||||
|
data = DataManager.Instance.currentQuitQuestion;
|
||||||
|
|
||||||
|
Debug.Log(data.title);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIAnswerItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Button openRightAnswer;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
openRightAnswer.onClick.AddListener(()=> { UIManager.Instance.OpenUI(UIType.UIRightAnswer); });
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class UIBase : MonoBehaviour
|
||||||
|
{
|
||||||
|
public void Open()
|
||||||
|
{
|
||||||
|
|
||||||
|
this.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
this.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Destroy()
|
||||||
|
{
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UICheckTest : UIBase
|
||||||
|
{
|
||||||
|
public Button close;
|
||||||
|
QuestionType questionType;
|
||||||
|
|
||||||
|
List<DataItem2> currentPeoplesQuestion;
|
||||||
|
|
||||||
|
public Transform content;
|
||||||
|
List<QuestionItem> allQuestionItem;
|
||||||
|
|
||||||
|
GameObject questionPrefab;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
close.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UICheckTest); });
|
||||||
|
EventCenter.dispatcher.AddListener(MsgType.OnSubmitQuestion,OnSubmitQuestion);
|
||||||
|
questionPrefab = (GameObject)Resources.Load("UIPrefabs/Question");
|
||||||
|
|
||||||
|
RefreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshData()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < content.transform.childCount; i++)
|
||||||
|
{
|
||||||
|
var transform = content.transform.GetChild(i);
|
||||||
|
GameObject.Destroy(transform.gameObject);
|
||||||
|
}
|
||||||
|
var allQuestion = DataManager.Instance.currentPeoplesQuestion;
|
||||||
|
questionType = DataManager.Instance.currentQuesitionType;
|
||||||
|
allQuestionItem = new List<QuestionItem>();
|
||||||
|
currentPeoplesQuestion = new List<DataItem2>();
|
||||||
|
switch (questionType)
|
||||||
|
{
|
||||||
|
case QuestionType.CLINICAL_PROBLEM:
|
||||||
|
for (int i = 0; i < allQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
if (allQuestion[i].type == 1)
|
||||||
|
{
|
||||||
|
currentPeoplesQuestion.Add(allQuestion[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QuestionType.DIAGNOSE_PROBLEM:
|
||||||
|
for (int i = 0; i < allQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
if (allQuestion[i].type == 2)
|
||||||
|
{
|
||||||
|
currentPeoplesQuestion.Add(allQuestion[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QuestionType.SUGGEST_PROBLEM:
|
||||||
|
for (int i = 0; i < allQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
if (allQuestion[i].type == 3)
|
||||||
|
{
|
||||||
|
currentPeoplesQuestion.Add(allQuestion[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QuestionType.EXIT_PROBLEM:
|
||||||
|
currentPeoplesQuestion = allQuestion;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < currentPeoplesQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
var temp = currentPeoplesQuestion[i];
|
||||||
|
var newUI = GameObject.Instantiate(questionPrefab, content);
|
||||||
|
QuestionItem currentItem = newUI.GetComponent<QuestionItem>();
|
||||||
|
bool isEnd = i == currentPeoplesQuestion.Count - 1;
|
||||||
|
currentItem.Init(temp, isEnd);
|
||||||
|
allQuestionItem.Add(currentItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSubmitQuestion(Message evt)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < allQuestionItem.Count; i++)
|
||||||
|
{
|
||||||
|
var item = allQuestionItem[i];
|
||||||
|
if(item.GetTogSelect() == -1)
|
||||||
|
{
|
||||||
|
Debug.Log("Toggle" + item.name + "No answer");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentAnswerQuestion.Add(item.currentData);
|
||||||
|
Debug.Log("ÎÊÌâ" + item.name + "Ñ¡ÔñÁË" + item.GetTogSelect());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIClickBody : UIBase
|
||||||
|
{
|
||||||
|
public Button btn;
|
||||||
|
|
||||||
|
|
||||||
|
public Transform currentModel;
|
||||||
|
|
||||||
|
public Transform moreBtn;
|
||||||
|
|
||||||
|
public Button btn1;
|
||||||
|
public Button btn2;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var buwei1 = currentModel.Find("ÐØ²¿");
|
||||||
|
var buwei2 = currentModel.Find("ÏÂÖ«");
|
||||||
|
|
||||||
|
var newUI = GameObject.Instantiate(btn, this.transform);
|
||||||
|
Vector2 player2DPosition = Camera.main.WorldToScreenPoint(buwei1.position);
|
||||||
|
newUI.transform.position = player2DPosition;
|
||||||
|
newUI.gameObject.SetActive(true);
|
||||||
|
newUI.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
Debug.Log("µãÐÜ");
|
||||||
|
moreBtn.transform.position = newUI.transform.position + new Vector3(105f, -40f);
|
||||||
|
moreBtn.gameObject.SetActive(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
var newUI2 = GameObject.Instantiate(btn, this.transform);
|
||||||
|
Vector2 player2DPosition2 = Camera.main.WorldToScreenPoint(buwei2.position);
|
||||||
|
newUI2.transform.position = player2DPosition2;
|
||||||
|
newUI2.gameObject.SetActive(true);
|
||||||
|
newUI2.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
Debug.Log("µãÏÂ");
|
||||||
|
moreBtn.transform.position = newUI2.transform.position + new Vector3(105f, -40f);
|
||||||
|
moreBtn.gameObject.SetActive(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
btn1.onClick.AddListener(() => { moreBtn.gameObject.SetActive(false); });
|
||||||
|
btn2.onClick.AddListener(() => { moreBtn.gameObject.SetActive(false); });
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.Video;
|
||||||
|
|
||||||
|
public class UIFile : UIBase
|
||||||
|
{
|
||||||
|
public GameObject video;
|
||||||
|
public GameObject image;
|
||||||
|
public GameObject URL;
|
||||||
|
public GameObject music;
|
||||||
|
public GameObject text;
|
||||||
|
|
||||||
|
|
||||||
|
public Button close;
|
||||||
|
|
||||||
|
string url;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
close.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIFile); });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(FileType file, string url = null)
|
||||||
|
{
|
||||||
|
this.url = url;
|
||||||
|
switch (file)
|
||||||
|
{
|
||||||
|
case FileType.text:
|
||||||
|
text.SetActive(true);
|
||||||
|
ShowText();
|
||||||
|
break;
|
||||||
|
case FileType.video:
|
||||||
|
video.SetActive(true);
|
||||||
|
ShowVideo();
|
||||||
|
break;
|
||||||
|
case FileType.image:
|
||||||
|
image.SetActive(true);
|
||||||
|
ShowImage();
|
||||||
|
break;
|
||||||
|
case FileType.URL:
|
||||||
|
URL.SetActive(true);
|
||||||
|
ShowURL();
|
||||||
|
break;
|
||||||
|
case FileType.music:
|
||||||
|
music.SetActive(true);
|
||||||
|
ShowMusic();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowImage()
|
||||||
|
{
|
||||||
|
StartCoroutine(DownSprite());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator DownSprite()
|
||||||
|
{
|
||||||
|
UnityWebRequest wr = new UnityWebRequest(url);
|
||||||
|
DownloadHandlerTexture texD1 = new DownloadHandlerTexture(true);
|
||||||
|
wr.downloadHandler = texD1;
|
||||||
|
yield return wr.SendWebRequest();
|
||||||
|
int width = 280;
|
||||||
|
int high = 100;
|
||||||
|
if (!wr.isNetworkError)
|
||||||
|
{
|
||||||
|
Texture2D tex = new Texture2D(width, high);
|
||||||
|
tex = texD1.texture;
|
||||||
|
//保存本地
|
||||||
|
//Byte[] bytes = tex.EncodeToPNG();
|
||||||
|
//File.WriteAllBytes(Application.dataPath + "/" + data.name + ".png", bytes);
|
||||||
|
|
||||||
|
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||||
|
image.GetComponent<Image>().sprite = sprite;
|
||||||
|
//transform.GetComponent<Image>().sprite = sprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowMusic()
|
||||||
|
{
|
||||||
|
AudioSource audio = music.GetComponent<AudioSource>();
|
||||||
|
audio.clip = Resources.Load("UIFile/Music/music1").GetComponent<AudioClip>();
|
||||||
|
|
||||||
|
audio.transform.Find("musicInfo").GetComponent<TextMeshProUGUI>().text = audio.clip.name;
|
||||||
|
Button btn = music.GetComponent<Button>();
|
||||||
|
btn.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
if (audio.isPlaying == true)
|
||||||
|
{
|
||||||
|
audio.Pause();
|
||||||
|
audio.transform.Find("text").GetComponent<TextMeshProUGUI>().text = "播放";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
audio.Play();
|
||||||
|
audio.transform.Find("text").GetComponent<TextMeshProUGUI>().text = "暂停";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowText()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowURL()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowVideo()
|
||||||
|
{
|
||||||
|
VideoPlayer player = video.GetComponent<VideoPlayer>();
|
||||||
|
//Button btn = video.GetComponent<Button>();
|
||||||
|
//btn.onClick.AddListener(() =>
|
||||||
|
//{
|
||||||
|
// if (player.isPlaying == true)
|
||||||
|
// {
|
||||||
|
// player.Pause();
|
||||||
|
// player.transform.Find() = "播放";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// player.Play();
|
||||||
|
// player.text = "暂停";
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
player.source = VideoSource.VideoClip;
|
||||||
|
player.clip = Resources.Load("UIFile/Video/video1").GetComponent<VideoClip>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.source = VideoSource.Url;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIHistory : UIBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public Button close;
|
||||||
|
|
||||||
|
public Button btn1;
|
||||||
|
public Button btn2;
|
||||||
|
public Button btn3;
|
||||||
|
public Button btn4;
|
||||||
|
public Button btn5;
|
||||||
|
public Button btn6;
|
||||||
|
public Button btn7;
|
||||||
|
|
||||||
|
|
||||||
|
private RowsItem currentItem;
|
||||||
|
public Image head;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
currentItem = DataManager.Instance.currentSelectPeople;
|
||||||
|
|
||||||
|
StartCoroutine(DownSprite());
|
||||||
|
|
||||||
|
//this.gameObject.GetComponent<Image>().
|
||||||
|
close.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIHistory); });
|
||||||
|
btn1.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//病人的个人资料
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/diagnosis/patient/base/info/list?diagnosisId=" + currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.peopleInfo;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
|
||||||
|
});
|
||||||
|
btn2.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//咨询的理由
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/diagnosis/event/base/info/list?diagnosisId="+currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.askReason;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
btn3.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//病史详情
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/medical/history/detail/list?diagnosisId=" + currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.historyInfo;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
btn4.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//生活方式
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/diagnosis/life/style/list?diagnosisId=" + currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.lifeType;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
btn5.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//正在进行的治疗
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/diagnosis/heal/info/list?diagnosisId=" + currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.healing;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
btn6.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//完成的检查结果
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85/api/diagnosis/check/result/list?diagnosisId=" + currentItem.id;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.finishCheck;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
btn7.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//其他信息
|
||||||
|
DataManager.Instance.currentHistoryChoose = "http://122.112.171.137:85//api/diagnosis/heal/other/info/list?diagnosisId=" + currentItem.id; ;
|
||||||
|
DataManager.Instance.currentHistoryType = HistoryType.otherInfo;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIHistoryInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
IEnumerator DownSprite()
|
||||||
|
{
|
||||||
|
UnityWebRequest wr = new UnityWebRequest(currentItem.image);
|
||||||
|
DownloadHandlerTexture texD1 = new DownloadHandlerTexture(true);
|
||||||
|
wr.downloadHandler = texD1;
|
||||||
|
yield return wr.SendWebRequest();
|
||||||
|
int width = 280;
|
||||||
|
int high = 100;
|
||||||
|
if (!wr.isNetworkError)
|
||||||
|
{
|
||||||
|
Texture2D tex = new Texture2D(width, high);
|
||||||
|
tex = texD1.texture;
|
||||||
|
//保存本地
|
||||||
|
//Byte[] bytes = tex.EncodeToPNG();
|
||||||
|
//File.WriteAllBytes(Application.dataPath + "/" + data.name + ".png", bytes);
|
||||||
|
|
||||||
|
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||||
|
head.sprite = sprite;
|
||||||
|
//transform.GetComponent<Image>().sprite = sprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIHistoryInfo : UIBase
|
||||||
|
{
|
||||||
|
public Button close;
|
||||||
|
|
||||||
|
public GameObject infoItem;
|
||||||
|
|
||||||
|
public Transform content;
|
||||||
|
|
||||||
|
string dataURL = string.Empty;
|
||||||
|
|
||||||
|
int currentDiaID = -1;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
close.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIHistoryInfo); });
|
||||||
|
|
||||||
|
var allData = DataManager.Instance.currentPeoplesQuestion;
|
||||||
|
if (allData != null)
|
||||||
|
{
|
||||||
|
if (allData.Count > 0)
|
||||||
|
{
|
||||||
|
currentDiaID = allData[0].diagnosisId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataURL = DataManager.Instance.currentHistoryChoose + currentDiaID;
|
||||||
|
Debug.Log(dataURL);
|
||||||
|
DataParse.Instance.ParsePeopleInfo(dataURL);
|
||||||
|
|
||||||
|
EventCenter.dispatcher.AddListener(MsgType.OnGetPeopleInfo2, OnGetPeopleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetPeopleInfo(Message evt)
|
||||||
|
{
|
||||||
|
var currentInfo = DataManager.Instance.rowitems2;
|
||||||
|
for (int i = 0; i < currentInfo.Count; i++)
|
||||||
|
{
|
||||||
|
var data = currentInfo[i];
|
||||||
|
var newUI = GameObject.Instantiate(infoItem, content);
|
||||||
|
string sex = data.sex == 0 ? "男" : "女";
|
||||||
|
newUI.transform.Find("info").GetComponent<Text>().text = "姓:" + data.familyName + " 名:" + data.name + "/n性别:" + sex + "/n职业:" + data.occupation;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
public class UILinkText : MonoBehaviour, IPointerClickHandler
|
||||||
|
{
|
||||||
|
public TextMeshProUGUI txt;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
txt.text = "<link='°Ù¶È'><u>www.baidu.com</u></link>";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerClick(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
Application.OpenURL(txt.text);
|
||||||
|
Vector3 pos = new Vector3(eventData.position.x, eventData.position.y, 0);
|
||||||
|
int linkIndex = TMP_TextUtilities.FindIntersectingLink(txt, pos, null); //--UIÏà»ú
|
||||||
|
if (linkIndex > -1)
|
||||||
|
{
|
||||||
|
TMP_LinkInfo linkInfo = txt.textInfo.linkInfo[linkIndex];
|
||||||
|
//Debug.Log(linkInfo.GetLinkText());
|
||||||
|
Application.OpenURL(linkInfo.GetLinkText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIPeopleInfoItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Image head;
|
||||||
|
public Image headBG;
|
||||||
|
public TextMeshProUGUI infoTxt;
|
||||||
|
public TextMeshProUGUI lauguage;
|
||||||
|
public Button beginBtn;
|
||||||
|
string imgurl;
|
||||||
|
string headurl;
|
||||||
|
private RowsItem data;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (head == null)
|
||||||
|
{
|
||||||
|
Debug.LogError(this.gameObject.name + "Head is Null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (infoTxt == null)
|
||||||
|
{
|
||||||
|
Debug.LogError(this.gameObject.name + "infoTxt is Null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (beginBtn == null)
|
||||||
|
{
|
||||||
|
Debug.LogError(this.gameObject.name + "beginBtn is Null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(RowsItem item)
|
||||||
|
{
|
||||||
|
this.data = item;
|
||||||
|
head.sprite = Resources.Load<Sprite>("");
|
||||||
|
infoTxt.text = data.name + "-" + data.specialty;
|
||||||
|
lauguage.text = data.languageType;
|
||||||
|
imgurl = data.image;
|
||||||
|
StartCoroutine(DownSprite());
|
||||||
|
beginBtn.onClick.AddListener(OnClickBegin);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator DownSprite()
|
||||||
|
{
|
||||||
|
UnityWebRequest wr = new UnityWebRequest(imgurl);
|
||||||
|
DownloadHandlerTexture texD1 = new DownloadHandlerTexture(true);
|
||||||
|
wr.downloadHandler = texD1;
|
||||||
|
yield return wr.SendWebRequest();
|
||||||
|
int width = 280;
|
||||||
|
int high = 100;
|
||||||
|
if (!wr.isNetworkError)
|
||||||
|
{
|
||||||
|
Texture2D tex = new Texture2D(width, high);
|
||||||
|
tex = texD1.texture;
|
||||||
|
//保存本地
|
||||||
|
//Byte[] bytes = tex.EncodeToPNG();
|
||||||
|
//File.WriteAllBytes(Application.dataPath + "/" + data.name + ".png", bytes);
|
||||||
|
|
||||||
|
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||||
|
headBG.sprite = sprite;
|
||||||
|
head.sprite = sprite;
|
||||||
|
//transform.GetComponent<Image>().sprite = sprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClickBegin()
|
||||||
|
{
|
||||||
|
//进入下一个界面
|
||||||
|
DataManager.Instance.currentSelectPeople = data;
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIPeopleProgress);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using TMPro;
|
||||||
|
using System;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
|
||||||
|
public class UIPeopleProgress : UIBase
|
||||||
|
{
|
||||||
|
private RowsItem currentItem;
|
||||||
|
|
||||||
|
public Image bg;
|
||||||
|
public Image head;
|
||||||
|
public TextMeshProUGUI nameTxt;
|
||||||
|
public TextMeshProUGUI descriptionTxt;
|
||||||
|
public Button close;
|
||||||
|
public TextMeshProUGUI hintTxt;
|
||||||
|
|
||||||
|
public Image progressImg;
|
||||||
|
public TextMeshProUGUI progressTxt;
|
||||||
|
public Button resetBtn;
|
||||||
|
public TextMeshProUGUI progressHintTxt;
|
||||||
|
|
||||||
|
string imgurl;
|
||||||
|
|
||||||
|
public Transform content;
|
||||||
|
|
||||||
|
public List<UIProgressItem> listP;
|
||||||
|
|
||||||
|
|
||||||
|
public List<DataItem> currentData;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
currentItem = DataManager.Instance.currentSelectPeople;
|
||||||
|
|
||||||
|
close.onClick.AddListener(DestroyThisUI);
|
||||||
|
|
||||||
|
EventCenter.dispatcher.AddListener(MsgType.OnGetCurrentPeopleProgress, OnGetCurrentData);
|
||||||
|
|
||||||
|
GetPeopleInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DestroyThisUI()
|
||||||
|
{
|
||||||
|
UIManager.Instance.DestoryUI(UIType.UIPeopleProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
EventCenter.dispatcher.RemoveListener(MsgType.OnGetCurrentPeopleProgress, OnGetCurrentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProgress()
|
||||||
|
{
|
||||||
|
float p = 1;
|
||||||
|
progressImg.fillAmount = p;
|
||||||
|
progressTxt.text = p * 100 + "%";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetCurrentData(Message evt)
|
||||||
|
{
|
||||||
|
imgurl = currentItem.image;
|
||||||
|
nameTxt.text = currentItem.name + "-" + currentItem.specialty;
|
||||||
|
descriptionTxt.text = currentItem.languageType;
|
||||||
|
currentData = DataManager.Instance.currentPeoplesProgress;
|
||||||
|
SetProgress();
|
||||||
|
StartCoroutine(DownSprite());
|
||||||
|
|
||||||
|
if (currentData != null)
|
||||||
|
{
|
||||||
|
listP = new List<UIProgressItem>();
|
||||||
|
GameObject Prefab = (GameObject)Resources.Load("UIPrefabs/UIProgressItem");
|
||||||
|
for (int i = 0; i < currentData.Count; i++)
|
||||||
|
{
|
||||||
|
UIProgressItem item = Instantiate(Prefab, content).GetComponent<UIProgressItem>();
|
||||||
|
listP.Add(item);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
item.CloseBG();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < currentData.Count; i++)
|
||||||
|
{
|
||||||
|
listP[i].SetTitle(currentData[i].title);
|
||||||
|
listP[i].SetData(currentData[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator DownSprite()
|
||||||
|
{
|
||||||
|
UnityWebRequest wr = new UnityWebRequest(imgurl);
|
||||||
|
DownloadHandlerTexture texD1 = new DownloadHandlerTexture(true);
|
||||||
|
wr.downloadHandler = texD1;
|
||||||
|
yield return wr.SendWebRequest();
|
||||||
|
int width = 280;
|
||||||
|
int high = 100;
|
||||||
|
if (!wr.isNetworkError)
|
||||||
|
{
|
||||||
|
Texture2D tex = new Texture2D(width, high);
|
||||||
|
tex = texD1.texture;
|
||||||
|
//±£´æ±¾µØ
|
||||||
|
//Byte[] bytes = tex.EncodeToPNG();
|
||||||
|
//File.WriteAllBytes(Application.dataPath + "/" + data.name + ".png", bytes);
|
||||||
|
|
||||||
|
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
|
||||||
|
bg.sprite = sprite;
|
||||||
|
head.sprite = sprite;
|
||||||
|
//transform.GetComponent<Image>().sprite = sprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetPeopleInfo()
|
||||||
|
{
|
||||||
|
string url = "http://122.112.171.137:85/api/diagnosis/info/list?casesId=" + currentItem.id;
|
||||||
|
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.ParsePeopleList(receiveContent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIProgressItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Button playBtn;
|
||||||
|
public Button moreBtn;
|
||||||
|
public TextMeshProUGUI titleTxt;
|
||||||
|
public Image bg;
|
||||||
|
|
||||||
|
public DataItem data;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
playBtn.onClick.AddListener(Show);
|
||||||
|
moreBtn.onClick.AddListener(ShowMore);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Show()
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentData = data;
|
||||||
|
UIManager.Instance.CloseAllUI();
|
||||||
|
UIManager.Instance.OpenUI(UIType.UITalkMain);
|
||||||
|
DataManager.Instance.GetGameData().ShowTalkMan();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseBG()
|
||||||
|
{
|
||||||
|
bg.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowMore()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTitle(string title)
|
||||||
|
{
|
||||||
|
titleTxt.text = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData(DataItem item)
|
||||||
|
{
|
||||||
|
this.data = item;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIQuitAll : UIBase
|
||||||
|
{
|
||||||
|
public Button close;
|
||||||
|
public List<Button> questions;
|
||||||
|
|
||||||
|
List<DataItem2> currentPeoplesQuestion;
|
||||||
|
|
||||||
|
|
||||||
|
public Transform content;
|
||||||
|
public GameObject button;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
close.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
UIManager.Instance.DestoryUI(UIType.UIQuitAll);
|
||||||
|
UIManager.Instance.ShowMainUI();
|
||||||
|
});
|
||||||
|
//for (int i = 0; i < questions.Length; i++)
|
||||||
|
//{
|
||||||
|
// questions[i].onClick.AddListener(() => { UIManager.Instance.OpenUI(UIType.UIAnswer); });
|
||||||
|
//}
|
||||||
|
currentPeoplesQuestion = new List<DataItem2>();
|
||||||
|
questions = new List<Button>();
|
||||||
|
var allQuestion = DataManager.Instance.currentPeoplesQuestion;
|
||||||
|
for (int i = 0; i < allQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
if (allQuestion[i].type == 4)
|
||||||
|
{
|
||||||
|
currentPeoplesQuestion.Add(allQuestion[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < currentPeoplesQuestion.Count; i++)
|
||||||
|
{
|
||||||
|
var newUI = GameObject.Instantiate(button, content);
|
||||||
|
newUI.SetActive(true);
|
||||||
|
var tempData = currentPeoplesQuestion[i];
|
||||||
|
newUI.GetComponentInChildren<TextMeshProUGUI>().text = tempData.title;
|
||||||
|
var btn = newUI.GetComponent<Button>();
|
||||||
|
questions.Add(btn);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < questions.Count; i++)
|
||||||
|
{
|
||||||
|
questions[i].onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
DataManager.Instance.currentQuitQuestion = currentPeoplesQuestion[i];
|
||||||
|
UIManager.Instance.OpenUI(UIType.UIAnswer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class UIRightAnswer : UIBase
|
||||||
|
{
|
||||||
|
public Button returnBtn;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
returnBtn.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIRightAnswer); });
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
using Crosstales.RTVoice.Tool;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using DG.Tweening;
|
||||||
|
using static Unity.Burst.Intrinsics.X86.Avx;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class UITalk : UIBase
|
||||||
|
{
|
||||||
|
public TextMeshProUGUI talkTxt;
|
||||||
|
public Button nextBtn;
|
||||||
|
public Image doc, p;
|
||||||
|
|
||||||
|
public SpeechText speak;
|
||||||
|
|
||||||
|
List<DataItem3> talkList;
|
||||||
|
static int currentTalkIndex = 0;
|
||||||
|
|
||||||
|
Animator talkMan;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
speak = GameObject.Find("SpeechText").GetComponent<SpeechText>();
|
||||||
|
doc = this.gameObject.transform.Find("doc").GetComponent<Image>();
|
||||||
|
p = this.gameObject.transform.Find("people").GetComponent<Image>();
|
||||||
|
talkMan = DataManager.Instance.GetGameData().talkMan;
|
||||||
|
talkList = new List<DataItem3>();
|
||||||
|
currentTalkIndex = 0;
|
||||||
|
nextBtn.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
//BeginTalk();
|
||||||
|
});
|
||||||
|
GetTalkMsg();
|
||||||
|
EventCenter.dispatcher.AddListener(MsgType.OnGetTalkMsg, OnGetTalkData);
|
||||||
|
|
||||||
|
if (!DataManager.Instance.isAddEventRTVoice)
|
||||||
|
{
|
||||||
|
speak.OnSpeechTextComplete += OnSpeakEnd;
|
||||||
|
DataManager.Instance.isAddEventRTVoice = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSpeakEnd()
|
||||||
|
{
|
||||||
|
BeginTalk();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
EventCenter.dispatcher.RemoveListener(MsgType.OnGetTalkMsg, OnGetTalkData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetTalkData(Message evt)
|
||||||
|
{
|
||||||
|
this.talkList = DataManager.Instance.currentTalk;
|
||||||
|
if (this.talkList != null)
|
||||||
|
{
|
||||||
|
if (currentTalkIndex >= this.talkList.Count)
|
||||||
|
{
|
||||||
|
UIManager.Instance.DestoryUI(UIType.UITalk);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BeginTalk(this.talkList[currentTalkIndex].msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeginTalk()
|
||||||
|
{
|
||||||
|
this.talkList = DataManager.Instance.currentTalk;
|
||||||
|
if (this.talkList != null)
|
||||||
|
{
|
||||||
|
if (currentTalkIndex >= this.talkList.Count)
|
||||||
|
{
|
||||||
|
UIManager.Instance.DestoryUI(UIType.UITalk);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BeginTalk(this.talkList[currentTalkIndex].msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeginTalk(string talk)
|
||||||
|
{
|
||||||
|
speak.Text = talk;
|
||||||
|
//talkTxt.DOText
|
||||||
|
talkTxt.text = talk;
|
||||||
|
speak.Speak();
|
||||||
|
string text = talkTxt.text;
|
||||||
|
var t = DOTween.To(() => string.Empty, value => talkTxt.text = value, text, talk.Length > 5 ? 2f : 1f).SetEase(Ease.Linear);
|
||||||
|
t.SetOptions(true);
|
||||||
|
if (null == this)
|
||||||
|
{
|
||||||
|
this.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
if (this.talkList[currentTalkIndex].senderCode == 2)
|
||||||
|
{
|
||||||
|
//ResetTalkMan();
|
||||||
|
//talkMan.SetBool("totalk", true);
|
||||||
|
p?.gameObject.SetActive(true);
|
||||||
|
doc?.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
else if (this.talkList[currentTalkIndex].senderCode == 1)
|
||||||
|
{
|
||||||
|
//ResetTalkMan();
|
||||||
|
//talkMan.SetBool("tolisten", true);
|
||||||
|
p?.gameObject.SetActive(false);
|
||||||
|
doc?.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
currentTalkIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetTalkMan()
|
||||||
|
{
|
||||||
|
talkMan.SetBool("totalk", false);
|
||||||
|
talkMan.SetBool("tolisten", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetTalkMsg()
|
||||||
|
{
|
||||||
|
var people = DataManager.Instance.currentSelectPeople;
|
||||||
|
var id = DataManager.Instance.currentData.id;
|
||||||
|
//http://122.112.171.137:85/api/diagnosis/message/list/{backgroundType}/{relationId}
|
||||||
|
string url = "http://122.112.171.137:85/api/diagnosis/message/list/" + DataManager.Instance.currentBGType + "/" + id;
|
||||||
|
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.ParsePeopleTalk(receiveContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,350 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue