我是靠谱客的博主 缓慢眼神,最近开发中收集的这篇文章主要介绍评分面板_C#,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

评分面板

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using FrameWork;
using System.Globalization;
/// <summary>
/// 评价面板
/// </summary>
public class EvaluatePanel : UIPanel
{
    public string uiType = "EvaluatePanel";

    enum OperationEvaluation
    {
        优秀, 良好, 还需努力
    }

    private List<Error> e_Error = new List<Error>();
    public Text e_scoreText;
    public Text e_time;
    //public Text e_evaluation;
    public Text e_Page;
    private int currentNO = 0;
    private int totalNO = 0;
    private int pageLineCount = 3;
    private float currentScore;

    private List<ErrorDetail_Text> errorDetail_Texts;
    private Transform myRectTransfrom;
    protected override void Awake()
    {
        time = DateTime.Now;
        base.Awake();
        myRectTransfrom = this.transform.GetChild(0);
        InitialParameter();
        FrameEntrance.Instance.Event.AddEventListener(CoreEventId.CallUIPanel, _MasterInitial);
    }
    private DateTime time;
    private void Update()
    {
#if UNITY_EDITOR
        //if (Input.GetKeyDown(KeyCode.Q))
        //{
        //    FrameEntrance.Instance.evalution.AddTask("ceshi");
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 12, OperationLogType.操作错误, "nih", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 13, OperationLogType.答题错误, "54545", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 14, OperationLogType.操作错误, "z", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 15, OperationLogType.操作错误, "sdf", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 16, OperationLogType.答题错误, "wfef", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 17, OperationLogType.答题错误, "swewer", -5);
        //    FrameEntrance.Instance.evalution.WriteOperationLog("ceshi", 18, OperationLogType.操作错误, "sdfs", -5);
        //    OpenUIPanel();
        //    GiveParameter("ceshi");
        //    GetTime(600);
        //}
        //if (Input.GetKeyDown(KeyCode.LeftArrow))
        //{
        //    LeftButton();
        //}
        //if (Input.GetKeyDown(KeyCode.RightArrow))
        //{
        //    RightButton();
        //}

#endif
    }

    public override void CloseUIPanel()
    {
        base.CloseUIPanel();
        if (FrameEntrance.Instance != null)
            FrameEntrance.Instance.Event.DispatchCoreEvent(new CoreEvent(CoreEventId.CallUIOperationFinished, true));
    }
    protected override void OnDestroy()
    {
        base.OnDestroy();
        if (FrameEntrance.Instance != null)
            FrameEntrance.Instance.Event.RemoveEventListener(CoreEventId.CallUIPanel, _MasterInitial);
    }
    private void _MasterInitial(CoreEvent coreEvent)
    {
        OpPanelparam op = (OpPanelparam)coreEvent.EventParam;
        Debug.Log(op.panelType);
        if (op.panelType == uiType)
        {


            //FrameEntrance.Instance.evalution.AddTask("农杆菌介导");
            //FrameEntrance.Instance.evalution.WriteOperationLog("农杆菌介导", 12, OperationLogType.操作错误, "ph计错误", -5);
            //FrameEntrance.Instance.evalution.WriteOperationLog("农杆菌介导", 14, OperationLogType.操作错误, "勺子拿取错误", -5);
            //FrameEntrance.Instance.evalution.WriteOperationLog("农杆菌介导", 15, OperationLogType.操作错误, "烧杯放置错误", -5);
            //FrameEntrance.Instance.evalution.WriteOperationLog("农杆菌介导", 18, OperationLogType.操作错误, "选择移液枪错误", -5);


            //FrameEntrance.Instance.evalution.AddTask("拟南芥");
            //FrameEntrance.Instance.evalution.WriteOperationLog("拟南芥", 12, OperationLogType.操作错误, "拿取镊子错误", -10);
            //FrameEntrance.Instance.evalution.WriteOperationLog("拟南芥", 14, OperationLogType.操作错误, "拿取种子错误", -5);
            //FrameEntrance.Instance.evalution.WriteOperationLog("拟南芥", 15, OperationLogType.操作错误, "点击剪刀错误", -5);
            //FrameEntrance.Instance.evalution.WriteOperationLog("拟南芥", 18, OperationLogType.操作错误, "选择移液枪错误", -5);

            OpenUIPanel();
            string[] paStrings = op.param;
            GiveParameter(paStrings[0]);
            GetTime(900);
        }
    }

    private void GiveParameter(string taskName)
    {
        List<OperationLog> oL = new List<OperationLog>();
        oL = FrameEntrance.Instance.evalution.ReadOperationLog(taskName);
        e_Error.Clear();
        for (int i = 0; i < oL.Count; i++)
        {
            if (oL[i].type.Equals(OperationLogType.答题错误))
            {
                e_Error.Add(new Error(OperationLogType.答题错误, oL[i].content, oL[i].score));
            }
            if (oL[i].type.Equals(OperationLogType.操作错误))
            {
                e_Error.Add(new Error(OperationLogType.操作错误, oL[i].content, oL[i].score));

            }
        }
        float totalScore = FrameEntrance.Instance.evalution.GetTaskScore(taskName);

        GetCurrentScore(totalScore);

        //GetEvaluation();

        currentNO = 0;

        int page = e_Error.Count / pageLineCount;
        int reducePage = e_Error.Count % pageLineCount;

        if (reducePage > 0)
        {
            totalNO = Mathf.Clamp(page + 1, currentNO + 1, page + 2);

            e_Page.text = (currentNO + 1).ToString() + " / " + totalNO;
        }
        else
        {
            totalNO = Mathf.Clamp(page, currentNO + 1, page + 1);

            e_Page.text = (currentNO + 1).ToString() + " / " + totalNO;
        }

        GiveParameter(currentNO);
    }

    private void InitialParameter()
    {
        this.errorDetail_Texts = new List<ErrorDetail_Text>();
        for (int i = 0; i < pageLineCount; i++)
        {
            Debug.Log(string.Format("list /{0}/ ErrorStepIndexText", i));
            ErrorDetail_Text errorDetail_Text = new ErrorDetail_Text(myRectTransfrom.Find(string.Format("list/{0}/ErrorStepIndexText", i)).GetComponent<Text>(), myRectTransfrom.Find(string.Format("list/{0}/ErrorInfoText", i)).GetComponent<Text>(), myRectTransfrom.Find(string.Format("list/{0}/ReduceScoreText", i)).GetComponent<Text>());
            errorDetail_Texts.Add(errorDetail_Text);
        }
    }

    private void GetCurrentScore(float score)
    {

        currentScore = Mathf.Clamp(100 + score, 0, Mathf.Infinity);

        e_scoreText.text = currentScore.ToString() + "分";

    }

    private void GetTime(float timer)
    {
        int s = ((int)timer) % 60;
        int m = ((int)timer) / 60;
        int h;
        if (m > 0)
        {
            h = m / 60;
        }
        else
        {
            h = 0;
        }

        if (h > 0)
        {
            m = m - h * 60;
        }
        e_time.text = DateTime.Parse(h + ":" + m + ":" + s).ToString("HH:mm:ss");
    }

    private void GetTime_1(float s)
    {
        DateTime iterm = new DateTime();
        iterm = iterm.AddSeconds(s);
        e_time.text = string.Format("{0:HH:mm:ss}", iterm);
    }
    private void GetTime_1(DateTime beforeTime)
    {
        DateTime iterm = new DateTime();
        TimeSpan timeSpan = DateTime.Now - beforeTime;
        iterm += timeSpan;
        e_time.text = iterm.ToString("HH:mm:ss");
    }

    //private void GetEvaluation()
    //{
    //    if (currentScore > 90)
    //    {
    //        e_evaluation.text = OperationEvaluation.优秀.ToString();
    //    }
    //    else if (currentScore > 80)
    //    {
    //        e_evaluation.text = OperationEvaluation.良好.ToString();
    //    }
    //    else
    //    {
    //        e_evaluation.text = OperationEvaluation.还需努力.ToString();
    //    }

    //}

    public void LeftButton()
    {
        if (currentNO == 0) return;

        currentNO--;

        e_Page.text = (currentNO + 1).ToString() + " / " + totalNO;

        GiveParameter(currentNO);
    }

    public void RightButton()
    {
        if (currentNO == totalNO - 1) return;
        currentNO++;

        e_Page.text = (currentNO + 1).ToString() + " / " + totalNO;

        GiveParameter(currentNO);
    }

    private void GiveParameter(int index)
    {
        for (int i = 0; i < errorDetail_Texts.Count; i++)
        {
            errorDetail_Texts[i].GiveText("", "", "");
            if (index * pageLineCount + i < e_Error.Count)
            {
                errorDetail_Texts[i].GiveText(e_Error[index * pageLineCount + i].errorType.ToString(), e_Error[index * pageLineCount + i].errorInformation, Mathf.Abs(e_Error[index * pageLineCount + i].score).ToString());
            }
        }
    }

}
/// <summary>
/// 错误数据类
/// </summary>
[System.Serializable]
public class Error
{
    public Error(OperationLogType errorType, string information, float score)
    {
        this.errorType = errorType;
        this.errorInformation = information;
        this.score = score;
    }

    public OperationLogType errorType;

    public string errorInformation = "";

    public float score = 0;
}
public class ErrorDetail_Text
{
    public Text e_step;
    public Text e_detail;
    public Text e_deduce;
    public ErrorDetail_Text(Text step, Text detail, Text deduce)
    {
        this.e_step = step;
        this.e_detail = detail;
        this.e_deduce = deduce;
    }

    public void GiveText(string step, string detail, string deduce)
    {
        this.e_step.text = step;
        this.e_detail.text = detail;
        this.e_deduce.text = deduce;
    }
}

 

最后

以上就是缓慢眼神为你收集整理的评分面板_C#的全部内容,希望文章能够帮你解决评分面板_C#所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部