140 lines
4.2 KiB
C#
140 lines
4.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using static LoginSceneUIManager;
|
|
using System;
|
|
using Newtonsoft.Json.Linq;
|
|
using UnityEngine.SceneManagement;
|
|
using System.Linq;
|
|
using static CourseTaskItem;
|
|
using OpenCVForUnity.DnnModule;
|
|
|
|
/// <summary>
|
|
/// 关卡详情面板
|
|
/// </summary>
|
|
public class LevelDetailPanel : PanelBasic
|
|
{
|
|
/// <summary>
|
|
/// 开始关卡按钮
|
|
/// </summary>
|
|
public Button start_level_button;
|
|
/// <summary>
|
|
/// 关卡编号
|
|
/// </summary>
|
|
public TextMeshProUGUI level_index_text;
|
|
/// <summary>
|
|
/// 关卡标题
|
|
/// </summary>
|
|
public TextMeshProUGUI level_name_text;
|
|
/// <summary>
|
|
/// 组件类型
|
|
/// </summary>
|
|
public TextMeshProUGUI level_type_text;
|
|
/// <summary>
|
|
/// 场景名称
|
|
/// </summary>
|
|
public TextMeshProUGUI level_description_text;
|
|
/// <summary>
|
|
/// 知识点Item预制体
|
|
/// </summary>
|
|
public LevelKnowledgeItem level_knowledge_item_prefab;
|
|
/// <summary>
|
|
/// 知识点Item容器
|
|
/// </summary>
|
|
public RectTransform level_knowledge_item_content;
|
|
|
|
/// <summary>
|
|
/// 关卡数据
|
|
/// </summary>
|
|
|
|
public CourseTaskItem.CourseTaskItemData current_task_data;
|
|
|
|
|
|
private List<LevelKnowledgeItem> level_knowledge_items_pool = new List<LevelKnowledgeItem>();
|
|
|
|
/// <summary>
|
|
/// 当前关卡对应场景
|
|
/// </summary>
|
|
public string scene_name = "";
|
|
|
|
|
|
void Start()
|
|
{
|
|
start_level_button.onClick.AddListener(() => { OnStartLevel(current_task_data); });
|
|
}
|
|
|
|
public void Init(CourseTaskItem.CourseTaskItemData _task_level_data, int _index)
|
|
{
|
|
if (current_task_data == null || current_task_data != _task_level_data)
|
|
{
|
|
current_task_data = _task_level_data;
|
|
level_index_text.text = string.Format("第{0}关", _index);
|
|
level_name_text.text = current_task_data.taskName;
|
|
level_type_text.text =current_task_data.contentName;
|
|
level_description_text.text = _task_level_data.sceneName;
|
|
scene_name= _task_level_data.sceneName;
|
|
|
|
//考察点
|
|
level_knowledge_items_pool.ForEach(x => x.is_used = false);
|
|
|
|
for (int i = 0; i < current_task_data.investigatePointList.Count; i++)
|
|
{
|
|
var _item = Get(i);
|
|
_item.Init(current_task_data.investigatePointList[i]);
|
|
}
|
|
|
|
level_knowledge_items_pool.ForEach(x => x.UpdateState());
|
|
|
|
}
|
|
|
|
current_task_data = _task_level_data;
|
|
}
|
|
|
|
public void OnStartLevel(CourseTaskItemData courseTaskItemData)
|
|
{
|
|
GameManager.current_main_menu_type = MainMenuType.课程任务;
|
|
//获取recordid
|
|
string url = InterfaceManager.IdAddress + ":8080/postback/getTaskRecordId?contentId="+ courseTaskItemData.contentId + "&courseId="+ courseTaskItemData .courseId+ "&userId="+CallForTest.instance.user.userId+"&taskId="+ courseTaskItemData.taskId;
|
|
StartCoroutine(InterfaceManager.Get(url, (result, msg) =>
|
|
{
|
|
if (result)
|
|
{
|
|
JObject jb = JObject.Parse(msg);
|
|
CallForTest.instance.recordId=jb["data"]["id"].ToString();
|
|
//获取任务详情,双击启动程序,手动选择任务并启动
|
|
CallForTest.instance.GetTaskDetail(courseTaskItemData.taskId, courseTaskItemData.contentId, courseTaskItemData.programLanguage);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(msg);
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 关卡知识点 对象管理
|
|
/// </summary>
|
|
/// <param name="_index"></param>
|
|
/// <returns></returns>
|
|
public LevelKnowledgeItem Get(int _index)
|
|
{
|
|
LevelKnowledgeItem _item;
|
|
if (level_knowledge_items_pool.Count > _index)
|
|
{
|
|
_item = level_knowledge_items_pool[_index];
|
|
}
|
|
else
|
|
{
|
|
if (level_knowledge_item_prefab == null)
|
|
level_knowledge_item_prefab = Resources.Load<LevelKnowledgeItem>("Prefabs/UIItem/LevelKnowledgeItem");
|
|
_item = Instantiate(level_knowledge_item_prefab, level_knowledge_item_content);
|
|
level_knowledge_items_pool.Add(_item);
|
|
}
|
|
_item.is_used = true;
|
|
return _item;
|
|
}
|
|
}
|