using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Newtonsoft.Json;
public abstract class ScoreBase : MonoBehaviour
{
///
/// 系统id
///
public int systemId;
///
/// 科目id
///
public int schemeId;
///
/// 科目满分
///
protected float maxScore = 100;
///
/// 科目得分s
///
protected float currentScore;
///
/// 此科目步骤
///
protected Dictionary 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;
}
///
/// 判分
///
public virtual void CheckScore(string triggerName,object para)
{
}
public virtual void SetScore(List scores)
{
for (int i = 0; i < scores.Count; i++)
{
steps[i+1].maxScore= scores[i];
}
}
///
/// 获取总分
///
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;
}
///
/// 返回成绩详情
///
///
public Dictionary GetStepScore()
{
//Debug.LogError(JsonConvert.SerializeObject(steps));
return steps;
}
///
/// 设置科目得分,用于断线重连恢复
///
public void setCurrentScore(float _score)
{
this.currentScore = _score;
}
}