You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.8 KiB
89 lines
2.8 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class UIViewScore : UIView |
|
{ |
|
|
|
public CommonButton ButtonEnter; |
|
public override UIViewType ViewType |
|
{ |
|
get |
|
{ |
|
return UIViewType.Normal; |
|
} |
|
} |
|
// 本次演练得分 |
|
public Text TotalScore; |
|
// 控火得分 |
|
public Text FireScore; |
|
//救人得分 |
|
public Text SaveScore; |
|
//侦察得分 |
|
public Text LookAtScore; |
|
//冷却得分 |
|
public Text CoolScore; |
|
//供水得分 |
|
public Text WaterScore; |
|
//item父对象 |
|
public GameObject ScrollViewContent; |
|
//item |
|
public GameObject SvContenItem; |
|
private void Awake() |
|
{ |
|
// 设置分数 |
|
TotalScore.text = string.Format("{0:0.0}", ReportDataMgr.GetTotalScore()); |
|
FireScore.text = string.Format("{0:0.0}", ReportDataMgr.GetFireScore()); |
|
SaveScore.text = string.Format("{0:0.0}", ReportDataMgr.GetSaveScore()); |
|
LookAtScore.text = string.Format("{0:0.0}", ReportDataMgr.GetLookAtScore()); |
|
CoolScore.text = string.Format("{0:0.0}", ReportDataMgr.GetCoolScore()); |
|
WaterScore.text = string.Format("{0:0.0}", ReportDataMgr.GetWaterScore()); |
|
// 根据参演人员数量创建ITEM |
|
StartCoroutine(CreateItem()); |
|
} |
|
|
|
private IEnumerator CreateItem() |
|
{ |
|
// 获取参演人员数据 |
|
foreach (var item in ReportDataMgr.ActInScore) |
|
{ |
|
string itemName = item.Key; |
|
float itemScore = item.Value / ReportDataMgr.QuestionnaireNumber; |
|
// 创建问题 |
|
GameObject obj = Instantiate(SvContenItem); |
|
// 记录问题位置,大小 |
|
Vector3 tempPos = obj.transform.localPosition; |
|
Vector3 tempSca = obj.transform.localScale; |
|
// 设置父对象 |
|
obj.transform.SetParent(ScrollViewContent.transform); |
|
obj.transform.localPosition = tempPos; |
|
obj.transform.localScale = tempSca; |
|
// 获取ScriteItem |
|
ScoreItem itemScript = obj.GetComponent<ScoreItem>(); |
|
// 设置Item数据 |
|
itemScript.SetName(itemName); |
|
itemScript.SetScore(string.Format("{0:0.0}", itemScore)); |
|
// 等待当前帧结束 |
|
yield return new WaitForEndOfFrame(); |
|
} |
|
//刷新大小 |
|
LayoutRebuilder.MarkLayoutForRebuild(ScrollViewContent.transform as RectTransform); |
|
} |
|
|
|
private void OnEnable() |
|
{ |
|
ButtonEnter.OnClicked += ButtonEnter_OnClicked; |
|
} |
|
private void OnDisable() |
|
{ |
|
ButtonEnter.OnClicked -= ButtonEnter_OnClicked; |
|
} |
|
private void ButtonEnter_OnClicked(CommonButton obj) |
|
{ |
|
Hide(); |
|
UIManager.ShowView<UIViewAnalyze>(); |
|
} |
|
}
|
|
|