using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InspectSettlementPanel : MonoBehaviour
{
// Use this for initialization
public TextMesh tagText_WaiXiang, tagTextFuJian, tagText_PeiZhi;//结果面板小标题
public Transform ResultViewListParent_WaiXiang;//结果列表外箱位置
public Transform WaiXiangParent;
public Transform ResultViewListParent_FuJian;//结果列表附件位置
public Transform FuJianParent;
public Transform ResultViewListParent_PeiZhi;//结果列表配置位置
public Transform PeiZhiParent;
public GameObject resultView;
//public ReadXMLWaiXiang readXML_WaiXiang;
//public ReadXMLFuJian readXML_FuJian;
//public ReadXMLPeiZhi readXML_PeiZhi;
protected Transform startPos; //生成的位置
public InspectListPanel inspectList;
private string waiXiang = "外箱";
private string fuJiang = "附件";
private string peiZhi = "配置";
public TextMesh EquipmentType;//设备型号
public TextMesh CheckQuantity;//检查数量
public TextMesh pass_Num;//检查合格通过数量
public TextMesh pass_No_Num;//检查不合格数量
public TextMesh player_Name;//检查人员名单
public TextMesh player_WorkNumber;//检查人员工号
public TextMesh CheckTimer;//检查时间
private int passNum;
private int passNoNum;
void Start()
{
resultView = Resources.Load("ResultView") as GameObject;
MakeResultView();
CheckQuantity.text = "检查项目: " + inspectList.taskList.Count.ToString() + " 项目";
GetInspectList_ButtonPassNum();
pass_Num.text = passNum.ToString();
pass_Num.color = Color.green;
pass_No_Num.text = passNoNum.ToString();
pass_No_Num.color = Color.red;
}
///
/// 获取合格的数量
///
void GetInspectList_ButtonPassNum()
{
for (int i = 0; i < inspectList.taskList.Count; i++)
{
if (inspectList.taskList[i].GetComponent().status == 2)
{
passNum++;
}
else if (inspectList.taskList[i].GetComponent().status == 3)
{
passNoNum++;
}
}
}
// Update is called once per frame
void MakeResultView()
{
for (int i = 0; i < inspectList.taskList.Count; i++)
{
if (inspectList.taskList[i].GetComponent().mainSubtasks == waiXiang)
{
if (WaiXiangParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent().text_num.text) == null)
{
startPos = ResultViewListParent_WaiXiang.Find(inspectList.taskList[i].GetComponent().endResultViewPos).gameObject.transform;
GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
obj.transform.parent = WaiXiangParent.transform;
obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
obj.name = "ResultView" + inspectList.taskList[i].GetComponent().text_num.text;
obj.GetComponent().SetText_ID(inspectList.taskList[i].GetComponent().text_num.text);
obj.GetComponent().SetText_Tag(inspectList.taskList[i].GetComponent().text_name.text);
obj.GetComponent().SetText_Status(inspectList.taskList[i].GetComponent().startInspect);
tagText_WaiXiang.text = inspectList.taskList[i].GetComponent().mainSubtasks + "检查结果";
}
}
if (inspectList.taskList[i].GetComponent().mainSubtasks == fuJiang)
{
if (FuJianParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent().text_num.text) == null)
{
startPos = ResultViewListParent_FuJian.Find(inspectList.taskList[i].GetComponent().endResultViewPos).gameObject.transform;
GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
obj.transform.parent = FuJianParent.transform;
obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
obj.name = "ResultView" + inspectList.taskList[i].GetComponent().text_num.text;
obj.GetComponent().SetText_ID(inspectList.taskList[i].GetComponent().text_num.text);
obj.GetComponent().SetText_Tag(inspectList.taskList[i].GetComponent().text_name.text);
obj.GetComponent().SetText_Status(inspectList.taskList[i].GetComponent().startInspect);
tagTextFuJian.text = inspectList.taskList[i].GetComponent().mainSubtasks + "检查结果";
}
}
if (inspectList.taskList[i].GetComponent().mainSubtasks == peiZhi)
{
if (PeiZhiParent.transform.Find("ResultView" + inspectList.taskList[i].GetComponent().text_num.text) == null)
{
tagText_PeiZhi.text = inspectList.taskList[i].GetComponent().mainSubtasks + "检查结果";
startPos = ResultViewListParent_PeiZhi.Find(inspectList.taskList[i].GetComponent().endResultViewPos).gameObject.transform;
GameObject obj = Instantiate(resultView, new Vector3(startPos.position.x, startPos.position.y, startPos.position.z), Quaternion.Euler(0, 0, 0));
obj.transform.parent = PeiZhiParent.transform;
obj.transform.localEulerAngles = new Vector3(0f, -180f, 0f);
obj.name = "ResultView" + inspectList.taskList[i].GetComponent().text_num.text;
obj.GetComponent().SetText_ID(inspectList.taskList[i].GetComponent().text_num.text);
obj.GetComponent().SetText_Tag(inspectList.taskList[i].GetComponent().text_name.text);
obj.GetComponent().SetText_Status(inspectList.taskList[i].GetComponent().startInspect);
}
}
}
}
}