91 lines
2.7 KiB
C#
91 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function 在UI中的二级工序面板预制体
|
|
*******************************************************************************/
|
|
namespace ZXK.ZPS
|
|
{
|
|
public class UISecondPanelCtrl : MonoBehaviour
|
|
{
|
|
[SerializeField]//选中后content
|
|
private Transform _secondContent = null;
|
|
[SerializeField]//备选区content
|
|
private Transform _secondSelectContent = null;
|
|
[SerializeField]
|
|
private GameObject _secondItemPrefab = null;
|
|
|
|
|
|
/// <summary>
|
|
/// 实例化二级面板
|
|
/// </summary>
|
|
/// <param name="secondItemName">一级工序对应的所有二级工序</param>
|
|
public void ShowSecondPanel(Dictionary<string, DataItemModel> secondDic)
|
|
{
|
|
if (GameRoot.Instance._CurModel == UTility.EnumCtrl.Model.Train)
|
|
{
|
|
foreach (DataItemModel item in secondDic.Values)
|
|
{
|
|
GameObject secondItem = Instantiate(_secondItemPrefab, _secondSelectContent);
|
|
UISecondItemCtrl secondCtrl = secondItem.GetComponent<UISecondItemCtrl>();
|
|
secondCtrl.InitItem(item, _secondContent, _secondSelectContent);
|
|
}
|
|
}
|
|
else if(GameRoot.Instance._CurModel == UTility.EnumCtrl.Model.Exam)
|
|
{
|
|
List<string> secondNameTemp = new List<string>();
|
|
foreach (string secondName in secondDic.Keys)
|
|
{
|
|
secondNameTemp.Add(secondName);
|
|
}
|
|
while (secondNameTemp.Count > 0)
|
|
{
|
|
int index = Random.Range(0, secondNameTemp.Count);
|
|
DataItemModel item = secondDic[secondNameTemp[index]];
|
|
GameObject secondItem = Instantiate(_secondItemPrefab, _secondSelectContent);
|
|
UISecondItemCtrl secondCtrl = secondItem.GetComponent<UISecondItemCtrl>();
|
|
secondCtrl.InitItem(item, _secondContent, _secondSelectContent);
|
|
secondNameTemp.RemoveAt(index);
|
|
}
|
|
}
|
|
}
|
|
public void HideSecondPanel()
|
|
{
|
|
foreach (Transform item in _secondSelectContent)
|
|
{
|
|
Destroy(item.gameObject);
|
|
}
|
|
foreach (Transform item in _secondContent)
|
|
{
|
|
Destroy(item.gameObject);
|
|
}
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void SetNextSecondProcess()
|
|
{
|
|
foreach (Transform item in _secondSelectContent)
|
|
{
|
|
if (item.name.Equals(GameRoot.Instance._NextSecondProcess))
|
|
{
|
|
item.GetComponent<UISecondItemCtrl>().SetLight();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取选中的二级工序顺序
|
|
/// </summary>
|
|
public List<string> GetItemOrder()
|
|
{
|
|
List<string> temp = new List<string>();
|
|
foreach (Transform item in _secondContent)
|
|
{
|
|
temp.Add(item.name);
|
|
}
|
|
return temp;
|
|
}
|
|
}
|
|
} |