111 lines
5.4 KiB
C#
111 lines
5.4 KiB
C#
using CG.Framework;
|
||
using CG.UTility;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
/*******************************************************************************
|
||
*Create By CG
|
||
*Function
|
||
*******************************************************************************/
|
||
namespace ZXK.LouDiXvMuNiu
|
||
{
|
||
public class SelectToolsPanel : UIBase
|
||
{
|
||
private Transform _toolsContent = null;
|
||
private GameObject _toolItemPrefab = null;
|
||
|
||
private List<GameObject> _toolBtnArray = new List<GameObject>();
|
||
private int _allTools = 0;
|
||
private int _curToolNumber = 0;
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
_toolsContent = GetWedage("ToolsItemContent_N").transform;
|
||
_toolItemPrefab = GetWedage("SelectToolsPanel_ToolsItem_N");
|
||
CreateTool();
|
||
}
|
||
private void OnEnable()
|
||
{
|
||
for (int i = 0; i < _toolBtnArray.Count; i++)
|
||
{
|
||
_toolBtnArray[i].transform.Find("BeUseImg").gameObject.SetActive(false);
|
||
//_toolBtnArray[i].transform.Find("BeUseImg/ChoseRight").gameObject.SetActive(false);
|
||
//_toolBtnArray[i].transform.Find("BeUseImg/ChoseError").gameObject.SetActive(false);
|
||
}
|
||
}
|
||
private void CreateTool()
|
||
{
|
||
List<NiuData> tempData = GameManager.Instance._DataNiuHandler.NiuStepTypeDic[GameManager.Instance._CurModelType];
|
||
for (int i = 0; i < tempData.Count; i++)
|
||
{
|
||
string itemTools = tempData[i].ToolsName;
|
||
string itemErroTools= tempData[i].OptionErro;
|
||
if (string.IsNullOrEmpty(itemTools)) continue;
|
||
string[] rightTools = itemTools.Split("|");
|
||
_allTools = rightTools.Length;
|
||
string[] erroTools = itemErroTools.Split("|");
|
||
string[] allTools = new string[rightTools.Length + erroTools.Length];
|
||
rightTools.CopyTo(allTools, 0);
|
||
erroTools.CopyTo(allTools, rightTools.Length);
|
||
|
||
for (int j = 0; j < allTools.Length; j++)
|
||
{
|
||
GameObject toolItemGeo = Instantiate(_toolItemPrefab, _toolsContent);
|
||
toolItemGeo.name = allTools[j];
|
||
toolItemGeo.transform.Find("NoUseImg/Text").GetComponent<Text>().text = allTools[j];
|
||
Sprite sprite = Resources.Load<Sprite>("ToolsLogo/" + allTools[j]);
|
||
//UtilitiesMng.LoadSpriteByURL(ItemInfo[i].picURL, (sprite) =>
|
||
//{
|
||
//DataBJCJHandler._BJCZSpriteArray.Add(ItemInfo[i].partName, sprite);
|
||
toolItemGeo.transform.Find("ToolsConnet").GetComponent<Image>().sprite = sprite;
|
||
//});
|
||
|
||
toolItemGeo.GetComponent<Button>().onClick.AddListener(() =>
|
||
{
|
||
NiuData curStep = GameManager.Instance._DataNiuHandler.CurNiuHandler.Value;
|
||
if (!curStep.TaskType.Equals(ConstCtrl.TASKTYPE_ShowGeo)) return;
|
||
toolItemGeo.GetComponent<Button>().interactable = false;
|
||
string[] curTools = curStep.ToolsName.Split("|");
|
||
|
||
bool rightSelect = false;
|
||
for (int i = 0; i < curTools.Length; i++)
|
||
{
|
||
if (curTools[i].Equals(toolItemGeo.name)) rightSelect = true;
|
||
}
|
||
if (rightSelect)
|
||
{
|
||
toolItemGeo.transform.Find("BeUseImg").gameObject.SetActive(true);
|
||
toolItemGeo.transform.Find("BeUseImg/ChoseRight").gameObject.SetActive(true);
|
||
GameManager.Instance._EventManager.Raise(new ClickToolArgs() { SelectTool = toolItemGeo.name });
|
||
// GameManager.Instance._DataNiuHandler.AddScore(curStep.ModuleName, curStep.ThreeTaskName, 1);
|
||
_curToolNumber++;
|
||
if (_curToolNumber == _allTools)
|
||
{
|
||
PopUpMng.PopChoseRightToast("<22><>е<D0B5><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 2.0f,()=> {
|
||
NiuData nextStep = GameManager.Instance._DataNiuHandler.GetNextStep();
|
||
GameManager.Instance._DataNiuHandler.CurNiuHandler.Value = nextStep;
|
||
GameManager.Instance._DataNiuHandler.AddScore(curStep.ModuleName, curStep.ThreeTaskName, curStep.Score);
|
||
});
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
PopUpMng.PopChoseErrorToast(curStep.ExamEvvr, 2.0f, () => {
|
||
toolItemGeo.transform.Find("BeUseImg").gameObject.SetActive(true);
|
||
toolItemGeo.transform.Find("BeUseImg/ChoseError").gameObject.SetActive(true);
|
||
});
|
||
// <20><><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
GameManager.Instance._DataNiuHandler.MarkStepAsWrong(curStep.ModuleName, curStep.ThreeTaskName);
|
||
|
||
}
|
||
});
|
||
toolItemGeo.SetActive(true);
|
||
_toolBtnArray.Add(toolItemGeo);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |