using ChartAndGraph; using Newtonsoft.Json; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using ZXKFramework; namespace DongWuYiXue.DaoNiaoShu { public class ChengJiPanel : UIBase { RectTransform content; GameObject step; CanvasRadarChart radar; //GameObject aiSpeak; //Text aiText; public override string GroupName => "ChengJiPanel"; public override string Name => "ChengJiPanel"; public override void Init(IUIManager uictrl) { base.Init(uictrl); content = transform.FindFirst("Content"); step = transform.FindFirst("Step").gameObject; radar = transform.FindFirst("Radar"); } public override void Show() { base.Show(); GeneSteps(GameManager.Instance.kaoheManager.results); transform.FindFirst("timeText").text = GameManager.Instance.timeCounterManager.GetRemainTime(); transform.FindFirst("totalScoreText").text = GameManager.Instance.kaoheManager.totalScore.ToString(); SetRadar(); transform.FindFirst("BottomText").gameObject.SetActive(true); } public void GeneSteps(List steps) { for (int i = 0; i < steps.Count; i++) { int seq = i + 1; Step s = steps[i]; GameObject obj = Instantiate(step, content); obj.SetActive(true); obj.transform.FindFirst("ID").text = seq.ToString(); obj.transform.FindFirst("Name").text = s.stepName; obj.transform.FindFirst("Type").text = s.stepType; obj.transform.FindFirst("MaxScore").text = s.maxScore; obj.transform.FindFirst("Score").text = s.score.ToString(); } } public void SetRadar() { double czjc = 0; double jnzd = 0; double wjgn = 0; double lcsw = 0; double rwgh = 0; double czjc_max = 0; double jnzd_max = 0; double wjgn_max = 0; double lcsw_max = 0; double rwgh_max = 0; List steps = GameManager.Instance.kaoheManager.results; string json = JsonConvert.SerializeObject(steps); foreach (Step step in steps) { switch (step.stepType) { case "基础操作": czjc += Convert.ToDouble(step.score); czjc_max += Convert.ToDouble(step.maxScore); break; case "临床思维": lcsw += Convert.ToDouble(step.score); lcsw_max += Convert.ToDouble(step.maxScore); break; case "技能重点": jnzd += Convert.ToDouble(step.score); jnzd_max += Convert.ToDouble(step.maxScore); break; case "无菌观念": wjgn += Convert.ToDouble(step.score); wjgn_max += Convert.ToDouble(step.maxScore); break; case "人文关怀": rwgh += Convert.ToDouble(step.score); rwgh_max += Convert.ToDouble(step.maxScore); break; } } ////Debug.Log(czjc + "=" + lcsw + "=" + jnzd + "=" + wjgn + "=" + rwgh); if (czjc_max != 0) { radar.DataSource.SetValue("Player 1", "基础操作", czjc / czjc_max * 10); } if (lcsw_max != 0) { radar.DataSource.SetValue("Player 1", "临床思维", lcsw / lcsw_max * 10); } if (jnzd_max != 0) { radar.DataSource.SetValue("Player 1", "技能重点", jnzd / jnzd_max * 10); } if (wjgn_max != 0) { radar.DataSource.SetValue("Player 1", "无菌观念", wjgn / wjgn_max * 10); } if (rwgh_max != 0) { radar.DataSource.SetValue("Player 1", "人文关怀", rwgh / rwgh_max * 10); } string result = "系统消息:请你结合用户的Json成绩数据,对用户的成绩情况做出分析,并给出指导意见" + json.Replace("\"", "\\\""); //Debug.Log("系统消息:请你结合用户的Json成绩数据,对用户的成绩做出分析" + json); //uiManager.GetUI().SendStateToAI(result, () => //{ // transform.FindFirst("BottomText").gameObject.SetActive(false); //}, null, false, false); //ChatUI2.Instance.SendAI(result+", 字数控制在120字内", () => { // transform.FindFirst("BottomText").gameObject.SetActive(false); //}); //ShowSpeak("基础操作满分" + GameManager.Instance.kaoheManager.czjc_Max + "用户得分" + czjc + "技能重点满分"+ GameManager.Instance.kaoheManager.jnzd_Max + "用户得分" + jnzd + "无菌观念满分" + GameManager.Instance.kaoheManager.wjgn_Max + "用户得分" + wjgn + "人文关怀满分" + GameManager.Instance.kaoheManager.rwgh_Max + "用户得分" + rwgh + "临床思维满分" + GameManager.Instance.kaoheManager.lcsw_Max +"用户得分" + lcsw); } //public override void Hide() //{ // base.Hide(); // aiSpeak.SetActive(false); //} } }