This commit is contained in:
杨号敬 2024-12-26 17:37:30 +08:00
parent 8c3910a8f6
commit 0c334d2c09
5 changed files with 1527 additions and 344 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Windows;
public enum TaskState public enum TaskState
{ {
@ -19,10 +20,30 @@ public class TaskItem : MonoBehaviour
public string taskName; // 任务名称 public string taskName; // 任务名称
public TaskState state; // 任务状态 public TaskState state; // 任务状态
public Text taskTxt; // 任务描述文本 public Text taskTxt; // 任务描述文本
public int overseeCond; //区域id
public int ishow;
public List<TaskTarget> Targets = new List<TaskTarget>(); // 任务目标1列表 public List<TaskTarget> Targets = new List<TaskTarget>(); // 任务目标1列表
private JSONReader jsonReader; // JSON 数据读取器 private JSONReader jsonReader; // JSON 数据读取器
List<int> ExtractNumbers(string input)
{
// 使用 '|' 分割字符串
string[] numberStrings = input.Split("");
// 创建一个列表存储数字
List<int> numbers = new List<int>();
foreach (string numberString in numberStrings)
{
// 尝试将字符串解析为整数
if (int.TryParse(numberString, out int number))
{
numbers.Add(number);
}
}
return numbers;
}
public void SetInfo(int id, JSONReader reader) public void SetInfo(int id, JSONReader reader)
{ {
taskId = id; taskId = id;
@ -35,6 +56,14 @@ public class TaskItem : MonoBehaviour
Task_ info = jsonReader.GetTaskByID(taskId); Task_ info = jsonReader.GetTaskByID(taskId);
taskName = info.Note; taskName = info.Note;
state = TaskState.NotStarted; state = TaskState.NotStarted;
Debug.Log(info.OverseeCond);
ishow = int.Parse(info.IsShow);
Debug.Log(ishow);
if (ishow == 1)
{
overseeCond = int.Parse(info.OverseeCond);
}
Debug.Log(info.Targets1); Debug.Log(info.Targets1);

View File

@ -5,6 +5,8 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using DG.Tweening; using DG.Tweening;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine.Windows;
public class TaskPanel : Base public class TaskPanel : Base
{ {
@ -30,21 +32,21 @@ public class TaskPanel : Base
{ {
instance = this; instance = this;
hideBtn.onClick.AddListener(OnClickHideButton); hideBtn.onClick.AddListener(OnClickHideButton);
//InitList(); InitList();
//InitTask(taskIDs); InitTask(taskIDs);
} }
//public void InitList() public void InitList()
//{ {
// foreach (Task_ task in JSONReader.TaskDictionary.Values) foreach (Task_ task in JSONReader.TaskDictionary.Values)
// { {
// if (int.TryParse(task.ID, out int taskId)) if (int.TryParse(task.ID, out int taskId))
// { {
// // 转换成功,添加到 taskIDs 列表 // ת»»³É¹¦£¬Ìí¼Óµ½ taskIDs Áбí
// taskIDs.Add(taskId); taskIDs.Add(taskId);
// } }
// } }
//} }
//添加任务 //添加任务
public void Taskad(int id) public void Taskad(int id)
@ -88,7 +90,7 @@ public class TaskPanel : Base
TaskItem taskItem = go.GetComponent<TaskItem>(); TaskItem taskItem = go.GetComponent<TaskItem>();
taskItem.SetInfo(taskId, JSONReader); taskItem.SetInfo(taskId, JSONReader);
taskItems.Add(taskItem); taskItems.Add(taskItem);
go.SetActive(false);
} }
// 更新任务UI // 更新任务UI
@ -102,6 +104,19 @@ public class TaskPanel : Base
} }
} }
public void displaytask(int taskId)
{
TaskItem taskItem = taskItems.Find(t => t.overseeCond== taskId);
if (taskItem != null)
{
if (taskItem.ishow == 1)
{
taskItem.gameObject.SetActive(true);
}
}
}
// 移除任务 // 移除任务
public void RemoveTask(int taskId) public void RemoveTask(int taskId)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerTask : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Task")
{
int id = collider.GetComponent<AreaID>().Id;
Debug.Log(1111111111111111111);
Debug.Log(id);
TaskPanel.instance.displaytask(id);
}
}
void OnTriggerExit(Collider collider)
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9e82f68a3a3dee6459425052ac338531
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: