2026-04-07 17:36:53 +08:00

135 lines
5.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using ChartAndGraph;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ZXKFramework;
namespace YiLiao.XinFeiTingZhen
{
public class ChengJiPanel : UIBase
{
RectTransform content;
GameObject step;
CanvasRadarChart radar;
public override string GroupName => "ChengJiPanel";
public override string Name => "ChengJiPanel";
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
content = transform.FindFirst<RectTransform>("Content");
step = transform.FindFirst<Transform>("Step").gameObject;
radar = transform.FindFirst<CanvasRadarChart>("Radar");
}
public override void Show()
{
base.Show();
GeneSteps(GameManager.Instance.kaoheManager.results);
transform.FindFirst<Text>("timeText").text = GameManager.Instance.timeCounterManager.GetRemainTime();
transform.FindFirst<Text>("totalScoreText").text = GameManager.Instance.kaoheManager.totalScore.ToString();
SetRadar();
transform.FindFirst<Text>("BottomText").gameObject.SetActive(true);
}
public void GeneSteps(List<Step> 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<Text>("ID").text = seq.ToString();
if (!string.IsNullOrEmpty(s.name2))
{
if (!string.IsNullOrEmpty(s.name3))
{
if (!string.IsNullOrEmpty(s.name4))
{
obj.transform.FindFirst<Text>("Name").text = s.name1 + "-" + s.name2 + "-" + s.name3 + "-" + s.name4;
}
else
{
obj.transform.FindFirst<Text>("Name").text = s.name1 + "-" + s.name2 + "-" + s.name3;
}
}
else
{
obj.transform.FindFirst<Text>("Name").text = s.name1 + "-" + s.name2;
}
}
else
{
obj.transform.FindFirst<Text>("Name").text = s.name1;
}
obj.transform.FindFirst<Text>("Type").text = s.stepType;
obj.transform.FindFirst<Text>("MaxScore").text = s.maxScore;
obj.transform.FindFirst<Text>("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<Step> 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;
}
}
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)
{
this.Error($"{rwgh}max:{rwgh_max}");
radar.DataSource.SetValue("Player 1", "人文关怀", rwgh / rwgh_max * 10);
}
string result = "系统消息请你结合用户的Json成绩数据对用户的成绩情况做出分析,并给出指导意见" + json.Replace("\"", "\\\"");
}
}
}