93 lines
2.1 KiB
C#
93 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using Newtonsoft.Json;
|
|
|
|
public abstract class ScoreBase : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 系统id
|
|
/// </summary>
|
|
public int systemId;
|
|
/// <summary>
|
|
/// 科目id
|
|
/// </summary>
|
|
public int schemeId;
|
|
|
|
/// <summary>
|
|
/// 科目满分
|
|
/// </summary>
|
|
protected float maxScore = 100;
|
|
/// <summary>
|
|
/// 科目得分s
|
|
/// </summary>
|
|
protected float currentScore;
|
|
/// <summary>
|
|
/// 此科目步骤
|
|
/// </summary>
|
|
protected Dictionary<int, ScoreSubjectStep> steps;
|
|
|
|
public Device_Control device_Control;
|
|
public virtual void Init()
|
|
{
|
|
systemId = int.Parse(transform.parent.name);
|
|
schemeId = int.Parse(transform.name);
|
|
}
|
|
|
|
public virtual void SetDeviceControl(Device_Control device_Control)
|
|
{
|
|
this.device_Control = device_Control;
|
|
}
|
|
/// <summary>
|
|
/// 判分
|
|
/// </summary>
|
|
public virtual void CheckScore(string triggerName,object para)
|
|
{
|
|
|
|
}
|
|
public virtual void SetScore(List<float> scores)
|
|
{
|
|
for (int i = 0; i < scores.Count; i++)
|
|
{
|
|
steps[i+1].maxScore= scores[i];
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取总分
|
|
/// </summary>
|
|
public float GetTotalScore()
|
|
{
|
|
float all = 0;
|
|
foreach (var item in steps)
|
|
{
|
|
all+=item.Value.currentScore;
|
|
if(item.Value.isOneVoteVeto && item.Value.currentScore==0)
|
|
{
|
|
all = 0;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Debug.LogError("总分为:" + all);
|
|
return all;
|
|
}
|
|
/// <summary>
|
|
/// 返回成绩详情
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Dictionary<int, ScoreSubjectStep> GetStepScore()
|
|
{
|
|
//Debug.LogError(JsonConvert.SerializeObject(steps));
|
|
return steps;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置科目得分,用于断线重连恢复
|
|
/// </summary>
|
|
public void setCurrentScore(float _score)
|
|
{
|
|
this.currentScore = _score;
|
|
}
|
|
}
|